jail timer
#2

PHP код:
new JT[MAX_PLAYERS];

CMD:jail(playerid,params[]) { 
    if(
PlayerInfo[playerid][LoggedIn] == 1) { 
        if(
PlayerInfo[playerid][Level] >= 1) { 
            new 
tmp[256], tmp2[256], tmp3[256], Indextmp strtok(params,Index), tmp2 strtok(params,Index), tmp3 strtok(params,Index); 
            if(
isnull(params)) return SendClientMessage(playeridred"USAGE: /jail [playerid] [minutes] [reason]"); 
            new 
player1playername[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME], string[128]; 
            
player1 strval(tmp); 

             if(
IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID && (PlayerInfo[player1][Level] != ServerInfo[MaxAdminLevel]) ) { 
                if(
PlayerInfo[player1][Jailed] == 0) { 
                    
GetPlayerName(player1playernamesizeof(playername)); GetPlayerName(playeridadminnamesizeof(adminname)); 
                    new 
jtime strval(tmp2); 
                    if(
jtime == 0jtime 9999

                       
CMDMessageToAdmins(playerid,"JAIL"); 
                    
PlayerInfo[player1][JailTime] = jtime*1000*60
                    
SetTimerEx("JailPlayer",5000,0,"d",player1); 
                    
SetTimerEx("Jail1",1000,0,"d",player1); 
                    
PlayerInfo[player1][Jailed] = 1
                    
PlayerPlaySound(player1,1057,0.0,0.0,0.0); 

                    if(
jtime == 9999) { 
                        if(!
strlen(params[strlen(tmp2)+1])) format(string,sizeof(string),"Administrator %s has jailed %s ",adminnameplayername); 
                        else 
format(string,sizeof(string),"Administrator %s has jailed %s [reason: %s]",adminnameplayernameparams[strlen(tmp)+1] ); 
                       } else { 
                        if(!
strlen(tmp3)) format(string,sizeof(string),"Administrator %s has jailed %s for %d minutes",adminnameplayernamejtime); 
                        else 
format(string,sizeof(string),"Administrator %s has jailed %s for %d minutes [reason: %s]",adminnameplayernamejtimeparams[strlen(tmp2)+strlen(tmp)+1] ); 
                        
JT[player1] = jtime;
                    } 
                    return 
SendClientMessageToAll(blue,string); 
                } else return 
SendClientMessage(playeridred"Player is already in jail"); 
            } else return 
SendClientMessage(playeridred"Player is not connected or is the highest level admin"); 
        } else return 
SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command"); 
    } else return 
SendClientMessage(playerid,red,"ERROR: You must be logged in to use this commands"); 


forward JailPlayer(player1); 
public 
JailPlayer(player1

    new 
str[128]; 
    
ResetPlayerWeapons(player1); 
    
SetPlayerInterior(player13); 
    
TogglePlayerControllable(player1,true); 
    
SetPlayerPos(player1,197.6661,173.8179,1003.0234); 
    
SetCameraBehindPlayer(player1); 
    
JT[player1]--; // Decreasing the timer
    
format(strsizeof(str), "%d"JT[[player1]);
    
GameTextForPlayer(player1strjtime,3);
    
JailTimer[player1] = SetTimerEx("JailRelease",PlayerInfo[player1][JailTime],0,"d",player1); 
    
PlayerInfo[player1][Jailed] = 1

Advice:
-strtok is outdated, use sscanf instead.
-Why making so much functions while you could do it in 1 function itself? [Apart from the Release function]
Reply


Messages In This Thread
jail timer - by sanamalik400 - 20.11.2015, 13:47
Re: jail timer - by Karan007 - 20.11.2015, 15:35
Re: jail timer - by sanamalik400 - 20.11.2015, 15:55
Re: jail timer - by sanamalik400 - 21.11.2015, 03:56
Re: jail timer - by DaniceMcHarley - 21.11.2015, 05:13
Re: jail timer - by Logic_ - 21.11.2015, 05:43
Re: jail timer - by sanamalik400 - 21.11.2015, 17:03
Re: jail timer - by Logic_ - 22.11.2015, 07:38
Re: jail timer - by sanamalik400 - 22.11.2015, 07:50
Re: jail timer - by Logic_ - 22.11.2015, 07:54

Forum Jump:


Users browsing this thread: 1 Guest(s)