Timer fu**ed up? +REP!
#1

This is my arrest system:

pawn Код:
CMD:ar1(playerid, params[])
{
    new id;
    if(GetPlayerSkin(playerid) == 285 || GetPlayerSkin(playerid) == 282 || GetPlayerSkin(playerid) == 281 || GetPlayerSkin(playerid) == 283 || GetPlayerSkin(playerid) == 288)
    if (sscanf(params, "u", id)) SendClientMessage(playerid, COLOR_LIGHTBLUE, "Usage: /ar1 [ID]");
    if(GetDistanceBetweenPlayers(playerid,id)> 2)return SendClientMessage(playerid,COLOR_RED,"[INFO]You are to far from that player");
    else if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOR_RED, "[INFO]Player not found");
    else
    {
        SetPlayerPos(id, 226.69999694824,108.5,998.59997558594);
        SetPlayerVirtualWorld(id, -1);
        SetPlayerInterior(id, 10);
        GivePlayerMoney(id, -1500);
        ResetPlayerWeapons(id);
        SendClientMessage(id, COLOR_GOLD, "[INFO]You have been Arrested, Your Sentence is 60 Seconds.");
        SendClientMessage(playerid, COLOR_GOLD, "[INFO]Player Arrested succesfully. (Arrest type: 1)");
        JailTime[playerid] = 60000;
        JailTimer[playerid] = SetTimerEx("Unjail",60000,true,"i",playerid);
        SetPlayerColor(id,orange);
        TogglePlayerControllable(id, 1);
    }
    return 1;
}
Timer Callback

pawn Код:
forward Unjail(playerid);
public Unjail(playerid)
{
     new id;
    //put it here
    if(JailTime[id] <= 60000)
    {
        //teleport the out of jail
        JailTime[id] = 60000;
        KillTimer(JailTimer[id]);
        SetPlayerPos(id, -2149,-2395.6000976563,30.200000762939);
        SetPlayerInterior(id, 0);
        SetPlayerVirtualWorld(id, 0);
        SetPlayerColor(id,COLOR_WHITE);
        SendClientMessage(id, COLOR_GOLD,"[INFO]You have been UnJailed, Now try to be a good civilian!");
    }
    return 1;
}
What happend? Every 60 secs ALL the players are unjailed :/ is impossible to play! +REP!
Reply
#2

You can use a new variable like

pawn Код:
new IsJailedInAr1[MAX_PLAYERS]; //in the top
and put the

pawn Код:
IsJailedInAr1[playerid] = 1; // in the ar1 command
and in the Timer Callback use:

pawn Код:
forward Unjail(playerid);
public Unjail(playerid)
{
     new id;
    //put it here
    if(IsJailedInAr1[playerid] == 1)
    {
       if(JailTime[id] <= 60000)
       {
          //teleport the out of jail
          JailTime[id] = 60000;
          KillTimer(JailTimer[id]);
          SetPlayerPos(id, -2149,-2395.6000976563,30.200000762939);
          SetPlayerInterior(id, 0);
          SetPlayerVirtualWorld(id, 0);
          SetPlayerColor(id,COLOR_WHITE);
          IsJailedInAr1[playerid] = 0;
          SendClientMessage(id, COLOR_GOLD,"[INFO]You have been UnJailed, Now try to be a good civilian!");
        }
    }
    return 1;
}
Try that I am sure this will help you as this only works for the player who is in Ar1!

-FalconX
Reply
#3

Haha falcon makes me laugh with his extended solution.
Gooday, your repeating your timer. look
pawn Код:
JailTimer[playerid] = SetTimerEx("Unjail",60000,true,"i",playerid);
See the 'true' parameter? that's if the timer should repeat, which you set to true..
change it to false and its all fixed
Reply
#4

Quote:
Originally Posted by Mike_Peterson
Посмотреть сообщение
Haha falcon makes me laugh with his extended solution.
Gooday, your repeating your timer. look
pawn Код:
JailTimer[playerid] = SetTimerEx("Unjail",60000,true,"i",playerid);
See the 'true' parameter? that's if the timer should repeat, which you set to true..
change it to false and its all fixed
^^ He can do that aswell, let's see if he get's fixed as I said HE CAN if he wants ^^

I just tried to help him in any way xD I just didn't notice the false/true thingy

-FalconX
Reply
#5

Whats happeninng?
Reply
#6

You do "new id;" and that by default is 0.
So you are setting ID 0s position etc

pawn Код:
new id = playerid;
Reply
#7

UE_FALCONX: Thank you!
Also thank to all the others
Reply
#8

Quote:
Originally Posted by Gooday
Посмотреть сообщение
UE_FALCONX: Thank you!
Also thank to all the others
It's alright mate! Glad that I fixed your problem

-FalconX
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)