PDA

View Full Version : Position display



guiismiti
29th November 2014, 06:31
Hi,

Just a simple idea I had to help people who need to know their position in maps in case they wanna spawn something with a mod.

I used to use the print function to check my position every 0.1s and took screenshots of the values. I noticed some people here use the same method.

I created these huds to show the position in a more "comfortable" way.



1. Precache these strings


game["labelx"] = &"^1X: ^7";
precacheString(game["labelx"]);
game["labely"] = &"^1Y: ^7";
precacheString(game["labely"]);
game["labelz"] = &"^1Z: ^7";
precacheString(game["labelz"]);


2. Call this function when the player spawns


if(isdefined(self.hud_positionx))
self.hud_positionx destroy();

self.hud_positionx = newClientHudElem(self);
self.hud_positionx.x = -80;
self.hud_positionx.y = -15;
self.hud_positionx.alignx = "left";
self.hud_positionx.horzAlign = "right";
self.hud_positionx.vertAlign = "middle";
self.hud_positionx.fontScale = 1;
self.hud_positionx setValue(0);
self.hud_positionx.sort = 9986;
self.hud_positionx.label = game["labelx"];

if(isdefined(self.hud_positiony))
self.hud_positiony destroy();

self.hud_positiony = newClientHudElem(self);
self.hud_positiony.x = -80;
self.hud_positiony.y = 0;
self.hud_positiony.alignx = "left";
self.hud_positiony.horzAlign = "right";
self.hud_positiony.vertAlign = "middle";
self.hud_positiony.fontScale = 1;
self.hud_positiony setValue(0);
self.hud_positiony.sort = 9986;
self.hud_positiony.label = game["labely"];

if(isdefined(self.hud_positionz))
self.hud_positionz destroy();

self.hud_positionz = newClientHudElem(self);
self.hud_positionz.x = -80;
self.hud_positionz.y = 15;
self.hud_positionz.alignx = "left";
self.hud_positionz.horzAlign = "right";
self.hud_positionz.vertAlign = "middle";
self.hud_positionz.fontScale = 1;
self.hud_positionz setValue(0);
self.hud_positionz.sort = 9986;
self.hud_positionz.label = game["labelz"];

for(;;)
{
wait 0.1;
origin = self getOrigin();
self.hud_positionx setValue(origin[0]);
self.hud_positiony setValue(origin[1]);
self.hud_positionz setValue(origin[2]);
}



802

Mitch
29th November 2014, 08:44
I mostly use a cvar function to print my position and then i type 'condump log.txt' to dump my console log to a file.

kung foo man
29th November 2014, 10:23
Manual client command: /viewpos shows the position and angle, too

guiismiti
29th November 2014, 13:15
interesting, will do something about that.


editted: forgot to mention the obvious - use thread for the function, since there's an infinite loop inside.

IzNoGoD
29th November 2014, 14:15
viewpos shows the position from which the player is viewing, not his origin

Tally
29th November 2014, 16:22
viewpos shows the position from which the player is viewing, not his origin

well, viewpos returns the player's origin + 60 added to Z coordinate. So, they are basically the same thing. You simply have to take 60 units off the Z coordinate.

guiismiti
29th November 2014, 16:38
well, viewpos returns the player's origin + 60 added to Z coordinate. So, they are basically the same thing. You simply have to take 60 units off the Z coordinate.

so, is origin the feet and viewpos the eyes?

Tally
29th November 2014, 16:58
so, is origin the feet and viewpos the eyes?

Yes, that is correct.

IzNoGoD
29th November 2014, 17:02
well, viewpos returns the player's origin + 60 added to Z coordinate. So, they are basically the same thing. You simply have to take 60 units off the Z coordinate.
Confirmed, although viewpos uses integers.

Also, +11 for prone and +40 for crouch