SA-MP Forums Archive
How do I fix this? - 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: How do I fix this? (/showthread.php?tid=83194)



How do I fix this? - Mike Garber - 23.06.2009

Ok,
This line:

Quote:

return 0;

Gives me

Quote:

error 010: invalid function or declaration

I can't see why It does that?
This Is the code I added recently:

Quote:

if(strcmp("/ban",cmdtext,true,4)==0)
if(PlayerInfo[playerid][pL1A] == 1) {
new id = strval(cmdtext[5]);
Ban(id);
printf("SERVER BAN: %d has been banned from the server",id);
SendClientMessageToAll(COLOR_WHITE, "----------------------------------------------------------------------------------------------------------");
SendClientMessageToAll(COLOR_GREEN, "SERVER ADMINISTRATION NOTICE");
SendClientMessageToAll(COLOR_WHITE, "%d have been banned from the server!");
SendClientMessageToAll(COLOR_WHITE, "----------------------------------------------------------------------------------------------------------");
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "SERVER: Unknown Command.");
}
return 1;
}
return 0;
}




Re: How do I fix this? - Grim_ - 23.06.2009

few errors there :P
pawn Код:
new cmd[256], idx;
cmd = strtok(cmdtext, idx);
if(strcmp(cmd, "/ban", true) == 0)
{
  if(PlayerInfo[playerid][PL1A] != 1) return SendClientMessage(playerid, color, "Not allowed to use this command!");
  new tmp[256];
  tmp = strtok(cmdtext, idx);
  if(!strlen(tmp)) return SendClientMessage(playerid, color, "Usage: /ban [id]");
  new targetid = strval(tmp);
  if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, color, "Invalid ID");
  new str[128], name[24];
  GetPlayerName(targetid, name, MAX_PLAYER_NAME);
  format(str, sizeof str, "%s has been banned by an administrator!", name);
  SendClientMessageToAll(color, "============================");
  SendClientMessageToAll(color, str);
  SendClientMessageToAll(color, "============================");
  return 1;
}
Something like this.
NOTE: Requires strtok, can be found here: https://sampwiki.blast.hk/wiki/strtok


Re: How do I fix this? - Mike Garber - 23.06.2009

It gives me this error, even though It IS defined :S
Thank you very much anyway
error 017: undefined symbol "PL1A"



Re: How do I fix this? - Grim_ - 23.06.2009

Show the code where you have it defined in the array please.



Re: How do I fix this? - Mike Garber - 23.06.2009

Well, I use other commands that works fine with it;

enum pInfo
{
pL1A,
};
new PlayerInfo[MAX_PLAYERS][pInfo];

If It's what you mean?


Re: How do I fix this? - Grim_ - 23.06.2009

In the command, un-capitalize the 'P'.