SA-MP Forums Archive
Mysql ip login - 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: Mysql ip login (/showthread.php?tid=295594)



Mysql ip login - TheBluec0de - 06.11.2011

Example to made auto ip login on mysql ?


Re: Mysql ip login - Pinguinn - 06.11.2011

You could try this

pawn Код:
new _ip[MAX_PLAYERS], ip[39];
GetPlayerIp(playerid, ip, sizeof(ip));
mysql_query("SELECT ip FROM `tablename` WHERE name = `%s`", name);
mysql_fetch_field_row(_ip[playerid], "ip");
if(_ip[playerid] == ip)
{
    // things here
}



Re: Mysql ip login - TheBluec0de - 06.11.2011

i put in "// things here"


Re: Mysql ip login - Pinguinn - 06.11.2011

No, you have to remove that line and do the thing you want to do when the player is automatic logged in


Re: Mysql ip login - Sascha - 06.11.2011

pinguinn's code is a bit incorrect
pawn Код:
new _ip[25], ip[25];
GetPlayerIp(playerid, ip, sizeof(ip));
mysql_query("SELECT ip FROM `tablename` WHERE `name` = '%s'", name);
mysql_fetch_field_row(_ip, "ip");
if(!strcmp(_ip, ip, true)



Re: Mysql ip login - TheBluec0de - 06.11.2011

OK, ... and for create a timer for save a stats ip.. when the player change ip..


Re: Mysql ip login - Sascha - 06.11.2011

just update the IP in the mysql db when a player logs in (not on auto-login ofc)...

So the next time he enters with the same IP as he had on his last login, he gets logged in automatically << the actual idea of auto-login..

So just add a
pawn Код:
new ip[25], string[200], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
GetPlayerIp(playerid, ip, sizeof(ip));
format(string, sizeof(string), "UPDATE `tablename` SET `ip`='%s' WHERE `name`='%s'", ip, name);
mysql_query(string);



Re: Mysql ip login - TheBluec0de - 06.11.2011

OK, ....