Previous IP saving
#1

Hey.

Im trying to save the IP a player connects from to the database, this i have done with succes.
However if the IP differs from the IP a player last connected from i would like to save it in the database too.

As of now i have the following function
Код:
        new plrIP[16];
    	GetPlayerIp(playerid, plrIP, sizeof(plrIP));
    	if(pData[playerid][IP] != plrIP)
    	{
    		//Update PIP Previous IP Adress
    	}
        return 1;
}
So basically if a player connects the IP field gets updated, but if it differs from normal(connection from a new IP)
I would like to get the IP data, and put that to the PIP field, and update the IP field with the new ip.
Does that sound doable?
If it is how would i be doing this?
Reply
#2

Isn't it easier to just update the IP as they connect, instead of checking if ip != ip? What do you intend on using this for?
Reply
#3

well, i only want to update the 'ip' field if it changes, and now it's updating on each time a player connects.
Lets say for example i connect using ip 127.0.0.1 now, it would update the 'ip' field and set it to 127.0.0.1
But i changed my ip, and i am connecting using 192.168.1.10 i want to update the `ip` field, and take the data in the `ip` field and put that into the `pip` field.

So if someone claims a different IP has accessed their account i can simply check.
Is this a good way or am i talking trash now?
Reply
#4

Most people have DHCP, so their IP can change at any moment based on needs/rules from their ISP.
So your player can also have a different IP every time he logs in, so just having 2 fields would be a bit limited.

You can also make a separate table and add a new entry every time they connect.
You could save the player's ID, login-time and IP at that time.
Then you can track all the IP addresses he ever used and you even see when he used which IP and when he connected to your server.
It will also be very easy to see if his IP is suddenly completely different (other country for example), that could easily be used as evidence that his account has been hacked by someone else.

Then you don't need to check if IP's have changed and update one or both fields based on the check.

I have an auto-login system on my script, which uses the last used IP.
You can always update that IP in his account everytime he connects too, but load it first.
Then you can compare that last IP with the current IP and if they're the same, login the player without the need to enter a password.
Reply
#5

Код:
new plrIP[MAX_PLAYERS][20];

// save stats
format(query,sizeof(query),"UPDATE `players` SET `ip`='%s'",plrIP[playerid]);

// load stats
GetPlayerIp(playerid, plrIP[playerid], 20);

Note: IP is a varchar. so, set your field to be varchar 20.
Reply
#6

Код:
new plrIP[MAX_PLAYERS][20];
max size of an ip is 16 right lol
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)