28.07.2011, 17:30
A global boolean array to represent if player is jailed or not.
To avoid bugs with players being jailed when connecting (if player is assigned a playerid, which was earlier jailed, you'll reset it when the player joins)
When you jail the player, you set it to true and check if the the player is already jailed.
Also, at your 'GetPlayerName' you are getting the playerid's name (AKA: The player who uses the command).
Should be:
EDIT: Also don't forget to set IsJailed[playerid here] to 'false' when the player is unjailed (probably at your "jailtime")
pawn Код:
new bool:IsJailed[MAX_PLAYERS];
pawn Код:
public OnPlayerConnect(playerid)
{
IsJailed[playerid] = false;
}
pawn Код:
CMD:jail(playerid, params[])
{
if(IsPlayerAdmin2[playerid] == 2)
{
new targetid, Text:JailTextDraw, reason[128], msg[64], name[46];
if(sscanf(params, "us[128]", targetid, reason)) return SendClientMessage(playerid, COLOR_ORANGE, "USAGE: /jail [id] [reason]");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_WHITE, "That player is not online.");
if(IsJailed[targetid] == true) return SendClientMessage(playerid, COLOR_WHITE, "That player is already jailed.");
IsJailed[targetid] = true;
GetPlayerName(playerid, name, sizeof(name));
format(msg, sizeof(msg), "%s was jailed. Reason: %s. Time: 120sec.", name, reason);
SendClientMessageToAll(COLOR_RED, msg);
SetTimer("jailtime", 120000, false);
SetPlayerInterior(targetid, 6);
SetPlayerPos(targetid, 265.34756469727, 77.521759033203, 1001.0390625);
JailTextDraw = TextDrawCreate(327.000000, 377.000000, "X");
TextDrawAlignment(JailTextDraw, 2);
TextDrawBackgroundColor(JailTextDraw, 255);
TextDrawFont(JailTextDraw, 2);
TextDrawLetterSize(JailTextDraw, 0.620000, 3.200000);
TextDrawColor(JailTextDraw, -1);
TextDrawSetOutline(JailTextDraw, 0);
TextDrawSetProportional(JailTextDraw, 1);
TextDrawSetShadow(JailTextDraw, 1);
CountdownTextDraw(targetid, JailTextDraw, 120);
return 1;
}
return 1;
}
Should be:
pawn Код:
GetPlayerName(targetid, name, sizeof(name));