Detecting if Player entered Water - 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)
+--- Thread: Detecting if Player entered Water (
/showthread.php?tid=465173)
Detecting if Player entered Water -
alinategh - 21.09.2013
Hello there, i was thinking if there is any way to detect if the player is in Water, or if player entered water, or Exited from Water... I searched around for some Callbacks for it but i didn't find any, and i know it exists and there IS a way for it cuz i saw it in a few servers. Please if you know, let me know.
Thanks In Advance and +REP to whoever help me.
Re: Detecting if Player entered Water -
DanishHaq - 21.09.2013
You could check if he's under sea level or you could check if a player is swimming with this include:
http://forum.sa-mp.com/showthread.ph...PlayerSwimming.
Re: Detecting if Player entered Water -
redreaper666 - 21.09.2013
The water high is always 0 on the z achse.
Means:
new Zpos[MAX_PLAYERS];
new Float:X,Y,Z;
GetPlayerPos(playerid,X,Y,Z);
Zpos[playerid] = Z;
If(Zpos[playerid] < 0)
{
He is in water
}
else
{
He is not in the water
}
Re: Detecting if Player entered Water -
Dragonsaurus - 21.09.2013
Checking whether the player is playing a swimming animation and the z coordinate being below 0.
Do the opposite of this to detect if he exits water.
Edit: Late, late, late, more late...
Re: Detecting if Player entered Water -
alinategh - 21.09.2013
Quote:
Originally Posted by DanishHaq
|
Thnx, really, +REP
Thnx to Dragonsaurus and redreaper666 too, really helpful thnx
Re: Detecting if Player entered Water -
Macluawn - 21.09.2013
Not true. There are places where water is above the 0 coordinate. For example, pirate ship in Las Venturas or swimming pools in Vinewood.
Its best to check for animation rather than position.