@name FailCake DismemberFence
@outputs On Set Ok Part [Prop1 Prop2 PropY PropY2]:entity Timeout Once [Vec]:vector
@persist Chat:array
@trigger all
@model models/props_combine/combine_interface001.mdl
runOnTick(1)
runOnChat(1)

#effects/combineshield/comshieldwall
 
E = entity()
O = owner()

if(first()){
E:setSkin(1)
Part = 0
On = 0
Set = 1
Ok = 0   
Once = 0 

Prop1:propDelete()
Prop2:propDelete()

print("* SetMode Activated *") 
print("Select the First Pos")

}

Chat = O:lastSaid():explode(" ")

if(chatClk(O)){
    
if(Chat[1,string] =="!set"){
On = 0
Set = 1   

Prop1:propDelete()
Prop2:propDelete()

print("* SetMode Activated *") 
print("Select the First X Pos")
}
}

if(Timeout){
timer("hold",700)
if(clk("hold")){
Timeout = 0
stoptimer("hold")    
}    
}

if(Set){
    
if(O:keyUse() & Timeout == 0){
    
if(Part == 0 & Timeout == 0){
Prop1 = propSpawn("models/props_junk/PopCan01a.mdl",O:aimPos(),ang(0,0,0),1)  
Part = 1
Timeout = 1
print("Select the Second X Pos")
}

if(Part == 3 & Timeout == 0){
PropY2 = propSpawn("models/props_junk/PopCan01a.mdl",O:aimPos(),ang(0,0,0),1)  
PropY2:setSkin(2)
Set = 0
Part = 0
Ok = 1
print("Positions Done Setting")
}

if(Part == 1 & Timeout == 0){
Prop2 = propSpawn("models/props_junk/PopCan01a.mdl",O:aimPos(),ang(0,0,0),1)  
Part = 2
Timeout = 1
print("Select the First Y Pos")
}

if(Part == 2 & Timeout == 0){
PropY = propSpawn("models/props_junk/PopCan01a.mdl",O:aimPos(),ang(0,0,0),1)  
Part = 3
PropY:setSkin(2)
Timeout = 1
print("Select the Second Y Pos")
}
}

  
}

if(Ok){

if(Once == 0){  
holoCreate(1) 
holoModel(1,"cube")
holoMaterial(1,"effects/com_shield004a")
print("Spawned Barrier")
Once = 1 
}    

Vec =  (Prop1:pos( ) + Prop2:pos( )) / 2
An = Prop1:pos():distance(Prop2:pos())
An2 = PropY:pos():distance(PropY2:pos())
Ang = (Prop1:pos() - Prop2:pos()):toAngle() + ang(0,90,0)

holoPos(1,Vec)
holoAng(1,Ang)
holoScaleUnits(1,vec(1,An,An2))
}

if(O:keyUse() & O:aimEntity() == E & Ok == 1 & O:pos():distance(E:pos()) <= 30){

if(On){
On = 0 
hint("* Field Turned Off *",7)   
}else{
On = 1
hint("* Field Turned On *",7)  
}
    
}


if(On){
    
}
