SA-MP Forums Archive
Problem with name ban(anticheat) - 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: Problem with name ban(anticheat) (/showthread.php?tid=109966)



Problem with name ban(anticheat) - Naxix - 23.11.2009

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


Re: Problem with name ban(anticheat) - Joe Staff - 23.11.2009

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!!!");



Re: Problem with name ban(anticheat) - Naxix - 23.11.2009

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

Can u might explain it a bit more? (:


Re: Problem with name ban(anticheat) - Butilka - 23.11.2009

{
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.


Re: Problem with name ban(anticheat) - LarzI - 23.11.2009

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



Re: Problem with name ban(anticheat) - Naxix - 23.11.2009

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?


Re: Problem with name ban(anticheat) - LarzI - 23.11.2009

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