Check if player is at X height?
#1

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...?
Reply
#2

OnPlayerUpdate, technically still using a timer. And probably a waste of code.
Reply
#3

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?
Reply
#4

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)
Reply
#5

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?
Reply
#6

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?
Reply
#7

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.
Reply
#8

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?
Reply
#9

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;
}
Reply
#10

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...?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)