Код:
CMD:jail(playerid, params[])
{
if(pInfo[playerid][pLevel] >= 1)
{
new id, time = 0, reason[50];
if(isnull(params)) return SendClientMessage(playerid, yellow, "Usage: /Jail <Player ID> <Minutes> <Reason>");
sscanf(params, "uis[50]", id, time, reason);
if(IsPlayerConnected(id) && id != playerid)
{
if(pInfo[id][Jailed] == 1) return SendClientMessage(playerid,red,"This player is already jailed. see /jailed");
if(pInfo[playerid][pLevel] <= pInfo[id][pLevel]) return ShowMessage(playerid, red, 6);
if(!isnull(reason) && time == 0)
format(Jstring,sizeof(Jstring),"Administrator %s has jailed player '%s' | Reason: %s",GetName(playerid),GetName(id),reason);
else if(!isnull(reason) && time >= 1) format(Jstring,sizeof(Jstring),"Administrator %s has jailed '%s' for %d minutes (reason: %s)",GetName(playerid),GetName(id), time, reason);
else if(isnull(reason) && time >= 1) format(Jstring,sizeof(Jstring),"Administrator %s has jailed '%s' for %d minutes",GetName(playerid),GetName(id), time);
else format(Jstring,sizeof(Jstring),"Administrator %s has jailed '%s'",GetName(playerid),GetName(id));
CommandToAdmins(playerid,"jail");
SendClientMessageToAll(red,Jstring);
pInfo[id][Jailed] = 1;
TogglePlayerControllable(id, false);
new Float:x, Float:y, Float:z;
GetPlayerPos(id,x,y,z);
SetPlayerCameraPos(id,x+7,y,z+5);
SetPlayerCameraLookAt(id,x,y,z);
JPlayer[id] = SetTimerEx("JailPlayer",3000,0,"d",id);
if(GetPlayerState(id) == PLAYER_STATE_ONFOOT) SetPlayerSpecialAction(id,SPECIAL_ACTION_HANDSUP);
if(time >= 1)
{
Jtimer[id] = SetTimerEx("Unjail",time*1000*60,0,"u",id);
}
return 1;
}
else return ShowMessage(playerid, red, 3);
}
else return ShowMessage(playerid, red, 1);
}
CMD:unjail(playerid, params[])
{
if(pInfo[playerid][pLevel] >= 1)
{
new id, reason[50];
if(isnull(params)) return SendClientMessage(playerid, yellow, "Usage: /unjail <Player ID/Part of Name> <Reason>");
sscanf(params, "us[50]", id, reason);
if(IsPlayerConnected(id))
{
if(pInfo[id][Jailed] == 0) return SendClientMessage(playerid,red,"This player is not jailed!");
if(!isnull(reason))
format(Jstring,sizeof(Jstring),"You have been unjailed by admin '%s' | Reason: %s",GetName(playerid),reason);
else format(Jstring,sizeof(Jstring),"You have been unjailed by admin '%s'",GetName(playerid));
SendClientMessage(id,yellow,Jstring);
CommandToAdmins(playerid,"unjail");
format(Jstring,sizeof(Jstring),"You have unjailed '%s'",GetName(id));
SendClientMessage(playerid,yellow,Jstring);
pInfo[id][Jailed] = 0;
TogglePlayerControllable(id, true);
SpawnPlayer(id);
KillTimer(Jtimer[id]);
return 1;
}
else return ShowMessage(playerid, red, 2);
}
else return ShowMessage(playerid, red, 1);
}
CMD:jailed(playerid,params[])
{
if(pInfo[playerid][pLevel] >= 1)
{
new IsFrozen = 0;
strdel(JLstring,0,500);
foreach(Player, i)
{
if (pInfo[i][Jailed] == 1)
{
format(Jstring, 128, "%s(ID: %d)\n",GetName(i),i);
strcat(JLstring, Jstring, sizeof(JLstring));
IsFrozen++;
}
}
if (IsFrozen == 0)
ShowPlayerDialog(playerid,JDIALOGS+165,DIALOG_STYLE_MSGBOX,"{00FFE6}Jailed Players","{FF0000}No one is Jailed!" ,"OK","");
else
{
if(IsFrozen == 1) ShowPlayerDialog(playerid,JDIALOGS+165,DIALOG_STYLE_MSGBOX,"{00FFE6}1 player is Jailed",JLstring ,"OK","");
else format(Jstring, 128, "{00FFE6}%d players are Jailed",IsFrozen), ShowPlayerDialog(playerid,JDIALOGS+165,DIALOG_STYLE_MSGBOX,Jstring,JLstring ,"OK","");
}
strdel(JLstring,0,500);
return 1;
}
else return ShowMessage(playerid, red, 1);
}