Posts: 2,136
	Threads: 50
	Joined: Jun 2010
	
	
 
	
	
		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?
	
	
	
	
		
	
 
 
	
	
	
		
	Posts: 1,331
	Threads: 44
	Joined: Jun 2010
	
	
 
	
		
		
		14 Feb 14, 02:55PM 
(This post was last modified: 14 Feb 14, 02:56PM by Bukz.)
		
	 
	
		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
	
	
	
	
		
	
 
 
	
	
	
		
	Posts: 255
	Threads: 9
	Joined: Jun 2010
	
	
 
	
	
		When i do /setfollowplayer cn in game it sometimes works but mostly nothing happens
	
	
	
	
		
	
 
 
	
	
	
		
	Posts: 1,331
	Threads: 44
	Joined: Jun 2010
	
	
 
	
	
		Yea if setfollow player is buggy than its rather pointless writing a script that utilizes it but the ideas there.
	
	
	
	
		
	
 
 
	
	
	
		
	Posts: 2,136
	Threads: 50
	Joined: Jun 2010
	
	
 
	
		
		
		15 Feb 14, 12:29AM 
(This post was last modified: 15 Feb 14, 12:30AM by jamz.)
		
	 
	
		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'. ;)