Automatic Jail
#1

so yeah i made jail and unjail command for some reasons i'm making when player disconnects
and join again with Jailed = 1 he/she will get jailed but the problem is when he/she spawn
OnPlayerRequestClass the jail time is ended. so thats the problem...

Code:

pawn Код:
public OnPlayerRequestSpawn(playerid)
{
    if(PlayerInfo[playerid][pJail] == 0)
    {
       new str[128];
       new pname[MAX_PLAYER_NAME],time;
       GetPlayerName(playerid, pname,MAX_PLAYER_NAME);
       format(str, sizeof(str), "%s has been autojailed <Reason: Jailed Evading>",pname);
       SendClientMessageToAll(COLOR_RED, str);
       SendClientMessage(playerid,COLOR_RED,"You cannot evade escaping from Jailed. You have been automatic jailed");
       SetPlayerInterior(playerid, 3);
       SetPlayerPos(playerid, 198.5319,162.3093,1003.0300);
       SetTimerEx("UnjailTime", time*1000, 0, "%d", playerid);
    }
    return 1;
}
pawn Код:
public UnjailTime(playerid)
{
    new string[256];
    new playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playername, sizeof(playername));
    if(IsPlayerConnected(playerid))
    SetPlayerInterior(playerid, 0);
    SpawnPlayer(playerid);
    PlayerInfo[playerid][pJail] = 0;
    format(string, sizeof(string), "%s has been unjailed <Reason: Time Ended>", playername);
    SendClientMessageToAll(COLOR_GREEN, string);
    return 1;
}
pawn Код:
CMD:jail(playerid, params[])
{
    new pid, time;
    new adminname[MAX_PLAYER_NAME], playername[MAX_PLAYER_NAME];
    GetPlayerName(pid, playername, sizeof(playername));
    GetPlayerName(playerid, adminname, sizeof(adminname));
    if(PlayerInfo[playerid][pAdmin] >= 2)
    {
        if(sscanf(params, "udz", pid, time, params[2])) return SendClientMessage(playerid,COLOR_RED, "USAGE: /jail <playername/id> <time> <reason>");
        if(PlayerInfo[playerid][pAdmin] < PlayerInfo[pid][pAdmin]) return SendClientMessage(playerid,COLOR_RED, "ERROR: You cant jail higher rank administrators");
        if(pid == INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_RED, "ERROR: Player is not connected!");
        if(PlayerInfo[pid][pJail] == 0)
        {
           new string[128];
           format(string, sizeof(string), "Administator %s has jailed %s for %d seconds <Reason: %s>", adminname,playername,time,params[2]);
           SendClientMessageToAll(COLOR_RED, string);
           format(string, sizeof(string), "Administator %s has jailed you for %d seconds <Reason: %s>", adminname,time,params[2]);
           SendClientMessage(pid,COLOR_RED, string);
           format(string, sizeof(string), "You jailed %s for %d seconds <Reason: %s>",playername, time, params[2]);
           SendClientMessage(playerid,COLOR_RED, string);
           TogglePlayerControllable(pid, 1);
           SetPlayerInterior(pid, 3);
           SetPlayerPos(pid, 198.5319,162.3093,1003.0300);
           SetTimerEx("UnjailTime", time*1000, 0, "%d", pid);
           PlayerInfo[pid][pJail] = 1;
        }
        else return SendClientMessage(playerid,COLOR_RED, "ERROR: Player is already jailed!");
    }
    else return SendClientMessage(playerid,COLOR_RED, "ERROR: You must be Administrar Level 2 to use this command");
    return 1;
}

CMD:unjail(playerid, params[])
{
    new pid,reason[128];
    new adminname[MAX_PLAYER_NAME];
    new pname[MAX_PLAYER_NAME];
    GetPlayerName(playerid,adminname,MAX_PLAYER_NAME);
    GetPlayerName(pid,pname,MAX_PLAYER_NAME);
    if(PlayerInfo[playerid][pAdmin] >= 2)
    {
        if(sscanf(params, "uz", pid, reason)) return SendClientMessage(playerid,COLOR_RED, "USAGE: /unjail <playername/id> <reason>");
        if(PlayerInfo[playerid][pAdmin] < PlayerInfo[pid][pAdmin]) return SendClientMessage(playerid,COLOR_RED, "ERROR: You cant unjail higher rank administrators");
        if(pid == INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_RED, "ERROR: Player is not connected!");
        if(PlayerInfo[pid][pJail] == 1)
        {
           new string[128];
           format(string, sizeof(string), "Administator %s has unjail %s <Reason: %s>", adminname,pname,reason[2]);
           SendClientMessageToAll(COLOR_RED, string);
           format(string, sizeof(string), "Administator %s has unjail you <Reason: %s>", adminname,reason);
           SendClientMessage(pid,COLOR_GREEN, string);
           format(string, sizeof(string), "You unjail %s <Reason: %s>",pname,reason[2]);
           SendClientMessage(playerid,COLOR_GREEN, string);
           TogglePlayerControllable(pid, 1);
           SetPlayerInterior(pid, 0);
           SpawnPlayer(pid);
           PlayerInfo[pid][pJail] = 0;
        }
        else return SendClientMessage(playerid,COLOR_RED,"ERROR: This Player is already unjail");
    }
    else return SendClientMessage(playerid,COLOR_RED,"ERROR: You must be Administrator Level 2 to use this command");
    return 1;
}
Please help

UPDATE: even i turn it to the right value it still the same. and also i want to add that Jail Time = %s for the Jailed = 1 so if i edit the scriptfiles of players and turn it to 1 and the timer the player would not be buggy. but whats the problem?
Reply


Messages In This Thread
Automatic Jail - by GAMER_PS2 - 10.11.2011, 03:13
Re: Automatic Jail - by Saurik - 10.11.2011, 03:35
Re: Automatic Jail - by GAMER_PS2 - 10.11.2011, 04:21
Re: Automatic Jail - by Saurik - 10.11.2011, 04:30
Re: Automatic Jail - by GAMER_PS2 - 10.11.2011, 04:35
Re: Automatic Jail - by Norn - 10.11.2011, 04:44
Re: Automatic Jail - by Saurik - 10.11.2011, 04:46
Re: Automatic Jail - by GAMER_PS2 - 10.11.2011, 05:01
Re: Automatic Jail - by Norn - 10.11.2011, 05:03
Re: Automatic Jail - by GAMER_PS2 - 10.11.2011, 05:08

Forum Jump:


Users browsing this thread: 2 Guest(s)