jailing command
#1

Im making a jail command now i placed the timer to the unjail in ongamemodeinit but it only counts to negative numbers even if the player jailtime is 0, it still counts to negative numbers as long as the player connect to server...
PHP код:
//ongamemodeinit
    
SetTimer("PrisonTimer"1000true);
//the command
CMD:ajail(playeridparams[])
{
    if(
IsPlayerAdmin(playerid) || pInfo[playerid][Admin] >= 3)
    {
        new 
playerbtimestring[128], RandomCell;
         if(
sscanf(params"uis[64]"playerbtimeparams)) return SendClientMessage(playeriderror"Usage: /ajail [playerid] [time] [reason]");
        if(!
IsPlayerConnected(playerb)) return SendClientMessage(playeriderror"Player id not connected.");
        if(
time == 0)
        {
            if(!
pInfo[playerb][Jailed]) return SendClientMessage(playerid0xFFFFFF"Player is not prisoned.");
            
SetPlayerColor(playerberror);
            
pInfo[playerb][Jailed] = 0;
            
pInfo[playerb][JailedTime] = time;
            
SetPlayerInterior(playerb0);
            
SetPlayerVirtualWorld(playerb0);
            
RandomCell random(sizeof(RandomJails));
            
SetPlayerFacingAngle(playerb88.5042);
            
SetPlayerPos(playerb1548.8394,-1669.6111,13.5656);
            
SetCameraBehindPlayer(playerb);
            
format(stringsizeof(string), "[AdmCmd]: {FF6347}An Administrator has released %s from Jail. [Reason: %s]",GetName(playerb), params);
            
SendClientMessageToAll(redstring);
            
format(stringsizeof(string), "[AdmCmd]:{FF6347}You have been released by administrator %s.",GetName(playerid));
            
SendClientMessage(playerid,redstring);
            
TogglePlayerControllable(playerb1);
        }
        else
        {
            
SetPlayerColor(playerberror);
            
pInfo[playerb][Jailed] = 2;
            
pInfo[playerb][JailedTime] = time*60;
            
SetPlayerVirtualWorld(playerb1337);
                  
SetPlayerInterior(playerb3);
            
ResetPlayerWeapons(playerb);
            
RandomCell random(sizeof(RandomJails));
            
SetPlayerFacingAngle(playerbRandomJails[RandomCell][3]);
            
TogglePlayerControllable(playerb0);
            
SetTimerEx("EnterExitTimer"5000false"i"playerb);
            
SetPlayerPos(playerbRandomJails[RandomCell][0], RandomJails[RandomCell][1], RandomJails[RandomCell][2]);
            
SetCameraBehindPlayer(playerb);
            
format(stringsizeof(string), "[AdmCmd]: {FF6347}An Administrator has jailed %s. [Reason: %s]"GetName(playerb), params);
            
SendClientMessageToAll(redstring);
            
format(stringsizeof(string), "[AdmCmd]: {FF6347}You have been jailed by administrator %s. Minutes: %d || Seconds: %d",GetName(playerid), pInfo[playerb][JailedTime]/60pInfo[playerb][JailedTime]);
            
SendClientMessage(playerbredstring);
            
GameTextForPlayer(playerb"~w~Loading Objects"35003);
            
TogglePlayerControllable(playerb0);
            
SetTimerEx("EnterExitTimer"5000false"i"playerb);
            
pInfo[playerb][pSpawnFreeze] = 1;
            
RemovePlayerAttachedObject(playerb0);
            
SetPlayerSpecialAction(playerbSPECIAL_ACTION_NONE);
        }
    }
      else return 
ShowMessage(playeriderror1);
      return 
1;

PHP код:
forward PrisonTimer();
public 
PrisonTimer()
{
    foreach(
Playerplayerid)
    {
        if(
pInfo[playerid][Jailed] == 2)
        {
            
pInfo[playerid][Jailed] = 0;
            
pInfo[playerid][JailedTime] = 0;
            
SetPlayerInterior(playerid0);
            
SetPlayerVirtualWorld(playerid0);
            
SetPlayerFacingAngle(playerid88.5042);
            
SetPlayerColor(playeriderror);
            
SetPlayerPos(playerid1548.8394,-1669.6111,13.5656);
            
SetCameraBehindPlayer(playerid);
            
SendClientMessage(playeridjblue" Time Served. Be on your best behaviour now :) .");
        }
        else
        {
            new 
string[128];
            
pInfo[playerid][JailedTime] --;
            
format(string,sizeof(string),"~r~Jailed Time Left: ~w~%d ~r~seconds"pInfo[playerid][JailedTime]);
            
GameTextForPlayer(playeridstring15003);
        }
    }
    return 
1;

Reply


Messages In This Thread
jailing command - by 1fret - 17.04.2017, 03:32
Re: jailing command - by sams90 - 17.04.2017, 03:48
Re: jailing command - by 1fret - 17.04.2017, 03:56
Re: jailing command - by sams90 - 17.04.2017, 03:56
Re: jailing command - by 1fret - 17.04.2017, 04:25
Re: jailing command - by khRamin78 - 17.04.2017, 05:48
Re: jailing command - by 1fret - 17.04.2017, 19:39
Re: jailing command - by khRamin78 - 17.04.2017, 19:42
Re: jailing command - by 1fret - 17.04.2017, 19:45

Forum Jump:


Users browsing this thread: 3 Guest(s)