Not working properly when 3 players are using the cmd
#1

Hello, this system doesnt work properly when 3 players are using it at the same time
this is for my fishing system.
lets say that player 1 and player 2 is fishing, then player 3 comes and fish too.
he type /fish, and one second after it says "You left the water" does anyone know whats wrong?
this is only happening when 3 or more are fishing at the same time.

This is the code that will stop the fishing if they leave the water, its a timer that checks every second
pawn Код:
for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(!IsPlayerNearWater(i))
        {
            if(Fishing[i] == 1)
            {
                SendClientMessage(i, COLOR_GREY, "You left the water.");
                Fishing[i] = 0;
                RemovePlayerAttachedObject(i,0);
                KillTimer(fishtimer[i]);
            }
        }
    }
This is the code that checks if the player is near the water
pawn Код:
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   20.0
    #define RADIUS      5.0
    if(pos[2] > -20.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


Forum Jump:


Users browsing this thread: 1 Guest(s)