IsPlayerNearWater not working as it should
#1

Hi

I have put this isplayernearwater function for my fishing system
But i dont Think it checks if the player is near the water, only the Z coordinate
Because i Can /fish everywhere i just have to be inder Z 15, i Can even fish at lspd

I Really hope that anybody Can help me😊

pawn Код:
if (strcmp("/fish", cmdtext, true, 10) == 0)
    {
        if(IsPlayerConnected(playerid))
        }
            if((IsPlayerNearWater(playerid)) || IsPlayerInWater(playerid))
            }
                if(Fishes[playerid][pWeight1] > 0 && Fishes[playerid][pWeight2] > 0 && Fishes[playerid][pWeight3] > 0 && Fishes[playerid][pWeight4] > 0 && Fishes[playerid][pWeight5] > 0)
                {
                    SendClientMessage(playerid, COLOR_GREY, "   You've already caught five fish, sell / eat / release them before catching more!");
                    return 1;
                }
                if(Fishing[playerid] == 0)
                {
                    //Fishing[playerid] = 1;
                    SetTimerEx("FishTimer", 5000, false, "i", playerid);
                    SendClientMessage(playerid,0xFFFFFFFF, "You threw the line in the water.");
                }
                else
                {
                    SendClientMessage(playerid,COLOR_GREY, "You already Fishing !");
                }
                return 1;
            }
            return SendClientMessage(playerid,COLOR_GREY, "You aren't at the water!");
        }
        return 1;
    }
pawn Код:
#define         MAX_Z_FISH_THRESHOLD            15.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; //return 0;
}
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)