21.04.2011, 19:05
Is there a good way to save a player's IP Address when creating an account? I'm using a Dini register system by the way.
Thanks for the help!
Thanks for the help!
new ip[12], file[64], name[24];
GetPlayerIp(playerid, ip, sizeof(ip));
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), "%s.ini", udb_encode(name));
if(!dini_Exists(file)) dini_Create(file);
dini_Set(file, "ip", ip);
new ip[12], file[64], name[24];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), "%s.ini", udb_encode(name));
if(dini_Exists(file))
{
strcpy(ip, dini_Get(file, "ip", ip));
}
To set:
PHP код:
PHP код:
|
new pIP[16]; // Global variable
public OnPlayerConnect(playerid)
{
GetPlayerIp(playerid, pIP, sizeof (pIP));
SetPVarString(playerid, "IP", pIP, sizeof (pIP));
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new ip[16];
GetPVarString(playerid), "IP", ip, sizeof (ip)
printf("playerid %d disconnected, and his IP was %s", playerid, ip);
return 1;
}
I'm more than sure he's saving the IP in OnPlayerDisconnect. A solution to this bug is to save the IP upon player connecting.
pawn Код:
|
public OnPlayerDisconnect(playerid, reason)
{
new __ip[16];
GetPVarString(playerid, "IP" __ip, sizeof(__ip));
printf("playerid %d disconnected, and his IP was %s", playerid, __ip);
return 1;
}