mercredi 13 juillet 2016

Not working properly when 3 players are using the cmd

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

Code:

    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

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   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;
}

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.
Recommended article from FiveFilters.org: Most Labour MPs in the UK Are Revolting.



Not working properly when 3 players are using the cmd

Aucun commentaire:

Enregistrer un commentaire