Why is this happening ? - 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: Why is this happening ? (
/showthread.php?tid=511939)
Why is this happening ? -
Johnson_Brooks - 08.05.2014
So yesterday i asked for an /admin [question] command and a /reply [id] [response] command.
/Reply is working fine but the /admin command is giving me errors
CODE:
pawn Код:
CMD:admin(playerid, params[])
{
new string[128];
new sName[MAX_PLAYER_NAME];
if(sscanf(params, "s", string)) return SendClientMessage(playerid, -1, "Usage /admin [question]");
GetPlayerName(playerid, sName, sizeof(sName));
new Message[128];
format(Message, sizeof(Message), "QUESTION from %s: %s", sName, string);
for(new i; i < MAX_PLAYERS; i++){
if(PlayerINFO[i][AdminLevel] >= 1 {
SendClientMessage(i, -1, Message);
}
}
return 1;
}
ERROR:
Код:
(855) : error 029: invalid expression, assumed zero
855 line is : if(PlayerINFO[i][AdminLevel] >=1 {
Re: Why is this happening ? -
Ada32 - 08.05.2014
this line
Код:
if(PlayerINFO[i][AdminLevel] >= 1) {
Re: Why is this happening ? -
Konstantinos - 08.05.2014
You forgot to close the if statement. It should be:
pawn Код:
if(PlayerINFO[i][AdminLevel] >=1) {
Also using "s" specifier without a length will give a warning to the console. But since it's not necessary to use sscanf when there is only 1 parameter and that's string, you can just do:
pawn Код:
CMD:admin(playerid, params[])
{
if(isnull(params)) return SendClientMessage(playerid, -1, "Usage /admin [question]");
new Message[144], sName[MAX_PLAYER_NAME];
GetPlayerName(playerid, sName, sizeof(sName));
format(Message, sizeof(Message), "QUESTION from %s: %s", sName, params);
for(new i; i < MAX_PLAYERS; i++){
if(PlayerINFO[i][AdminLevel] >= 1) {
SendClientMessage(i, -1, Message);
}
}
return 1;
}
Re: Why is this happening ? -
Johnson_Brooks - 08.05.2014
Quote:
Originally Posted by Konstantinos
You forgot to close the if statement. It should be:
pawn Код:
if(PlayerINFO[i][AdminLevel] >=1) {
Also using "s" specifier without a length will give a warning to the console. But since it's not necessary to use sscanf when there is only 1 parameter and that's string, you can just do:
pawn Код:
CMD:admin(playerid, params[]) { if(isnull(params)) return SendClientMessage(playerid, -1, "Usage /admin [question]"); new Message[144], sName[MAX_PLAYER_NAME]; GetPlayerName(playerid, sName, sizeof(sName)); format(Message, sizeof(Message), "QUESTION from %s: %s", sName, params); for(new i; i < MAX_PLAYERS; i++){ if(PlayerINFO[i][AdminLevel] >= 1) { SendClientMessage(i, -1, Message); } } return 1; }
|
Thanks , rep+ . Are you greek ?