timer problem
#1

Im trying to make a reduceplayerwantedlevel system that reduces the player wanted level i made a forward and i also added a timer but it only reduces the player level once and then it stop it doesnt do it again can someone tell me whats the problem with the code?
pawn Код:
//the timer
SetTimer("ReduceWantedLevel",6000,true);// thats not the real time(6000) jus used it to test

forward ReduceWantedLevel(playerid);
public ReduceWantedLevel(playerid)
{
    for(new i = 0; i < MAX_PLAYERS;i++)
    {
    if(GetPlayerWantedLevel(i) == 0) return 1;
    else if(GetPlayerWantedLevel(i) >= 40)
    {
        SetPlayerWantedLevel(i, 35);
        SendClientMessage(i, yellow,"test");
        return 1;
    }
    else if(GetPlayerWantedLevel(i) == 35)
    {
        SetPlayerWantedLevel(i, 30);
        SendClientMessage(i, yellow, "[WANTED]: You have lost 5 wanted levels.[level 30] ");
        return 1;
    }
    else if(GetPlayerWantedLevel(i) == 30)
    {
        SetPlayerWantedLevel(i, 28);
        SendClientMessage(i, yellow, "[WANTED]: You have lost 2 wanted levels.[level 28] ");
        return 1;
    }
    else if(GetPlayerWantedLevel(i) == 28)
    {
        SetPlayerWantedLevel(i, 20);
        SendClientMessage(i, yellow, "[WANTED]: You have lost 8 wanted levels.[level 20] ");
        return 1;
    }
    else if(GetPlayerWantedLevel(i) == 20)
    {
        SetPlayerWantedLevel(i, 15);
        SendClientMessage(i, yellow, "[WANTED]: You have lost 5 wanted levels.[level 15] ");
        return 1;
    }
    else if(GetPlayerWantedLevel(i) == 15)
    {
        SetPlayerWantedLevel(i, 10);
        SendClientMessage(i, yellow, "[WANTED]: You have lost 5 wanted levels.[level 10] ");
    }
    else if(GetPlayerWantedLevel(i) == 10)
    {
        SetPlayerWantedLevel(i, 9);
        SendClientMessage(i, yellow, "[WANTED]: You have lost 1 wanted levels.[level 9] ");
    }
    else if(GetPlayerWantedLevel(i) == 9)
    {
        SetPlayerWantedLevel(i, 8);
        SendClientMessage(i, yellow, "[WANTED]: You have lost 1 wanted levels.[level 8]");
    }
    else if(GetPlayerWantedLevel(i) == 8)
    {
        SetPlayerWantedLevel(i, 7);
        SendClientMessage(i, yellow, "[WANTED]: You have lost 1 wanted levels.[level 7]");
    }
    else if(GetPlayerWantedLevel(i) == 7)
    {
        SetPlayerWantedLevel(i, 6);
        SendClientMessage(i, yellow, "[WANTED]: You have lost 1 wanted levels.[level 6]");
    }
    else if(GetPlayerWantedLevel(i) == 5)
    {
        SetPlayerWantedLevel(i, 4);
        SendClientMessage(i, yellow, "[WANTED]: You have lost 1 wanted levels.[level 4]");
    }
    else if(GetPlayerWantedLevel(i) == 4)
    {
        SetPlayerWantedLevel(i, 3);
        SendClientMessage(i,yellow, "[WANTED]: You have lost 1 wanted levels.[level 3]");
    }
    else if(GetPlayerWantedLevel(i) == 2)
    {
        SetPlayerWantedLevel(i, 1);
        SendClientMessage(i, yellow, "[WANTED]: You have lost 1 wanted levels.[level 1]");
    }
    else if(GetPlayerWantedLevel(i) == 1)
    {
        SetPlayerWantedLevel(i, 0);
        SendClientMessage(i,yellow, "[WANTED]: You have now lost your wanted levels [Innocent]");
    }
    }
    return 1;
}
Reply
#2

Wanted-levels are only from 0 to 6...

Setting it to a level higher than '6' will probably set it automatically back to '6' and since don't have an
else if(GetPlayerWantedLevel(i) == 6) in your code, it will do nothing.
Reply
#3

You are using a 'playerid' parameter when you have used a 'SetTimer' function. Parameters are only acceptable for use with the 'SetTimerEx' function. In this case, you are doing a loop for all players, so a 'playerid' parameter is unnecessary.

pawn Код:
forward ReduceWantedLevel();
public ReduceWantedLevel()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i)) continue;
        new original = GetPlayerWantedLevel(i);
        switch(original)
        {
            case 0: continue;
            case 1 .. 10: SetPlayerWantedLevel(i, (original - 1));
            case 11 .. 20: SetPlayerWantedLevel(i, (original - 5));
            case 21 .. 28: SetPlayerWantedLevel(i, (original - 8));
            case 29, 30: SetPlayerWantedLevel(i, (original - 2));
            default: SetPlayerWantedLevel(i, (original - 5));
        }
        new var = GetPlayerWantedLevel(i), fstr[55];
        format(fstr, sizeof(fstr), "[WANTED]: You have lost %d wanted levels. [Level %d]", (original - var), var);
        SendClientMessage(i, yellow, (var) ? (fstr) : ("[WANTED]: You have now lost your wanted levels [Innocent]"));
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)