Makeadmin command - command unknown. -
Denying - 13.05.2014
Uh, before I start, I just wanted to say thanks for putting some of your time away to read this.
Alright, so, I am using ZCMD and sscanf, as you'll be able to see in a second.
I have the following command which I made by myself, of course..
Now, the thing is, it.. I'll just show you.
pawn Код:
CMD:makeadmin(playerid, params[])
{
new target, adminlevel, msg1[256], p;
GetPlayerName(playerid, pName, sizeof(pName));
if(!IsPlayerAdmin(playerid) && PlayerInfo[playerid][AdminLevel] < 6) return SendClientMessage(playerid, COLOR_ERROR, "Error: You are not authorized to use this command.");
if(sscanf(params, "ui", target, adminlevel))
{
SendClientMessage(playerid, COLOR_USAGE, "USAGE: {ABABAB}/makeadmin [playername/id] [adminlevel]");
SendClientMessage(playerid, COLOR_USAGE, "Available levels: {ABABAB}1 - Trial Admin, 2 - Basic Admin, 3 - Senior Admin.");
SendClientMessage(playerid, COLOR_USAGE, "Available levels: {ABABAB}4 - Lead Admin 5 - Head Admin, 6 - Co-owner, 7 - Owner.");
return 1;
}
if(!IsPlayerConnected(target)) return SendClientMessage(playerid, COLOR_ERROR, "Error: The selected player was not found, try again.");
if(adminlevel < 0 || adminlevel > 7) return SendClientMessage(playerid, COLOR_ERROR, "Error: Available admin levels are between 0 and 7.");
if(PlayerInfo[target][AdminLevel] == adminlevel) return SendClientMessage(playerid, COLOR_ERROR, "Error: The selected player is already an admin of that level.");
if(PlayerInfo[target][AdminLevel] > PlayerInfo[playerid][AdminLevel]) return SendClientMessage(playerid, COLOR_ERROR, "Error: The selected player is out of your limits.");
GetPlayerName(target, tName, sizeof(tName));
format(ppFile[target], sizeof(ppFile), "Accounts/%s.ini", tName);
dini_IntSet(ppFile[target], "AdminLevel", adminlevel);
PlayerInfo[target][AdminLevel] = adminlevel;
RPName(tName, '_');
RPName(pName, '_');
if(PlayerInfo[target][AdminLevel] == 0)
format(msg1, sizeof(msg1), "[ADMIN]{FC4800} %s is no longer an admin on the server.",pName, tName);
if(PlayerInfo[target][AdminLevel] == 1)
format(msg1, sizeof(msg1), "[ADMIN]{FC4800} %s has made %s a Trial Admin.",pName, tName);
if(PlayerInfo[target][AdminLevel] == 2)
format(msg1, sizeof(msg1), "[ADMIN]{FC4800} %s has made %s a Basic Admin.",pName, tName);
if(PlayerInfo[target][AdminLevel] == 3)
format(msg1, sizeof(msg1), "[ADMIN]{FC4800} %s has made %s a Senior Admin.",pName, tName);
if(PlayerInfo[target][AdminLevel] == 4)
format(msg1, sizeof(msg1), "[ADMIN]{FC4800} %s has made %s a Lead Admin.",pName, tName);
if(PlayerInfo[target][AdminLevel] == 5)
format(msg1, sizeof(msg1), "[ADMIN]{FC4800} %s has made %s a Head Admin.",pName, tName);
if(PlayerInfo[target][AdminLevel] == 6)
format(msg1, sizeof(msg1), "[ADMIN]{FC4800} %s has made %s a Co-owner.",pName, tName);
if(PlayerInfo[target][AdminLevel] == 7)
format(msg1, sizeof(msg1), "[ADMIN]{FC4800} %s has made %s a Owner.",pName, tName);
SendClientMessageToAll(COLOR_ADMIN, msg1);
return 1;
}
At the last line, there's "SendClientMessageToAll(COLOR_ADMIN, msg1);"
At first I wanted to send the message only to admins, so I used:
pawn Код:
new p;
for(p = 0; p < MAX_PLAYERS; p++)
{
if(PlayerInfo[p][AdminLevel] > 0 && IsPlayerConnected(p)) SendClientMessage(p, COLOR_ADMIN, msg1);
}
But it kept showing "Unknown command" after sending the message, which I didn't understand, I still don't.
So that's why I made this thread, anyone got an idea as to why it keeps sending "Unknown command" when I add the for loop? (I tried making a block with the for loop, same problem.. unknown command)
And a way to solve it would be nice.
Thank you in advance.
Btw, I didn't repeat the new p;
Re: Makeadmin command - command unknown. -
Konstantinos - 13.05.2014
Is the size of PlayerInfo array MAX_PLAYERS? If not and it's lower than its value, it will cause run time error 4 and it will display the unknown command message.
Re: Makeadmin command - command unknown. -
Scottas - 13.05.2014
Add crash detect plugin and see it should show you an error if something wrong. Can you confirm, that array 'PlayerInfo' has 'MAX_PLAYERS' cells?
Edit: too late, sorry
Re: Makeadmin command - command unknown. -
Andreas1331 - 13.05.2014
It needs to return 1;
All commands made with ZCMD needs to return something at all times.
Re: Makeadmin command - command unknown. -
Denying - 13.05.2014
Fixed, thank you all for your time.