Problem with name ban(anticheat)
#1

Hi, i have tried makeing a Anti cheat system, it worked fine but than i wanted to add a system that bans a name if it connect to my server.

i tried this code:
Код:
{
	new name[MAX_PLAYER_NAME];
	GetPlayerName(playerid,name,sizeof(name));
	if(name == "Test")
	{
	Ban(playerid);
	return 1;
	}
	return 1;
}
and it comes up with this error:

Код:
C:\Program Files\Rockstar Games\GTA San Andreas\sampserver\gamemodes\AntiCheat.pwn(70) : error 033: array must be indexed (variable "name")
Any1 who can help?

-Naxix
Reply
#2

You're close, but you cannot directly do an 'is array equal to string' conditional. You have to use the 'strcmp' function,

strcmp -- Remember, it returns 0 if the strings DO match

pawn Код:
if(strcmp(burger,"NOM NOM NOM"))==0)return SendClientMessage(playerid,0xFF0000FF,"I LYK TEH BURGR!!!");
Reply
#3

Sorry, i'm not the best scripter, but i did not know hwat u meant s:

Can u might explain it a bit more? (:
Reply
#4

{
new name[MAX_PLAYERS][MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
if(strcmp(name[playerid), "Test", 10, true) == 0)
{
Ban(playerid);
return 1;
}
return 1;
}
I think it should be like this.
Reply
#5

pawn Код:
{
  new name[MAX_PLAYER_NAME];
  GetPlayerName(playerid,name,sizeof(name));
  if(strcmp(name), "Test", true) == 0)
  {
  Ban(playerid);
  return 1;
  }
  return 1;
}
Reply
#6

Quote:
Originally Posted by lrZ^ aka LarzI
pawn Код:
{
 new name[MAX_PLAYER_NAME];
 GetPlayerName(playerid,name,sizeof(name));
 if(strcmp(name), "Test", true) == 0)
 {
 Ban(playerid);
 return 1;
 }
 return 1;
}
Код:
C:\Program Files\Rockstar Games\GTA San Andreas\sampserver\gamemodes\AntiCheat.pwn(70) : warning 202: number of arguments does not match definition
C:\Program Files\Rockstar Games\GTA San Andreas\sampserver\gamemodes\AntiCheat.pwn(70) : warning 206: redundant test: constant expression is non-zero
C:\Program Files\Rockstar Games\GTA San Andreas\sampserver\gamemodes\AntiCheat.pwn(70) : error 029: invalid expression, assumed zero
C:\Program Files\Rockstar Games\GTA San Andreas\sampserver\gamemodes\AntiCheat.pwn(70) : warning 215: expression has no effect
C:\Program Files\Rockstar Games\GTA San Andreas\sampserver\gamemodes\AntiCheat.pwn(70) : error 001: expected token: ";", but found ")"
C:\Program Files\Rockstar Games\GTA San Andreas\sampserver\gamemodes\AntiCheat.pwn(70) : error 029: invalid expression, assumed zero
C:\Program Files\Rockstar Games\GTA San Andreas\sampserver\gamemodes\AntiCheat.pwn(70) : fatal error 107: too many error messages on one line
i get those errors?
Reply
#7

oops, a little typ0 there :P

pawn Код:
{
  new name[MAX_PLAYER_NAME];
  GetPlayerName(playerid,name,sizeof(name));
  if(!strcmp(name, "Test"))
   Ban(playerid);
  return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)