array must be indexed (variable "playerip")
#1

Hey, i was trying to do so if the server get's my ip it would say ADMIN: %s joined.

but i get this error:
Код:
(105) : error 033: array must be indexed (variable "playerip")
This is my script:
Код:
public OnPlayerConnect(playerid)
{
	new playerip[16];
	GetPlayerIp(playerid,playerip,sizeof(playerip));
	if(playerip == [my ip])
	{
		new name[MAX_PLAYER_NAME],string[32];
		GetPlayerName(playerid,name,sizeof(name));
		format(string,sizeof(string),"ADMIN: %s joined",name);
		SendClientMessageToAll(COLOUR_LIGHTBLUE,string);
		PlayerPlaySound(playerid,1185,0,0,0);
		SendClientMessage(playerid,COLOUR_YELLOW,"Welcome admin!");
		return 1;
	}
	else
	{
		new name[MAX_PLAYER_NAME],string[32];
		GetPlayerName(playerid,name,sizeof(name));
		format(string,sizeof(string),"PLAYER: %s joined",name);
		SendClientMessageToAll(COLOUR_LIGHTBLUE,string);
		return 1;
}
}
Reply
#2

IP is a string, so use the strcmp function to compare your IP and the IP of the player who connects.

https://sampwiki.blast.hk/wiki/Strcmp
Reply
#3

Which line is 105?
And i can already see one thing wrong here :
Код:
if(playerip == [my ip])
You cannot compare strings / arrays using comparison operators such as == or !=, you need to use a function which will compare the two.
Код:
if(!strcmp(playerip, "your ip here"))
will compare playerip and your ip.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)