How to use onSpawn
#1
I want to use a combination of setfollowplayer and onSpawn to spectate a player in-game. Right now (should be fixed/modified if anybody wants to patch it) spectate moves to the next alive cn when the player you're watching dies, or switches to free spectate if no-one is alive. I'd like it to switch back to a set cn when that player respawns.
However, I can't understand how to use onSpawn. I know it needs to be 'declared' first, but how do I integrate the cn into this, and how do I combine it with setfollowplayer?
Thanks given by:
#2
something like:

[cubescript]
checkinit mapstartalways [
cntostalk = -1
]

checkinit onSpawn [
thecn = $arg1
if (!= $thecn (player1 cn)) [
// someone other than you spawned
if (isclient $cntostalk) [
setfollowplayer $cntostalk
]
]
][/cubescript]

When you wanna stalk someone everytime they spawn just do:

/cntostalk = CLIENT_NUMBER_OF_PLAYER_HERE

P.S. I didn't test it and it can be made way better. I'll work on that but for now I'm lazy and you'll get the idea. :p
Thanks given by:
#3
When i do /setfollowplayer cn in game it sometimes works but mostly nothing happens
Thanks given by:
#4
Yea if setfollow player is buggy than its rather pointless writing a script that utilizes it but the ideas there.
Thanks given by:
#5
I agree with you both. I've only started using it today and it rarely works. Thanks for the time though, Bukz. At least I know how to see it fail properly now. :/

BTW, not 'stalk'; 'learn from'. ;)
Thanks given by: