It does not run after "else" and the timer does not stop
#1

Hello.
When you press "KEY_FIRE" you have to wait a while for a function to run, but if you stop the time it stops.
The problem is that it does not comply with any of that, the functions for "KEY_FIRE" only execute before the first "else" and the others do not. Also when "KEY_FIRE" is released the times are not eliminated.

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if ( HOLDING(KEY_FIRE) && GetPlayerWeapon(playerid) == 41 )
    {
        if (IsPlayerInRangeOfPoint(playerid, 2.0, 1979.8413, -1167.6011, 20.1171))
        {
            if(Grafo0 == true)
            {
                if(!PLAYER_CREW[playerid][player_crew_VALID]) return 0;
                {
                    PaintGraffiti0[playerid] = SetTimerEx("PaintGraffitiObject0",30000,0,"i",playerid);
                    PaintingGraffiti[playerid] = SetTimerEx("PaintingGraffitiTextMessage",2000,1,"i",playerid);
                    ShowPlayerMessage(playerid, "Painting Graffiti", 1);
                }
            }
        }

        return 0;
    }
    else if(GetPlayerWeapon(playerid) == 41)
    {
        if (IsPlayerInRangeOfPoint(playerid, 2.0, 2440.9645, -1197.2967, 35.1560))
        {
            if(Grafo1 == true)
            {
                if(!PLAYER_CREW[playerid][player_crew_VALID]) return 0;
                {
                    PaintGraffiti1[playerid] = SetTimerEx("PaintGraffitiObject1",30000,0,"i",playerid);
                    PaintingGraffiti[playerid] = SetTimerEx("PaintingGraffitiTextMessage",2000,1,"i",playerid);
                    ShowPlayerMessage(playerid, "Painting Graffiti", 1);
                }
            }
        }

        return 0;
    }
    else if(GetPlayerWeapon(playerid) == 41)
    {
        if (IsPlayerInRangeOfPoint(playerid, 2.0, 2204.2260, -1325.6894, 23.4943))
        {
            if(Grafo2 == true)
            {
                if(!PLAYER_CREW[playerid][player_crew_VALID]) return 0;
                {
                    PaintGraffiti2[playerid] = SetTimerEx("PaintGraffitiObject2",30000,0,"i",playerid);
                    PaintingGraffiti[playerid] = SetTimerEx("PaintingGraffitiTextMessage",2000,1,"i",playerid);
                    ShowPlayerMessage(playerid, "Painting Graffiti", 1);
                }
            }
        }

        return 0;
    }
    else if(GetPlayerWeapon(playerid) == 41)
    {
        if (IsPlayerInRangeOfPoint(playerid, 2.0, 2472.0942, -1521.4567, 23.4021))
        {
            if(Grafo3 == true)
            {
                if(!PLAYER_CREW[playerid][player_crew_VALID]) return 0;
                {
                    PaintGraffiti3[playerid] = SetTimerEx("PaintGraffitiObject3",30000,0,"i",playerid);
                    PaintingGraffiti[playerid] = SetTimerEx("PaintingGraffitiTextMessage",2000,1,"i",playerid);
                    ShowPlayerMessage(playerid, "Painting Graffiti", 1);
                }
            }
        }

        return 0;
    }
    else if(GetPlayerWeapon(playerid) == 41)
    {
        if (IsPlayerInRangeOfPoint(playerid, 2.0, 2177.6616, -1778.8986, 13.0923))
        {
            if(Grafo4 == true)
            {
                if(!PLAYER_CREW[playerid][player_crew_VALID]) return 0;
                {
                    PaintGraffiti4[playerid] = SetTimerEx("PaintGraffitiObject4",30000,0,"i",playerid);
                    PaintingGraffiti[playerid] = SetTimerEx("PaintingGraffitiTextMessage",2000,1,"i",playerid);
                    ShowPlayerMessage(playerid, "Painting Graffiti", 1);
                }
            }
        }

        return 0;
    }
    else if(GetPlayerWeapon(playerid) == 41)
    {
        if (IsPlayerInRangeOfPoint(playerid, 2.0, 2406.5959, -2049.0668, 13.2881))
        {
            if(Grafo5 == true)
            {
                if(!PLAYER_CREW[playerid][player_crew_VALID]) return 0;
                {
                    PaintGraffiti5[playerid] = SetTimerEx("PaintGraffitiObject5",30000,0,"i",playerid);
                    PaintingGraffiti[playerid] = SetTimerEx("PaintingGraffitiTextMessage",2000,1,"i",playerid);
                    ShowPlayerMessage(playerid, "Painting Graffiti", 1);
                }
            }
        }

        return 0;
    }
    else if(GetPlayerWeapon(playerid) == 41)
    {
        if (IsPlayerInRangeOfPoint(playerid, 2.0, 2745.0478, -1982.1180, 13.5546))
        {
            if(Grafo6 == true)
            {
                if(!PLAYER_CREW[playerid][player_crew_VALID]) return 0;
                {
                    PaintGraffiti6[playerid] = SetTimerEx("PaintGraffitiObject6",30000,0,"i",playerid);
                    PaintingGraffiti[playerid] = SetTimerEx("PaintingGraffitiTextMessage",2000,1,"i",playerid);
                    ShowPlayerMessage(playerid, "Painting Graffiti", 1);
                }
            }
        }

        return 0;
    }
    else if(GetPlayerWeapon(playerid) == 41)
    {
        if (IsPlayerInRangeOfPoint(playerid, 2.0, 1727.0979, -1682.3328, 12.8170))
        {
            if(Grafo7 == true)
            {
                if(!PLAYER_CREW[playerid][player_crew_VALID]) return 0;
                {
                    PaintGraffiti7[playerid] = SetTimerEx("PaintGraffitiObject7",30000,0,"i",playerid);
                    PaintingGraffiti[playerid] = SetTimerEx("PaintingGraffitiTextMessage",2000,1,"i",playerid);
                    ShowPlayerMessage(playerid, "Painting Graffiti", 1);
                }
            }
        }

        return 0;
    }
    else if(GetPlayerWeapon(playerid) == 41)
    {
        if (IsPlayerInRangeOfPoint(playerid, 2.0, 1910.8919, -1417.3697, 12.8503))
        {
            if(Grafo8 == true)
            {
                if(!PLAYER_CREW[playerid][player_crew_VALID]) return 0;
                {
                    PaintGraffiti8[playerid] = SetTimerEx("PaintGraffitiObject8",30000,0,"i",playerid);
                    PaintingGraffiti[playerid] = SetTimerEx("PaintingGraffitiTextMessage",2000,1,"i",playerid);
                    ShowPlayerMessage(playerid, "Painting Graffiti", 1);
                }
            }
        }

        return 0;
    }
    else if(GetPlayerWeapon(playerid) == 41)
    {
        if (IsPlayerInRangeOfPoint(playerid, 2.0, 1801.2230, -1108.2810, 23.5881))
        {
            if(Grafo9 == true)
            {
                if(!PLAYER_CREW[playerid][player_crew_VALID]) return 0;
                {
                    PaintGraffiti9[playerid] = SetTimerEx("PaintGraffitiObject9",30000,0,"i",playerid);
                    PaintingGraffiti[playerid] = SetTimerEx("PaintingGraffitiTextMessage",2000,1,"i",playerid);
                    ShowPlayerMessage(playerid, "Painting Graffiti", 1);
                }
            }
        }

        return 0;
    }
    else if(GetPlayerWeapon(playerid) == 41)
    {
        if (IsPlayerInRangeOfPoint(playerid, 2.0, 2087.0234, -972.4073, 50.3846))
        {
            if(Grafo10 == true)
            {
                if(!PLAYER_CREW[playerid][player_crew_VALID]) return 0;
                {
                    PaintGraffiti10[playerid] = SetTimerEx("PaintGraffitiObject10",30000,0,"i",playerid);
                    PaintingGraffiti[playerid] = SetTimerEx("PaintingGraffitiTextMessage",2000,1,"i",playerid);
                    ShowPlayerMessage(playerid, "Painting Graffiti", 1);
                }
            }
        }

        return 0;
    }
    else if(GetPlayerWeapon(playerid) == 41)
    {
        if (IsPlayerInRangeOfPoint(playerid, 2.0, 1927.2662, -2116.5690, 12.7568))
        {
            if(Grafo11 == true)
            {
                if(!PLAYER_CREW[playerid][player_crew_VALID]) return 0;
                {
                    PaintGraffiti11[playerid] = SetTimerEx("PaintGraffitiObject11",30000,0,"i",playerid);
                    PaintingGraffiti[playerid] = SetTimerEx("PaintingGraffitiTextMessage",2000,1,"i",playerid);
                    ShowPlayerMessage(playerid, "Painting Graffiti", 1);
                }
            }
        }

        return 0;
    }
    else if(GetPlayerWeapon(playerid) == 41)
    {
        if (IsPlayerInRangeOfPoint(playerid, 2.0, 1077.9577, -1882.2891, 12.7068))
        {
            if(Grafo12 == true)
            {
                if(!PLAYER_CREW[playerid][player_crew_VALID]) return 0;
                {
                    PaintGraffiti12[playerid] = SetTimerEx("PaintGraffitiObject12",30000,0,"i",playerid);
                    PaintingGraffiti[playerid] = SetTimerEx("PaintingGraffitiTextMessage",2000,1,"i",playerid);
                    ShowPlayerMessage(playerid, "Painting Graffiti", 1);
                }
            }
        }

        return 0;
    }
    else if(GetPlayerWeapon(playerid) == 41)
    {
        if (IsPlayerInRangeOfPoint(playerid, 2.0, 980.6154, -1029.6491, 29.4584))
        {
            if(Grafo13 == true)
            {
                if(!PLAYER_CREW[playerid][player_crew_VALID]) return 0;
                {
                    PaintGraffiti13[playerid] = SetTimerEx("PaintGraffitiObject13",30000,0,"i",playerid);
                    PaintingGraffiti[playerid] = SetTimerEx("PaintingGraffitiTextMessage",2000,1,"i",playerid);
                    ShowPlayerMessage(playerid, "Painting Graffiti", 1);
                }
            }
        }

        return 0;
    }
    else if(GetPlayerWeapon(playerid) == 41)
    {
        if (IsPlayerInRangeOfPoint(playerid, 2.0, 673.1393, -448.9865, 15.1859))
        {
            if(Grafo14 == true)
            {
                if(!PLAYER_CREW[playerid][player_crew_VALID]) return 0;
                {
                    PaintGraffiti14[playerid] = SetTimerEx("PaintGraffitiObject14",30000,0,"i",playerid);
                    PaintingGraffiti[playerid] = SetTimerEx("PaintingGraffitiTextMessage",2000,1,"i",playerid);
                    ShowPlayerMessage(playerid, "Painting Graffiti", 1);
                }
            }
        }

        return 0;
    }
    else if(GetPlayerWeapon(playerid) == 41)
    {
        if (IsPlayerInRangeOfPoint(playerid, 2.0, 513.5759, -1628.2778, 16.0294))
        {
            if(Grafo15 == true)
            {
                if(!PLAYER_CREW[playerid][player_crew_VALID]) return 0;
                {
                    PaintGraffiti15[playerid] = SetTimerEx("PaintGraffitiObject15",30000,0,"i",playerid);
                    PaintingGraffiti[playerid] = SetTimerEx("PaintingGraffitiTextMessage",2000,1,"i",playerid);
                    ShowPlayerMessage(playerid, "Painting Graffiti", 1);
                }
            }
        }

        return 0;
    }
    else if(GetPlayerWeapon(playerid) == 41)
    {
        if (IsPlayerInRangeOfPoint(playerid, 2.0, 236.9735, -312.3251, 0.6481))
        {
            if(Grafo16 == true)
            {
                if(!PLAYER_CREW[playerid][player_crew_VALID]) return 0;
                {
                    PaintGraffiti16[playerid] = SetTimerEx("PaintGraffitiObject16",30000,0,"i",playerid);
                    PaintingGraffiti[playerid] = SetTimerEx("PaintingGraffitiTextMessage",2000,1,"i",playerid);
                    ShowPlayerMessage(playerid, "Painting Graffiti", 1);
                }
            }
        }

        return 1;
    }

    if (RELEASED( KEY_FIRE ))
    {
        CallLocalFunction("KillTimesofPaintingGraffiti", "i", playerid);
        return 1;
    }
pawn Код:
forward KillTimesofPaintingGraffiti(playerid);
public KillTimesofPaintingGraffiti(playerid)
{
    KillTimer(PaintGraffiti0[playerid]);
    KillTimer(PaintGraffiti1[playerid]);
    KillTimer(PaintGraffiti2[playerid]);
    KillTimer(PaintGraffiti3[playerid]);
    KillTimer(PaintGraffiti4[playerid]);
    KillTimer(PaintGraffiti5[playerid]);
    KillTimer(PaintGraffiti6[playerid]);
    KillTimer(PaintGraffiti7[playerid]);
    KillTimer(PaintGraffiti8[playerid]);
    KillTimer(PaintGraffiti9[playerid]);
    KillTimer(PaintGraffiti10[playerid]);
    KillTimer(PaintGraffiti11[playerid]);
    KillTimer(PaintGraffiti12[playerid]);
    KillTimer(PaintGraffiti13[playerid]);
    KillTimer(PaintGraffiti14[playerid]);
    KillTimer(PaintGraffiti15[playerid]);
    KillTimer(PaintGraffiti16[playerid]);
    KillTimer(PaintingGraffiti[playerid]);
    return 1;
}
Reply
#2

You have no clue what you are doing that is your first problem. else if's checking the same condition, shit loads of repeat code, shit loads of timer variables. At this point start over this code is garbage.
Reply
#3

Code in English.
Reply
#4

Ready, it's in English.
Reply
#5

Why do you keep checking the player's weapon? You can use it as primary check then keep on with your other if statements, and why all these variables, I don't even know why you need all these, I guess one will be enough as you're doing the same action each time, you're using a lot of timers, that can be reduced to one or two. I guess all that is the reason of the amount of time put to execute.
Reply
#6

Quote:
Originally Posted by TheToretto
Посмотреть сообщение
Why do you keep checking the player's weapon? You can use it as primary check then keep on with your other if statements, and why all these variables, I don't even know why you need all these, I guess one will be enough as you're doing the same action each time, you're using a lot of timers, that can be reduced to one or two. I guess all that is the reason of the amount of time put to execute.
I told him he needs to re-write it..... I am sure you full heartily agree.
Reply
#7

Thanks for the suggestions, now it works correctly.
Reply
#8

Quote:
Originally Posted by Pottus
Посмотреть сообщение
I told him he needs to re-write it..... I am sure you full heartily agree.
of course boss I just told him what he needs to re-write it
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)