Automatic unjail - Timer does not save
#9

pawn Код:
enum pInfo
{
    pJailTime,
    JailTimer
}
new PlayerInfo[MAX_PLAYERS][pInfo];

INI_WriteInt(File,"AjailTime",0);   //When the player registers a new account
INI_WriteInt(File,"AjailTime",PlayerInfo[playerid][pJailTime]);      //Save to the .INI file

INI_Int("AjailTime",PlayerInfo[playerid][pJailTime]);              //Loading from the .INI file

CMD:jail(playerid, params[])
{
    new tID, time, reason[48], jstring[128];
    if(!gPlayerLogged[playerid]) return SCM(playerid, COLOR_GREY, NOTLOGGED);
    if(PlayerInfo[playerid][pAdmin] < 2) return SCM(playerid, COLOR_GREY, NOTADMIN);
    if(sscanf(params, "uD(9999)S(No Reason)[48]", tID, time, reason)) return SCM(playerid, -1, "[USAGE] /jail [playerid/PartOfName] [Minutes] [Reason]");
    else if(tID == INVALID_PLAYER_ID) return SCM(playerid, COLOR_GREY, INVALIDID);
    else if(PlayerInfo[tID][pAdmin] > PlayerInfo[playerid][pAdmin]) return SCM(playerid, COLOR_GREY, "[AdmCMD] You can't jail admins who are a higher level than you!");
    else if(PlayerInfo[tID][pJailTime] > 0) return SCM(playerid, COLOR_GREY, "[AdmCMD] This player is already in jail!");
    else
    {
        format(jstring, sizeof(jstring), "[AdmCMD] %s has been jailed by Administrator %s for %d minute(s), [Reason: %s]", GetName(tID), GetName(playerid), time, reason);
        SCMTA(COLOR_LIGHTRED, jstring);
        PlayerInfo[tID][pJailTime] = time*60;
        SetTimerEx("JailPlayer", 5000, false, "d", tID);
        SetTimerEx("Jail1", 1000, false, "d", tID);
    }
    return 1;
}

CMD:unjail(playerid, params[])
{
    new tID, jstring[128];
    if(!gPlayerLogged[playerid]) return SCM(playerid, COLOR_GREY, NOTLOGGED);
    if(PlayerInfo[playerid][pAdmin] < 2) return SCM(playerid, COLOR_GREY, NOTADMIN);
    if(sscanf(params, "u", tID)) return SCM(playerid, -1, "[USAGE] /unjail [playerid/PartOfName]");
    else if(tID == INVALID_PLAYER_ID) return SCM(playerid, COLOR_GREY, INVALIDID);
    else if(PlayerInfo[tID][pAdmin] > PlayerInfo[playerid][pAdmin]) return SCM(playerid, COLOR_GREY, "[AdmCMD] You can't unjail admins who are a higher level than you!");
    else if(PlayerInfo[tID][pJailTime]  < 1) return SCM(playerid, COLOR_GREY, "[AdmCMD] This player is not in jail!");
    else
    {
        format(jstring, sizeof(jstring), "[AdmCMD] %s has been unjailed by Administrator %s", GetName(tID), GetName(playerid));
        SCMTA(COLOR_LIGHTRED, jstring);
        PlayerInfo[tID][pJailTime] = 1;
        JailRelease(tID);
    }
    return 1;
}

public Jail1(playerid)
{
    TogglePlayerControllable(playerid, 0);
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    SetPlayerCameraPos(playerid, x+10, y, z+10);
    SetPlayerCameraLookAt(playerid, x, y, z);
    SetTimerEx("Jail2", 1000, false, "d", playerid);
}

public Jail2(playerid)
{
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    SetPlayerCameraPos(playerid, x+7, y, z+5);
    SetPlayerCameraLookAt(playerid, x, y, z);
    if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
    {
        SetPlayerSpecialAction(playerid, SPECIAL_ACTION_HANDSUP);
    }
    GameTextForPlayer(playerid, "~r~Admin Jailed!", 3000, 0);
    SetTimerEx("Jail3", 1000, false, "d", playerid);
}

public Jail3(playerid)
{
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    SetPlayerCameraPos(playerid, x+3, y, z);
    SetPlayerCameraLookAt(playerid, x, y, z);
}

public JailPlayer(playerid)
{
    SetPlayerPos(playerid, 197.6661, 173.8179, 1003.0234);
    SetPlayerInterior(playerid, 3);
    SetCameraBehindPlayer(playerid);
    KillTimer(PlayerInfo[playerid][JailTimer]);
    PlayerInfo[playerid][JailTimer] = SetTimerEx("JailRelease", 1000, true, "d", playerid);
    TogglePlayerControllable(playerid, 1);
}

public JailRelease(playerid)
{
    if(!IsPlayerConnected(playerid))
    {
        KillTimer(PlayerInfo[playerid][JailTimer]);
        return;
    }
    if(--PlayerInfo[playerid][pJailTime] < 1)
    {
        KillTimer(PlayerInfo[playerid][JailTimer]);
        SetPlayerInterior(playerid, 0);
        SetPlayerPos(playerid, 0.0, 0.0, 0.0);
        SpawnPlayer(playerid);
        PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
        GameTextForPlayer(playerid, "~g~Released!", 3000, 0);
    }
}

public OnPlayerSpawn(playerid)
{
    if(PlayerInfo[playerid][pJailTime] > 0)
    {
        KillTimer(PlayerInfo[playerid][JailTimer]);
        SetPlayerPos(playerid, 197.6661, 173.8179, 1003.0234);
        SetPlayerInterior(playerid, 3);
        SetCameraBehindPlayer(playerid);
        SendClientMessage(playerid, COLOR_GREY, "[JAIL] You have not served your time yet!");
        SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
        ResetPlayerWeapons(playerid);
        GameTextForPlayer(playerid, "~r~Back To Jail", 2500, 0);
        PlayerInfo[playerid][JailTimer] = SetTimerEx("JailRelease", 1000, true, "d", playerid);
    }
    else
    {
        SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
        SetPlayerPos(playerid, 1685.8979/*X*/, -2330.5691/*Y*/, -2.6797/*Z*/);
        SetPlayerFacingAngle(playerid, 360.0);
    }
    return 1;
}
Reply


Messages In This Thread
Automatic unjail - Timer does not save - by AndySedeyn - 07.05.2014, 20:52
Re: Automatic unjail - Timer does not save - by Jefff - 07.05.2014, 21:33
Re: Automatic unjail - Timer does not save - by AndySedeyn - 07.05.2014, 21:49
Re: Automatic unjail - Timer does not save - by Jefff - 07.05.2014, 23:53
Re: Automatic unjail - Timer does not save - by AndySedeyn - 08.05.2014, 04:33
Re: Automatic unjail - Timer does not save - by AndySedeyn - 08.05.2014, 14:29
Re: Automatic unjail - Timer does not save - by Jefff - 09.05.2014, 00:33
Re: Automatic unjail - Timer does not save - by AndySedeyn - 09.05.2014, 04:38
Re: Automatic unjail - Timer does not save - by Jefff - 09.05.2014, 16:48
Re: Automatic unjail - Timer does not save - by AndySedeyn - 10.05.2014, 06:53

Forum Jump:


Users browsing this thread: 1 Guest(s)