SA-MP Forums Archive
How can i check if the player is in the air or not? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How can i check if the player is in the air or not? (/showthread.php?tid=145708)



How can i check if the player is in the air or not? - Torran - 03.05.2010

Well title says all..

How can i check if the player is in the air, Or on the ground?


Re: How can i check if the player is in the air or not? - RyDeR` - 03.05.2010

You can chech his Z position.


Re: How can i check if the player is in the air or not? - Torran - 03.05.2010

Quote:
Originally Posted by » RyDeR «
You can chech his Z position.
So like

pawn Код:
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
if(z > 20) return whatever here;



Re: How can i check if the player is in the air or not? - Steven82 - 03.05.2010

Quote:
Originally Posted by Joe Torran C
Quote:
Originally Posted by » RyDeR «
You can chech his Z position.
So like

pawn Код:
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
if(z > 20) return whatever here;
I think that is correct, try it


Re: How can i check if the player is in the air or not? - [XST]O_x - 03.05.2010

Quote:
Originally Posted by Steven82
Quote:
Originally Posted by Joe Torran C
Quote:
Originally Posted by » RyDeR «
You can chech his Z position.
So like

pawn Код:
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
if(z > 20) return whatever here;
I think that is correct, try it
It can't be,the height of Mount Chilliad for example is much more than 20,so if the player will be on the ground
on a higher place the function will still work,so it can't be(or atleast thats what i think)


Re: How can i check if the player is in the air or not? - Torran - 03.05.2010

Quote:
Originally Posted by O_x
Quote:
Originally Posted by Steven82
Quote:
Originally Posted by Joe Torran C
Quote:
Originally Posted by » RyDeR «
You can chech his Z position.
So like

pawn Код:
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
if(z > 20) return whatever here;
I think that is correct, try it
It can't be,the height of Mount Chilliad for example is much more than 20,so if the player will be on the ground
on a higher place the function will still work,so it can't be(or atleast thats what i think)
Its only for certain places and there all below 20


Re: How can i check if the player is in the air or not? - ZeRo_HUN - 03.05.2010

You can use the MapAndreas plugin.


Re: How can i check if the player is in the air or not? - [cA]Unforseen - 03.05.2010

Quote:
Originally Posted by O_x
Quote:
Originally Posted by Steven82
Quote:
Originally Posted by Joe Torran C
Quote:
Originally Posted by » RyDeR «
You can chech his Z position.
So like

pawn Код:
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
if(z > 20) return whatever here;
I think that is correct, try it
It can't be,the height of Mount Chilliad for example is much more than 20,so if the player will be on the ground
on a higher place the function will still work,so it can't be(or atleast thats what i think)
this is right
there is 1way
use if(IsPlayerInArea(...
use the area of mount chilliad...


Re: How can i check if the player is in the air or not? - Calgon - 03.05.2010

Use MapAndreas for absolute accuracy.


Re: How can i check if the player is in the air or not? - Gamer_Z - 03.05.2010

only and only map andreas, if u want to do it with area's good luck with speed and amount of code, just use this:
just an example
pawn Код:
IsPlayerInAir(playerid){
  new Float:varx,Float:vary,Float:varz,Float:var1,Float:diff;
  GetPlayerPos(playerid, varx, vary, varz);
  MapAndreas_FindZ_For2DCoord(varx, vary, var1);
  if(varz < var1){
    diff = varz-var1;
    if(diff > 5){
      return 1;// player is in air
    }else{
      return 0;//player is on the ground
    }
  }else
  if(varz => var1){
    diff = var1-varz;
    if(diff > 5){
      return -1;// player is under ground
    }else{
      return 0;//player is on the ground
    }
  }
  return 0;
}