SA-MP Forums Archive
Strcmp not working - 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: Strcmp not working (/showthread.php?tid=69735)



Strcmp not working - Robbin237 - 20.03.2009

The problem is, im ID 0, i join, im fine. It says no difference, and ips are the same (127.0.0.1) and in the ini file too (127.0.0.1). Now my friend joins and it says DIFFERENCE FOUND, while the IP of my friend and the ip in the ini are exactly the same. And he gets banned. Please help me?

Код:
dcmd_actest(playerid, params[])
{
	new string[128];
  new Name[MAX_PLAYER_NAME+1];

  GetPlayerName(playerid, Name, sizeof(Name));
	GetPlayerIp(playerid, PlayerIP[playerid], sizeof(PlayerIP));

	if(!strcmp(Name, "Eros"))
	{
	  printf("Player IP: %s --- Original IP: %s", PlayerIP[playerid], dini_Get("Players.ini", "ErosIP"));

		if(strcmp(PlayerIP, dini_Get("Players.ini", "ErosIP")))
		{
			format(string, sizeof(string), "***BAN: %s (%d) (INVALID NICK) Fake Admin!", Name, playerid);
 			SendClientMessageToAll(COLOR_PINK, string);
		}
	}

	else if(!strcmp(Name, "Decysen"))
	{
	  printf("Player IP: %s --- Original IP: %s", PlayerIP[playerid], dini_Get("Players.ini", "DecysenIP"));
		
		if(strcmp(PlayerIP, dini_Get("Players.ini", "DecysenIP")))
		{
			format(string, sizeof(string), "***BAN: %s (%d) (INVALID NICK) Fake Admin!", Name, playerid);
 			SendClientMessageToAll(COLOR_PINK, string);
		}
	}
	
	return 1;
}



Re: Strcmp not working - Robbin237 - 22.03.2009

*BUMP*


Re: Strcmp not working - tom_jonez - 23.03.2009

make sure:
new PlayerIP[MAX_PLAYERS];

is actually:
new PlayerIP[MAX_PLAYERS][];

because the ip is actually a string, not just 1 integer.
PlayerIP[MAX_PLAYERS][] =
{
{"192.168.0.1"},//id 1
{"192.168.0.2"} // id 2
};

just a thought, might, might not work


Re: Strcmp not working - Pghpunkid - 23.03.2009

Check strcmp's parameters.. i think your missing some.

Also try seeing if they are 0. like..

pawn Код:
if(strcmp(Name, "Eros") == 0)



Re: Strcmp not working - Robbin237 - 28.04.2009

Sorry for the late bump, but still cannot get it to work..

Thnx


Re: Strcmp not working - MenaceX^ - 28.04.2009

pawn Код:
if(!strcmp(Name,"/command",1))



Re: Strcmp not working - Djiango - 28.04.2009

pawn Код:
if(strcmp("Eros", Name, true) == 0)