Setting a timer to unjail, help
#1

Hey guys, one more time i need help... I made my jail cmd but now i don't know how to set a timer that unjail after 3 minuts!

Here's the code, Thanks!

pawn Код:
COMMAND:cjail(playerid, params[])
{
    if(GetPlayerColor(playerid) == 0x0259EAAA)
    {
        new toplayer;
        if(!sscanf(params, "ui", toplayer))
        {
            if(IsPlayerConnected(toplayer))
            {
                new Float:X, Float:Y, Float:Z;
                GetPlayerPos(playerid, X,Y,Z);
                if(IsPlayerInRangeOfPoint(toplayer, 20.0, X,Y,Z))
                {
                    new string[64];
                    new name[MAX_PLAYER_NAME], PlayerName[MAX_PLAYER_NAME];
                    GetPlayerName(playerid, name, sizeof(name));
                    GetPlayerName(toplayer, PlayerName, sizeof(PlayerName));
                    format(string, sizeof(string), "Cop %s Has UnStun You", name);
                    SendClientMessage(playerid, 0x0259EAAA, string);
                    format(string, sizeof(string), "You Has UnStun %s", PlayerName);
                    SendClientMessage(playerid, 0x0259EAAA, string);
                    SetPlayerPos(toplayer, 264.6288,77.5742,1001.0391);
                    return 1;
                }
                else return SendClientMessage(playerid, 0x0259EAAA, "You Are Not Near The Player.");
            }
            else return SendClientMessage(playerid, 0x0259EAAA, "Player Is Not Connected.");
        }
        else return SendClientMessage(playerid, 0x0259EAAA, "USAGE: /cjail [PlayerId/PartOfName]");
    }
    else return SendClientMessage(playerid, 0x0259, "You Are Not Cop!");
}
THANKS
Reply
#2

A variable for jailing the player:
pawn Код:
new jailed[MAX_PLAYERS]; // Put it on script top (global variable)
forward UnJail();
On the command, after setting player position (jailing him), put that:
pawn Код:
jailed[toplayer] = 1;
Also a timer:
pawn Код:
SetTimer("UnJail",180000,false); // 60000ms = 1min || 180000 = 3min
Also the cllback function:
pawn Код:
public UnJail()
{
   for(new v; v < MAX_PLAYERS; v++)
   {
         if(jailed[v] == 1)
         {
              SetPlayerPos(v, x, y, z); // Change x y z  for the position you want the players go after unjailed
              jailed[v] = 0;
         }
    return 1;
    }
Reply
#3

Thanks man!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)