SA-MP Forums Archive
Error 076 - 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)
+--- Thread: Error 076 (/showthread.php?tid=451114)



Error 076 - Calvingreen17 - 15.07.2013

Код:
C:\Users\di$t0rt3d_p1ctur3\Saved Games\GTA San Andreas\Server\gamemodes\coolbeans.pwn(457) : error 076: syntax error in the expression, or invalid function call
This his the code that contains 457:

Код:
//SendIPToAdmins
	new string[128],plyrname[MAX_PLAYER_NAME];
	GetPlayerName(playerid,plyrname,sizeof(plyrname));
	format(string,sizeof(string),"[ADM]%s connected with IP %d",plyrname,pIP);
	SendMessageToAdmins(0xFFFFFFAA,string);
    return 1;
}



Re: Error 076 - ScRipTeRi - 16.07.2013

pawn Код:
//SendIPToAdmins
    new ip[999];
    new string[99];
    GetPlayerName(playerid,name,sizeof(name));
    GetPlayerIp(playerid,ip,sizeof(ip));
    format(string, 150, "[ADM]%s connected with IP %d.", name, ip);
    SendMessageToAdmins(0xFFFFFFAA,string);



Re: Error 076 - Zex Tan - 16.07.2013

Quote:
Originally Posted by ScRipTeRi
Посмотреть сообщение
pawn Код:
//SendIPToAdmins
    new ip[999];
    new string[99];
    GetPlayerName(playerid,name,sizeof(name));
    GetPlayerIp(playerid,ip,sizeof(ip));
    format(string, 150, "[ADM]%s connected with IP %d.", name, ip);
    SendMessageToAdmins(0xFFFFFFAA,string);
This won't work out well, you shouldn't use %d as the IP. IP is a string also ip[999] is a waste of memory.

Try this,

pawn Код:
//SendIPToAdmins
    new string[60],pname[MAX_PLAYER_NAME+1], pIP[16];
    GetPlayerName(playerid, pname, sizeof(pname));
    GetPlayerIp(playerid, pIP, sizeof(pIP));
    format(string,sizeof(string),"[ADM]%s connected with IP %s",pname,pIP);
    SendMessageToAdmins(0xFFFFFFAA,string);
    return 1;
}
Well, I'm not sure about your string size, if you want to change it go ahead.


Re: Error 076 - Calvingreen17 - 16.07.2013

Well for starters I already have a stock for pIP:

Код:
stock pIP(playerid)
{
    new pIP[16];
    GetPlayerIP(playerid,pIP,sizeof(pIP));
    return pIP;
}
It also still returns that 1 error. The error comes strictly from this line:

Код:
format(string,sizeof(string),"[ADM]%s connected with IP %s",pname,pIP);
Also I cant use pname cause i get error "already defined"


Re: Error 076 - JimmyCh - 16.07.2013

Use this without the stock:
pawn Код:
new string[60],Name[MAX_PLAYER_NAME+1], pIP[16];
GetPlayerName(playerid, Name, sizeof(Name));
GetPlayerIp(playerid, pIP, sizeof(pIP));
format(string,sizeof(string),"[ADM]%s connected with IP %s",Name,pIP);
SendMessageToAdmins(0xFFFFFFAA,string);
return 1;



Re: Error 076 - Calvingreen17 - 16.07.2013

Thanks Jimmy and Zex Tan. I will rep you both