If statement errors? Confused.. - 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)
+--- Thread: If statement errors? Confused.. (
/showthread.php?tid=457629)
If statement errors? Confused.. -
Jamcraftadam - 12.08.2013
Hello, I am trying to make a /kick command, but I get 4 errors.. Heres the code and errors..
Код:
CMD:kick(playerid,params[])
{
new id,reason[128],name[MAX_PLAYER_NAME];
if(PlayerInfo[playerid][Adminlevel] > 5) //this is also taken from the tut by Kush
{
if(sscanf(params,"us[128]",id,reason); return //your error message
else
{
format(string1,sizeof(string1),"%s have been kicked from the server: reason: %s",GetPlayerName(id,name,sizeof(name)),reason); //this will format the kick message that is being sent to all player connected
SendClientMessageToAll(0xFFFFFF,string1);
Kick(id);//kicks the player
}
}
else
{
//your error message about that the player is not a admin
}
}
Errors:
Код:
G:\Roleplay Server\gamemodes\rp.pwn(1033) : error 028: invalid subscript (not an array or too many subscripts): "PlayerInfo"
G:\Roleplay Server\gamemodes\rp.pwn(1033) : warning 215: expression has no effect
G:\Roleplay Server\gamemodes\rp.pwn(1033) : error 001: expected token: ";", but found "]"
G:\Roleplay Server\gamemodes\rp.pwn(1033) : error 029: invalid expression, assumed zero
G:\Roleplay Server\gamemodes\rp.pwn(1033) : fatal error 107: too many error messages on one line
Re: If statement errors? Confused.. -
GWMPT - 12.08.2013
.......
pawn Код:
CMD:kick(playerid,params[])
{
new id,reason[128],name[MAX_PLAYER_NAME];
if(PlayerInfo[playerid][Adminlevel] > 5) { //this is also taken from the tut by Kush
if(sscanf(params,"us[128]",id,reason)) {
return sendClientMessage(playerid, -1, "Usage: /kick <playerid>");
} else {
format(string1,sizeof(string1),"%s have been kicked from the server: reason: %s",GetPlayerName(id,name,sizeof(name)),reason); //this will format the kick message that is being sent to all player connected
SendClientMessageToAll(0xFFFFFF,string1);
Kick(id);//kicks the player
}
} else {
//your error message about that the player is not a admin
}
}
So, instead of writing if(sscanf(params, "us[128]", id, reason)) { return xxxxx; }
no, you're writing if(sscanf(params, "us[128]", id, reason);
Indeed.
Re: If statement errors? Confused.. -
Jamcraftadam - 12.08.2013
Same errors on line 1033 = if(PlayerInfo[playerid][Adminlevel] > 5) { //this is also taken from the tut by Kush
Re: If statement errors? Confused.. -
Pupak - 12.08.2013
You don't have that enumeration in your script. You can use if(IsPlayerAdmin(playerid)) instead, but then you'll only be able to use the command as RCON administrator.