11.09.2013, 13:21
1. You dont need 2 variables.
2. If you are using only 0-1 ( new Jailed[MAX_PLAYERS]; ), use bool: and char ( new bool:Jailed[MAX_PLAYERS char]; )
connect/disconnect
2. If you are using only 0-1 ( new Jailed[MAX_PLAYERS]; ), use bool: and char ( new bool:Jailed[MAX_PLAYERS char]; )
connect/disconnect
pawn Code:
if(JailTimer[playerid] > -1)
KillTimer(JailTimer[playerid]);
JailTimer[playerid] = -1;
pawn Code:
CMD:jail(playerid,params[])
{
if(!IsPlayerAdmin(playerid)) return 0;
new id,time,reason[100];
if(sscanf(params,"udS(No Reason)[100]",id,time,reason)) SendClientMessage(playerid, lb, "USAGE: /jail <playerid / Part of Name> <time> <reason>");// this is sscanf routine , d=integer and s= string
else if(id == INVALID_PLAYER_ID || !IsPlayerConnected(id)) SendClientMessage(playerid, red, "ERROR: Player is not connected.");// now we are checking if the targetid is online ! = not and id= targetid and if the id isnt on will send the message etc
else if(JailTimer[id] > -1) SendClientMessage(playerid, red, "ERROR: Player is already jailed.");// 1 jailed 0 is not jailed
else{
new szPlayerName[MAX_PLAYER_NAME + 1];
GetPlayerName(id, szPlayerName, MAX_PLAYER_NAME);// the jailed person id
SetPlayerInterior(id, 3);//sets player interior
SetPlayerVirtualWorld(id, 10);//sets player vw
SetPlayerPos(id, 197.5662, 175.4800, 1004.0);//player pos
SetPlayerFacingAngle(id, 360.0);//player angle
SetPlayerHealth(id, 9999999999.0);//player cannot be killed
ResetPlayerWeapons(id);//resets his weapons
JailTimer[id] = SetTimerEx("Unjail", time*60000, false, "i", id);//jail timer
format(szString, sizeof(szString), "AdmSys-: %s (ID:%d) has been jailed for %d minutes. Reason: %s", PlayerName, id, time, reason);
SendClientMessageToAll(color, szString);//%s = name . %d = number
}
return 1;
}
CMD:unjail(playerid,params[])
{
if(!IsPlayerAdmin(playerid)) return 0;
new id;
if(sscanf(params,"u",id)) SendClientMessage(playerid, lb, "USAGE: /unjail <playerid / Part of Name>"); //sscanf routine
else if(id == INVALID_PLAYER_ID || !IsPlayerConnected(id)) SendClientMessage(playerid, red, "ERROR: Player is not connected."); //checks if the targetid is connected
else if(JailTimer[id] < 0) SendClientMessage(playerid, red, "ERROR: Player is not jailed."); //checks if the id is jailed and if he isnt it will send an error.
else{
KillTimer(JailTimer[id]);//kills the timer
JailTimer[id] = -1;
SetPlayerInterior(id, 0);//normal int
SetPlayerVirtualWorld(id, 0);//normal vw
SetPlayerHealth(id, 100);//sets his health back as 100
SpawnPlayer(id);//respawns player
}
return 1;
}