Detection of is player near any source of water
#1

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.
Reply
#2

Using mapandreas, this will work:
pawn Code:
#include <mapandreas>
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;
}
Reply
#3

I'll try this when I have the time and reply to you back, thanks for dedicating your time into this.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)