Autologin MySql
#1

Can someone help me with making an autologin? I'm using MySql and currently saving the IP of the player at the register part.

Any help? Thanks.
Reply
#2

Why don't you save the IP when the person logs in, instead of when the person registers?

Person logs in with IP 11.22.33.44. IP 11.22.33.44 is saved in database bound to their user id or whatever.
Person disconnects, comes back the next day. Get their IP and if it matches up to the saved IP (in this case "11.22.33.44"), log them in automatically.
If person's IP is different (e.g. now it's 22.33.44.55), it saves, and they will have to login manually.
If person reconnects and their IP is still 22.33.44.55, automatic login again.

You can use the function GetPlayerIp.
Reply
#3

Ok i made it save when the player logs in, now how i can make the autlogin code? Any tip?
Reply
#4

I could be wrong, but try this:

Код:
new ip[16];
GetPlayerIp(playerid, ip, sizeof(ip));

if (!strcmp([variable for person's IP], ip, true))
{
	//auto login code here
}
Example of "Variable for person's IP":

Код:
new ip[16];
GetPlayerIp(playerid, ip, sizeof(ip));

if (!strcmp(PlayerInfo[playerid][pIPAddress], ip, true))
{
	//auto login code here
}
Also, just noticed this (very recent!) thread exists, which may be useful: https://sampforum.blast.hk/showthread.php?tid=589891
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)