Basic command.. probabbly blinding obvious error - 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: Basic command.. probabbly blinding obvious error (
/showthread.php?tid=69650)
Basic command.. probabbly blinding obvious error -
Acoole - 19.03.2009
The command:
Код:
if (strcmp("/admins", cmdtext, true, 10) == 0)
{
new string[256];
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(Level[i] == 1)
{
GetPlayerName(i, sendername, sizeof(sendername));
format(string, 256, "Administrator: %s",sendername);
SendClientMessage(playerid, COLOR_WHITE, string);
}
}
}
}
The aim of the command: To display all online administrators
The issue: Compiles, but the command just says SERVER: Unknown Command, also, the server executable spits out this warning: SCRIPT: Bad parameter count (Count is 8, Should be 4)
SCRIPT: Bad parameter count (Count is 8, Should be 4)
I'm sure the issue here is blindingly obviously, any help is appreciated.
Regards,
~Aim
Re: Basic command.. probabbly blinding obvious error -
Nero_3D - 19.03.2009
to solve the Unknown Command just add a return true
pawn Код:
if (strcmp("/admins", cmdtext, true) == 0)
{
new string[128]; //Tip: read the topic about string length by ******
for(new i; i < MAX_PLAYERS; i++) //you dont need to declare i as 0 because all values in pawn are at creating 0
{
if(IsPlayerConnected(i))
{
if(Level[i] == 1)
{
if(!string[0]) SendClientMessage(playerid, COLOR_WHITE, "========== Admins Online ==========");
GetPlayerName(i, string, MAX_PLAYER_NAME);
format(string, sizeof string, "Administrator: %s", string);
SendClientMessage(playerid, COLOR_WHITE, string);
}
}
}
return true; //if you return false (that happens when you dont put a return at the end of a command) the text Unknown Command will appear
}