15.08.2010, 03:34
Give this a try:
pawn Код:
if(!strcmp(cmd, "/jail", true, 5) // Jails a player
{
if(adminlevel[playerid] < 2) return SendClientMessage(playerid, RED, "You are not an admin with the required level.");
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, ORANGE, "USAGE: /jail [name/id] [reason]");
new targetid = ReturnUser(tmp);
if(targetid == INVALID_PLAYER_ID)
{
format(string, sizeof(string), "%d is not an active player.", targetid);
return SendClientMessage(playerid, RED, string);
}
else if(jail[giveplayerid] == 1) return SendClientMessage(playerid, RED, "Player is already jailed!");
else
{
GetPlayerName(targetid, giveplayername, sizeof(giveplayername));
GetPlayerName(playerid, sendername, sizeof(sendername));
new reason[128];
reason = bigstrtok(cmdtext, idx);
if(!strlen(reason)) return SendClientMessage(playerid, ORANGE, "USAGE: /jail [name/id] [reason]");
format(string, sizeof(string), "You got jailed by Admin %s. Reason: %s", sendername, reason);
SendClientMessage(targetid, ADMIN_RED, string);
format(string, sizeof(string), "Administrator %s jailed %s. [ Reason: %s ]",sendername,giveplayername, reason);
SendClientMessageToAll(ADMIN_RED,string);
jail[targetid] = 1;
OnPlayerJailed(targetid);
}
return 1;
}
if(!strcmp(cmd, "/unjail", true, 7)) // Unjails a player
{
if(adminlevel[playerid] < 2) return SendClientMessage(playerid, RED, "You cannot use this command!");
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
return SendClientMessage(playerid, ORANGE, "USAGE: /unjail [name/id]");
}
new targetid = ReturnUser(tmp);
if(targetid == INVALID_PLAYER_ID)
{
format(string, sizeof(string), "%d is not an active player.", targetid);
return SendClientMessage(playerid, RED, string);
}
else if(jail[giveplayerid] == 0) return SendClientMessage(playerid, RED, "Player is not jailed!");
else
{
GetPlayerName(targetid, giveplayername, sizeof(giveplayername));
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "Administrator %s unjailed %s",sendername, giveplayername);
SendClientMessageToAll(ADMIN_RED, string);
jail[targetid] = 0;
OnPlayerUnjailed(targetid);
}
return 1;
}