If statement issues - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: If statement issues (
/showthread.php?tid=129993)
If statement issues -
Christopher. - 24.02.2010
OK so i have this if statement in OnPlayerCommandText in my FS.
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(PlayerInfo[playerid][Jailed] == 1) return SendClientMessage(playerid, AdministrationError, "Error: You cannot use a command when you are jailed.");
return 0;
}
And this is the Jail CMD:
Код:
COMMAND:jail(playerid, params[])
{
new string[128];
new JailedPlayer[MAX_PLAYER_NAME];
new AdministratorName[MAX_PLAYER_NAME];
new id, Reason[128];
if (PlayerInfo[playerid][Level] > 1)
{
if (sscanf(params, "uz", id, Reason)) SendClientMessage(playerid, 0xFF0000AA, "Usage: /jail [PlayerID] [Reason]");
else if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "Player not found");
else
{
GetPlayerName(id, JailedPlayer, sizeof(JailedPlayer));
GetPlayerName(playerid, AdministratorName, sizeof(AdministratorName));
format(string, sizeof(string), "%s was jailed by Administrator %s. [Reason: %s ]", JailedPlayer, AdministratorName, Reason);
SendClientMessage(playerid, AdministrationHelp, "[Help] To unjail the specified player type /unjail [PlayerID].");
SetPlayerPos(id, 199.3792, 173.4266, 1003.0234);
TogglePlayerControllable(id, 1);
PlayerInfo[id][Jailed] = 1;
SetPlayerInterior(id, 3);
SendClientMessageToAll(AdministrationAnnouncement, string);
LogCommand(string);
}
}
else
{
SendClientMessage(playerid, AdministrationError, NotAdminError);
}
return 1;
}
And my issue is, Once there jailed its not stopping them from using commands, i set the "PlayerInfo[id][Jailed] = 1;" to one and yet OnPlayerCommandText is still returning allowing the player to use a command, I am really stumped here, I'm not sure what to do, It should return that SendClientMessage when "PlayerInfo[id][Jailed] = 1" but yet it doesn't?, Thanks Chris.
Re: If statement issues -
[HiC]TheKiller - 24.02.2010
Try putting
pawn Код:
if(PlayerInfo[playerid][Jailed] == 1) return SendClientMessage(playerid, AdministrationError, "Error: You cannot use a command when you are jailed.");
At the top of OnPlayerCommandText so it's called first.