How do I fix this?
#1

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;
}

Reply
#2

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
Reply
#3

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

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

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

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

If It's what you mean?
Reply
#6

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


Forum Jump:


Users browsing this thread: 1 Guest(s)