Check if player is at X height? -
Memoryz - 08.10.2009
How can I check if a player is at a specific height.
Like let's say i want to respawn someone if their height is 535.2068?
And is there a better way to check other than using a timer...?
Re: Check if player is at X height? -
Calgon - 08.10.2009
OnPlayerUpdate, technically still using a timer. And probably a waste of code.
Re: Check if player is at X height? -
Memoryz - 08.10.2009
Quote:
Originally Posted by CalgonX
OnPlayerUpdate, technically still using a timer. And probably a waste of code.
|
Not a waste, if you're at a specific height, you win the game, and you get spawned to the lobby...
So how would I go about doing this then?
Re: Check if player is at X height? -
Calgon - 08.10.2009
Quote:
Originally Posted by Memoryz
Quote:
Originally Posted by CalgonX
OnPlayerUpdate, technically still using a timer. And probably a waste of code.
|
Not a waste, if you're at a specific height, you win the game, and you get spawned to the lobby...
So how would I go about doing this then?
|
pawn Код:
public OnPlayerUpdate(playerid)
{
New Float: PX, Float: PY, Float: PZ;
GetPlayerPos(playerid, PX, PY, PZ);
if(PX == 535.2068)
{
return 0;
}
else
{
return 1;
}
}
Something like that. FYI, Y is height though.
Y^
X>
Z
(down)
Re: Check if player is at X height? -
Memoryz - 08.10.2009
Okay,
Код:
AddPlayerClass(170,535.2068,-2101.1238,-0.6810,279.2928,0,0,0,0,0,0);
Is where the height should be, which variable is the height tho?
Re: Check if player is at X height? -
Memoryz - 08.10.2009
Quote:
Originally Posted by Seif_
Z is the height.
|
I know, but which number in: AddPlayerClass(170,535.2068,-2101.1238,-0.6810,279.2928,0,0,0,0,0,0);
Would be the height?
Re: Check if player is at X height? -
Abernethy - 08.10.2009
AddPlayerClass(170,535.2068,-2101.1238,
-0.6810,279.2928,0,0,0,0,0,0);
The
bold is the height, btw Calgon. You were checking the X not the Z.
Re: Check if player is at X height? -
Memoryz - 08.10.2009
Quote:
Originally Posted by Abernethy♥
AddPlayerClass(170,535.2068,-2101.1238,-0.6810,279.2928,0,0,0,0,0,0);
The bold is the height, btw Calgon. You were checking the X not the Z.
|
Thanks,
Now one more thing, how do I check if the player is between
-0.5448 and
-0.8659?
Re: Check if player is at X height? -
Abernethy - 08.10.2009
Quote:
Originally Posted by Memoryz
Quote:
Originally Posted by Abernethy♥
AddPlayerClass(170,535.2068,-2101.1238,-0.6810,279.2928,0,0,0,0,0,0);
The bold is the height, btw Calgon. You were checking the X not the Z.
|
Thanks,
Now one more thing, how do I check if the player is between -0.5448 and -0.8659?
|
Well there is a way, I've seen it with moving gates although I can't remember. This code will check if they're below -0.8659.
pawn Код:
public OnPlayerUpdate(playerid)
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, Float:X, Float:Y, Float:Z);
if (Float:Z <= -0.8659)
{
// effect
}
return true;
}
Re: Check if player is at X height? -
Memoryz - 09.10.2009
Quote:
Originally Posted by Abernethy♥
Quote:
Originally Posted by Memoryz
Quote:
Originally Posted by Abernethy♥
AddPlayerClass(170,535.2068,-2101.1238,-0.6810,279.2928,0,0,0,0,0,0);
The bold is the height, btw Calgon. You were checking the X not the Z.
|
Thanks,
Now one more thing, how do I check if the player is between -0.5448 and -0.8659?
|
Well there is a way, I've seen it with moving gates although I can't remember. This code will check if they're below -0.8659.
pawn Код:
public OnPlayerUpdate(playerid) { new Float:X, Float:Y, Float:Z; GetPlayerPos(playerid, Float:X, Float:Y, Float:Z); if (Float:Z <= -0.8659) { // effect } return true; }
|
Nice!
This is exactly what I was looking for!
Thanks =)
Just one last little thing, Im guessing this will cause a little lag...?