Is player near water (fishing system)
#8

Doesn't seem like anyone can think outside the box here.

pawn Code:
#include <a_samp>
#include <zcmd>
#include <mapandreas>

#define         MAX_Z_FISH_THRESHOLD            4.0
#define         WATER_CHECK_RADIUS              5.0

IsPlayerNearWater(playerid)
{
    new Float:x, Float:y, Float:z, Float:checkx, Float:checky, Float:checkz, Float:angle;
   
    GetPlayerPos(playerid, x, y, z);
   
    // Make sure player is at correct Z-Height (Will not work near the dam)
    if(z > 0.0 && z < MAX_Z_FISH_THRESHOLD)
    {
        // Check North/East/South/West for water
        for(new i = 0; i < 4; i++)
        {
            checkx = x + (WATER_CHECK_RADIUS * floatsin(-angle, degrees));
            checky = y + (WATER_CHECK_RADIUS * floatcos(-angle, degrees));
            angle += 90.0;

            // Find the Z
            MapAndreas_FindZ_For2DCoord(checkx, checky, checkz);

            // Doesn't work under bridges
            if(checkz == 0.0) return 1;
        }
    }
    return 0;
}

CMD:wcheck(playerid, arg[])
{
    if(IsPlayerNearWater(playerid)) SendClientMessage(playerid, -1, "Near water!");
    else SendClientMessage(playerid, -1, "Not Near water!");
    return 1;
}
Reply


Messages In This Thread
Is player near water (fishing system) - by Natric - 22.08.2014, 13:53
Re: Is player near water (fishing system) - by Virtual1ty - 22.08.2014, 13:57
Re: Is player near water (fishing system) - by Natric - 22.08.2014, 14:06
Re: Is player near water (fishing system) - by Virtual1ty - 22.08.2014, 14:09
Re: Is player near water (fishing system) - by ThePhenix - 22.08.2014, 14:22
Re: Is player near water (fishing system) - by cnoopers - 22.08.2014, 14:23
Re: Is player near water (fishing system) - by Hiddos - 22.08.2014, 14:27
Re: Is player near water (fishing system) - by Pottus - 22.08.2014, 14:45
Re: Is player near water (fishing system) - by Natric - 22.08.2014, 16:10
Re: Is player near water (fishing system) - by Faisal_khan - 22.08.2014, 18:10

Forum Jump:


Users browsing this thread: 1 Guest(s)