21 Jun 15, 10:45PM
I know there's already a script which makes you respawn on the same team as before but this one is event based... the idea is that you don't have to sleep for 500ms or something just to make sure the sleep time is larger than the ping so you actually went to spectate. Instead it switches back as soon as you're in spectate which results in a much faster respawn.
fireEvent was a more general approach so it also counts the milliseconds passed since waiting to fire but for sure you can't let two events race each other the second one will always kill the first one. As a hint though fireEvent is also really usefull for claiming and releasing admin.
And for sure the actual command created here is /respawn
fireEvent was a more general approach so it also counts the milliseconds passed since waiting to fire but for sure you can't let two events race each other the second one will always kill the first one. As a hint though fireEvent is also really usefull for claiming and releasing admin.
[SELECT ALL] Code:
alias nop []
alias fireEvent [
eventStatement = $arg1
eventListener = $arg2
if (! (&& (checkalias arg3) $arg3)) [
eventStart = (millis)
]
sleep 1 [
if ($eventStatement) [
($eventListener (- (millis) $eventStart))
] [
fireEvent $eventStatement $eventListener 1
]
]
]
checkinit mapstartalways [
eventStart = 0
eventStatement = 0
eventListener = nop
]
alias isSpectate [
return (= (curteam (player1 cn)) 4)
]
alias enterTeam [
team $teamwish
attack
]
alias respawn [
if (! (&& (checkalias arg1) $arg1)) [
if (= (curteam) 0) [
teamwish = [CLA]
]
if (= (curteam) 1) [
teamwish = [RVSF]
]
]
spectate
fireEvent isSpectate enterTeam
]