@name Robotboy655's Expression Two: Signalizacija
@inputs
@outputs Active
@persist On Alarm Eject AlarmS
@trigger 

# CAR ALARM, BAD CODED, TO BE DELETED

runOnChat(1)
interval(1)

Player = owner()
Vehicle = entity():isWeldedTo()
Active = Vehicle:driver():name() != ""

if(lastSpoke() == Player & lastSaidWhen() == curtime())
{
    Args = lastSaid():explode(" ")
    Cmd = Args:string(1):lower()
    Args:remove(1)
    
    if(Cmd == "!on")
    {
        hideChat(1)
        On = 1
        printColor(vec(255,255,255),"Signalisation turned ",vec(0,255,0),"on")
    }
    if(Cmd == "!off")
    {
        hideChat(1)
        On = 0
        printColor(vec(255,255,255),"Signalisation turned ",vec(0,255,0),"off")
    }
    if(Cmd == "!offa")
    {
        hideChat(1)
        AlarmS = 0
        soundStop("alarm")
        printColor(vec(255,255,255),"Signalisation turned ",vec(0,255,0),"off")
    }
}

if(Active == 1 & On == 1 & Vehicle:driver() != Player & Alarm == 0)
{
    hint("Car stolen by " + Vehicle:driver():name(),5)
    Vehicle:hintDriver("No car stealing! Made by robotboy655!",5)
    timer("StartEject",100)
    Alarm = 1
}
if(Active == 1 & On == 1 & Vehicle:driver() != Player & AlarmS == 0)
{
    Vehicle:soundPlay("alarm",0,"npc/turret_floor/alarm.wav")
    AlarmS = 1
}
if(!Vehicle:driver())
{
    Eject = 0
    Alarm = 0
    stoptimer("StartEject")
}

if(clk("StartEject") & Active == 1 & On == 1 & Vehicle:driver() != Player & Eject == 0)
{
    Vehicle:ejectPod()
    stoptimer("StartEject")
    Eject = 0
    On = 1
    Alarm = 1
}
