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

Have questions about CoD/UO mapping that aren't covered in the tutorials section? Post here!

Moderator: Core Staff

Post Reply
xeno
CJ Wannabe
CJ Wannabe
Posts: 38
Joined: October 31st, 2007, 12:37 am
Location: United States - GA

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

Post by xeno » May 14th, 2009, 3:27 am

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;
	}
}
Image

User avatar
Nightmare
Core Staff
Core Staff
Posts: 2688
Joined: January 12th, 2006, 10:09 pm
Contact:

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

Post by Nightmare » May 14th, 2009, 3:47 am

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;
	}
}
Coding is Poetry. Mapping is Art.
"Cause im the sexiest mapper ever...except for nm, that sexy man" - Soviet

-=[CoDJumper.com Movies]=-
[Ambush] || [Backlot] || [Bloc] || [Bog] || [Broadcast] || [Chinatown] || [Countdown]
[Crash] || [Creek] || [Crossfire] || [District] || [Downpour] || [Killhouse] || [Overgrown]
[Pipeline] || [Shipment & Wetwork] || [Showdown] || [Strike] || [Vacant]

xeno
CJ Wannabe
CJ Wannabe
Posts: 38
Joined: October 31st, 2007, 12:37 am
Location: United States - GA

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

Post by xeno » May 14th, 2009, 4:23 am

Thank you so much :D
Image

Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 1 guest