Detection of is player near any source of 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: Detection of is player near any source of water (
/showthread.php?tid=573052)
Detection of is player near any source of water -
Beckett - 04.05.2015
I've been searching through the forums for a quite while for a function that checks if player is nearby any source of water,
NOT SWIMMING.
I hope I explained it well, thanks in advance.
Re: Detection of is player near any source of water -
Gammix - 04.05.2015
Using mapandreas, this will work:
https://sampforum.blast.hk/showthread.php?tid=275492
Use it as a stock if in include or declare it as a function in the script.
pawn Code:
stock IsPlayerNearWater(playerid)
{
static Float:pos[3];
GetPlayerPos(playerid, pos[0], pos[1], pos[2]);//read positions
static Float:check_pos[3];
static Float:angle;
#define THRESHOLD 4.0
#define RADIUS 5.0
if(pos[2] > 0.0 && pos[2] < THRESHOLD)
{
for(new i = 0; i < 4; i++)
{
check_pos[0] = pos[0] + (RADIUS * floatsin(-angle, degrees));
check_pos[1] = pos[1] + (RADIUS * floatcos(-angle, degrees));
angle += 90.0;
MapAndreas_FindZ_For2DCoord(check_pos[0], check_pos[1], check_pos[2]);
if(check_pos[2] == 0.0) return true;
}
}
return false;
}
Re: Detection of is player near any source of water -
Beckett - 04.05.2015
I'll try this when I have the time and reply to you back, thanks for dedicating your time into this.