@name I like trains
@persist Train:entity Target:entity
@trigger all

#This is my ver first propcore & applyforce mini project... Just made it
#to learn and understand them a bit more. I keep getting asked for it in 
#every server i go so here it is. Many things can be changed. Do with it
#as you wish. Special thanks to Meow.TilDe` for his patience with me and
#all the help with this...
#make sure to visit us in our server... search tilde in the browser.
#Due to the lack of ability to make it nocollide with the world AND
#do any damage to players, this will only work in open spaces.

entity():setAlpha(255)
runOnTick(1)
runOnChat(1)
Me=owner()

if(first())
{
        hint("Trainwax by BooSt.TilDe`",10)
        hint("Type !trainwax <players partial or full name>",20)
        hint("DONT BE A FUCKING MINGE WITH THIS!",10)
        hint("You can get banned instantly with this in RP servers, again, dont be an idiot with this",20)
}


#Chat commands#
LastSaid = Me:lastSaid():explode(" ")
if(chatClk(Me))
{
    #we use the first word "!trainwax" to activate
    if(LastSaid[1,string]=="iliketrains")
    {
        
            Target = findPlayerByName(LastSaid[2,string])
            hint("Trainwaxing " + toString(Target) + "",3) 
            Train=propSpawn("models/props_trainstation/train001.mdl",owner():pos()+vec(0,2500,120),ang(0,0,0),0)
            #Trainwax sound
            Target:soundPlay(1,0,"ambient/alarms/train_horn2.wav")
            Target:soundPlay(2,0,"ambient/alarms/train_crossing_bell_loop1.wav")
            #Start a timer so we delete the train after trainwaxing
            timer("Timer",5000)
        
    }
}
Train:applyForce(vec(0,-300,0)*Train:mass())

if(clk("Timer"))
{
    Train:propDelete()
    soundStop(2)
}
