Page 1 of 1

Coordinates

Posted: July 12th, 2007, 10:48 pm
by dizzy
Is it possible to have the corrdnates of an object be displayed?

Example:

on your screen it says

X:
Y:
Z:

The coordinates always change?


Thanks,
Dizzy

Re: Coordinates

Posted: July 12th, 2007, 11:40 pm
by Drofder2004
dizzy wrote:Is it possible to have the corrdnates of an object be displayed?

Example:

on your screen it says

X:
Y:
Z:

The coordinates always change?


Thanks,
Dizzy
Yes, I have it in an unreleased mod, but at this moment I cant get hold of it. I will tr and get information posted 2moro.

Posted: July 13th, 2007, 12:09 am
by dizzy
Alright thank you very much drofder

Posted: July 13th, 2007, 4:21 pm
by Drofder2004
Entire post edited...

This is the full code, it is 100% working from what I can see...
Ok, this is what the code does and is used for...

The script creates 3 new pieces of HUD, in the bottom left. This code has been ripped from one of my mods so the text may need moved around. Which you can do in the "createHud()" section with the .x and .y values. The top number represents the players X value, the second, the players Y and finally, the third is the players Z value. This code has been redesigned to work as map code (it was originally gametype) so there is a lot more to it and may contain problems when more people are on the map.

Towards the end of the script (6-7 lines from the bottom) this forum has made 1 line into 2 because of its length, make sure it is on one line in your code.

Good luck with this and any problems or changes just reply with them.

Code: Select all

main()
{
	maps\mp\_load::main();
	thread checkPlayers();
}

checkPlayers()
{
	for(;;)
	{
		players = getentarray("player","classname");
		for(i=0;i<players.size;i++)
		{
			if((isDefined(players[i].hud_x) && isDefined(players[i].hud_y) && isDefined(players[i].hud_z)) && (players[i].sessionstate == "spectator" || players[i].sessionstate == "intermission"))
			{
				players[i] notify("destroy_hud");
				players[i] thread cleanHud();
			}
			
			if(!isDefined(players[i].hud_x) && players[i].sessionstate != "spectator" && players[i].sessionstate != "intermission")
				players[i] thread createHud();
		}
		wait 1;
	}
}

createHud()
{
	if(!isDefined(self.hud_x))
	{
		self.hud_x = newClientHudElem(self);
		self.hud_x.horzAlign = "left";
		self.hud_x.vertAlign = "bottom";
		self.hud_x.alignX = "left";
		self.hud_x.alignY = "middle";
		self.hud_x.x = 180;
		self.hud_x.y = -64;
		self.hud_x.archived = false;
		self.hud_x.font = "default";
		self.hud_x.fontscale = 0.6;
		self.hud_x setValue(0);
	}

	if(!isDefined(self.hud_y))
	{
		self.hud_y = newClientHudElem(self);
		self.hud_y.horzAlign = "left";
		self.hud_y.vertAlign = "bottom";
		self.hud_y.alignX = "left";
		self.hud_y.alignY = "middle";
		self.hud_y.x = 180;
		self.hud_y.y = -54;
		self.hud_y.archived = false;
		self.hud_y.font = "default";
		self.hud_y.fontscale = 0.6;
		self.hud_y setValue(0);
	}
	
	if(!isDefined(self.hud_z))
	{
		self.hud_z = newClientHudElem(self);
		self.hud_z.horzAlign = "left";
		self.hud_z.vertAlign = "bottom";
		self.hud_z.alignX = "left";
		self.hud_z.alignY = "middle";
		self.hud_z.x = 180;
		self.hud_z.y = -44;
		self.hud_z.archived = false;
		self.hud_z.font = "default";
		self.hud_z.fontscale = 0.6;
		self.hud_z setValue(0);
	}
   
	wait 0.5;
	self thread hud_values();
	wait 0.1;
	self thread hud_updates();
}

hud_values()
{
	self endon("destroy_hud");
	self.org = undefined;
	self.value_x = undefined;
	self.value_y = undefined;
	self.value_z = undefined;

	for(;;)
	{
		self.org = self getOrigin();
		self.value_x = self.org[0];
		self.value_y = self.org[1];
		self.value_z = self.org[2];
		wait 0.05;
	}
}

hud_updates()
{
	self endon("destroy_hud");
	for(;;)
	{
		self.hud_x setValue(self.value_x);
		self.hud_y setValue(self.value_y);
		self.hud_z setValue(self.value_z);
		wait 0.05;
	}
}

cleanHud()
{
	self.hud_x destroy();
	self.hud_y destroy();
	self.hud_z destroy();
}

Posted: July 14th, 2007, 2:38 am
by dizzy
Cool, Thank you drofder...