KILLTIMER
#1

The function of this code is simple, every 5 minutes it DECREASES one of a wanted level, and if you have not tried level, ie, if 0, it simply calls the KillTimer to stop counting, the problem is that if the player LOG iN SERVER wITH 0 of demand and eventually earn him a star the code does not take the stars, it just takes if I relog, it's because I'm putting it into the public SetTimer OnPlayerConnect (playerid).

HOW TO SOLVE THIS? WOULD THE TAKING OF OnPlayerConnect SetTimer (playerid)? IF SO, WHERE SHOULD I WEAR THE SetTimer?

pawn Код:
forward WantedLevelDown(playerid);
public WantedLevelDown(playerid)
{
    if(WantedPoints[playerid] == 0) return KillTimer(GetPVarInt(playerid, "Timer"));
    {
    if((WantedPoints[playerid] - 1) >= 0)
    {
        static wanSTR[100];
        -- WantedPoints[playerid];
        format(wanSTR, sizeof wanSTR, ">> seu level de procurado abaixou para %02i", WantedPoints[playerid]);

        SendClientMessage(playerid, -1, wanSTR);
        SetPlayerWantedLevel(playerid, WantedPoints[playerid]);
        if(WantedPoints[playerid] == 0) return KillTimer(GetPVarInt(playerid, "Timer"));
    }
    return 0x01;
    }
}
Reply
#2

did you use SetTimer instead of SetTimerEx?
Reply
#3

I used SetTimer Ex

pawn Код:
public OnPlayerConnect(playerid)
{
SetPVarInt(playerid, "Timer", SetTimerEx("WantedLevelDown", 120000, 1, "i", playerid));
Reply
#4

My god use proper variables.....

Код:
new WantedLevelDown[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
      WantedLevelDown[playerid] = SetTimerEx("WantedLevelDown", 120000, 1, "i", playerid);
You'll also want to use about 268200 if you want 5 minutes.

Anyways back to your original question, you could remove the KillTimers and only kill it when they disconnect this will keep checking their wanted level every 5 minutes or you could kill the timer when it reaches 0 then restart it where in the code you give them a wanted level pretty simple.
Reply
#5

Another one that I made with this type of variable and that gave the same error because of him being in onplayerconnect

Global Var
pawn Код:
new t_lesswanted[MAX_PLAYERS];
OnPlayerDisconnect
pawn Код:
KillTimer(t_lesswanted[playerid]);
OnPlayerConnect
pawn Код:
t_lesswanted[playerid] = SetTimerEx("call_lesswanted", (60000 * 5), true, "i", playerid);
Code
pawn Код:
forward call_lesswanted(playerid);
pawn Код:
public call_lesswanted(playerid)
{
    if((WantedPoints[playerid] - 1) >= 0)
    {
        static wanSTR[100];
        -- WantedPoints[playerid];
        format(wanSTR, sizeof wanSTR, ">> seu level de procurado abaixou para %02i", WantedPoints[playerid]);
       
        SendClientMessage(playerid, -1, wanSTR);
        SetPlayerWantedLevel(playerid, WantedPoints[playerid]);
    }
    return 0x01;
}
I need the KillTimer activate when the level is 0, and that the code is working again when the player earn stars.
Help please? (:
Reply
#6

(60000 * 5) this not 5 minutes by the way it's about 5:40 seconds..... use 894 as a good approximate correction so
use 894 * 60 * 5
Reply
#7

I need the KillTimer activate when the level is 0, and that the code is working again when the player earn stars.
Reply
#8

So when they earn a star put in

Код:
WantedLevelDown[playerid] = SetTimerEx("WantedLevelDown", 120000, 1, "i", playerid);
Reply
#9

I'll have to put it everywhere in my gamemode where the player earns a star? DDDD:
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)