Page 1 of 1

Spawning a box 200 units above a player and follows them.

Posted: May 14th, 2009, 3:27 am
by xeno
I'm trying to make a command so that when I type /rcon s_find # then a box will spawn 200 units above the player of your choice and follow them around. Then it will disappear within a couple seconds. Can't seem to get it to work, even tried getting 9mm to help me. :D


This is what I have so far...

Code: Select all

whereswaldo() // spawns a box above the player in the sky
{	
	self endon("boot");

	setcvar("s_find", "");
	while(1)
	{
		if(getcvar("s_find") != "")
		{
			smitePlayerNum = getcvarint("s_find");
			players = getentarray("player", "classname");
			for(i = 0; i < players.size; i++)
			{
				thisPlayerNum = players[i] getEntityNumber();
				if(thisPlayerNum == smitePlayerNum && players[i].sessionstate == "playing") // this is the one we're looking for
				{
					model = getent(("xmodel/crate_misc_red1"));
					model.orgin = player[i].orgin;
					player[i] linkto (model);
					wait 100;
					unlink (model);
				}
			}
			setcvar("s_find", "");
		}
		wait 0.05;
	}
}

Re: Spawning a box 200 units above a player and follows them.

Posted: May 14th, 2009, 3:47 am
by Nightmare
Fixed plenty of errors, not tested but should work.

Code: Select all

main(){
	precacheModel("xmodel/crate_misc_red1");
	thread wheresWaldo();
}

wheresWaldo(){ // spawns a box above the player in the sky
	self endon("boot");
	setcvar("s_find", "");
	while(1){
		if(getcvar("s_find") != ""){
			players = getentarray("player", "classname");
			for(i = 0; i < players.size; i++){
				thatPlayer = players[i] getEntityNumber();
				if(thatPlayer == getcvarint("s_find"))
					if(isAlive(players[i]){
						model = spawn("script_model",(0,0,0));
						model setModel("xmodel/crate_misc_red1");
						model.origin = players[i].origin + (0,0,200);
						model linkto(players[i]);
						wait 100;
						model delete();
					}
			}
			setcvar("s_find", "");
		}
		wait 0.05;
	}
}

Re: Spawning a box 200 units above a player and follows them.

Posted: May 14th, 2009, 4:23 am
by xeno
Thank you so much :D