04.05.2015, 09:14
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:
#include <mapandreas>
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;
}