Command
#8

Quote:
Originally Posted by ReD_HunTeR
Посмотреть сообщение
You have to use MapAndreas plugin for that, velocity is not for that type of purpose.

Код:
new Float:ox, Float:oy, Float:oz, Float:mz;
GetPlayerPos(playerid, ox, oy, oz);
MapAndreas_FindZ_For2DCoord(ox, oy, mz); //this here is to find the ground coordinates you have to use mapandreas plugin
if(mz != nz) return SCM(playerid, COLOR_LIGHTRED, "* You can't plant seeds in air."); //If ground value doesn't match with the players Z coordinates returns error
https://sampforum.blast.hk/showthread.php?tid=120013
You should add a small tolerance, because a) MapAndreas isn't 100% precise and b) the player position will always be above the ground (exactly 1 unit above ground, which is the origin of the player model).

For example

Код:
if(floatabs(z - 1.0 - mz) < 0.3) // Player position must be between 0.7 and 1.3 meters above ground position (considering MapAndreas isn't precise) - a tolerance of 0.3m - subtract 1.0 from player position for the offset
{
 // Not midair
}
Still velocity is a valid way to do so. There's no way a player has a velocity of 0.0 (or similarly low) if midair, except being frozen or modding. But even then it's extremely unlikely to still have a standing/crouching animation.
MapAndreas will detect anything obstructed as underground. You could work with a combination of velocity, animation and player state to get a better result.
Reply


Messages In This Thread
Command - by KinderClans - 20.09.2018, 19:39
Re: Command - by ReD_HunTeR - 20.09.2018, 20:17
Re: Command - by KinderClans - 21.09.2018, 10:07
Re: Command - by UFF - 21.09.2018, 11:15
Re: Command - by GTLS - 21.09.2018, 13:01
Re: Command - by KinderClans - 21.09.2018, 13:34
Re: Command - by kingmk - 21.09.2018, 14:07
Re: Command - by NaS - 21.09.2018, 14:29
Re: Command - by KinderClans - 22.09.2018, 10:40
Re: Command - by NaS - 22.09.2018, 12:26

Forum Jump:


Users browsing this thread: 1 Guest(s)