29.09.2012, 13:24
Hello,
i'll add on MySQL the IP from any Player when he connects the server.
This is under OnPlayerConnect
MySQL Info:
It doesn't save my ip when i join the server. There are not any Errors & Warnings on Pawn
i'll add on MySQL the IP from any Player when he connects the server.
This is under OnPlayerConnect
PHP код:
// Aliases
new query[130 + MAX_PLAYER_NAME];
format(query, sizeof(query), "SELECT * FROM aliases WHERE username = '%s'", PlayerName(playerid));
new result = mysql_query(query);
if(mysql_num_rows(result) == 0)
{
new aquery[130 + MAX_PLAYER_NAME];
format(aquery, sizeof(aquery), "INSERT INTO aliases (username, ip) VALUES ('%s', '%s')", PlayerName(playerid), PlayerIP(playerid));
mysql_query(aquery);
} else {
new aquery[130 + MAX_PLAYER_NAME];
format(aquery, sizeof(aquery), "UPDATE aliases SET username = '%s', ip = '%s'", PlayerName(playerid), PlayerIP(playerid));
mysql_query(aquery);
}
PHP код:
id int(11) Nein kein(e) AUTO_INCREMENT
username varchar(40) latin1_swedish_ci Nein kein(e)
ip varchar(40) latin1_swedish_ci Nein kein(e)
PHP код:
stock PlayerName(playerid)
{
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
return pName;
}
stock PlayerIP(playerid)
{
new pIP[26];
GetPlayerIp(playerid, pIP, sizeof(pIP));
return pIP;
}