MySQL IP not saving correctly
#1

....
Reply
#2

ip = '%d'
Reply
#3

....
Reply
#4

Use GetPlayerIp(playerid, ip, 50); Directly
Reply
#5

....
Reply
#6

Quote:
Originally Posted by Ryan_Bowe
View Post
Did not work, saved as the number 50.

Yes it will not work because it isn't numbers only and IP is a string ( char + numbers)
Reply
#7

....
Reply
#8

Quote:
Originally Posted by Ryan_Bowe
View Post
Still the same 255.255.255.255.
pawn Code:
stock MySQL_Save(playerid) {
    GetPlayerIp(playerid, PlayerData[playerid][pIP], 50);
    new query[3000];
    format(query, sizeof(query), "UPDATE `playerdata` SET ip = '%s', adminlevel = '%d' WHERE username = '%s'",
    GetPlayerIp(playerid,pIP,32),
    PlayerData[playerid][pAdminLevel],
    GetPlayerNameEx(playerid));
    mysql_query(query);
    return 1;
}
Reply
#9

How did you insert the ip in your database ? if you insert it as 'int' change to `ip` varchar(16) NOT NULL

@ Originally Posted by [HRD]Mar1 View Post
Use GetPlayerIp(playerid, ip, 50); Directly

No that's wrong the ip can't exceed 16 letters. https://sampwiki.blast.hk/wiki/GetPlayerIp

EDIT:
pawn Code:
stock MySQL_Save(playerid) {
    new query[200],pIP[16];//query size too much and you check for small variables.
    format(query, sizeof(query), "UPDATE `playerdata` SET ip = '%s', adminlevel = '%d' WHERE username = '%s'",
    GetPlayerIp(playerid,pIP,16),
    PlayerData[playerid][pAdminLevel],
    GetPlayerNameEx(playerid));
    mysql_query(query);
    return 1;
}
Reply
#10

Do not save IP, when he is disconnecting. If the player connect, save the IP.
Reply
#11

pawn Code:
public OnPlayerConnect(playerid)
{
        GetPlayerIp(playerid, pInfo[playerid][pIP], 16);
}
Then save it.

pawn Code:
stock MySQL_Save(playerid)
{    
new query[3000];    format(query, sizeof(query), "UPDATE `playerdata` SET ip = '%s', adminlevel = '%d' WHERE username = '%s'",  
pInfo[playerid][pIP],
PlayerData[playerid][pAdminLevel],    
GetPlayerNameEx(playerid));    
mysql_query(query);  
 return 1;
}
Make sure you define the IP Variable.

EDIT:

Why is your query 3000?
Reply
#12

Quote:
Originally Posted by SilentSoul
View Post
@ Originally Posted by [HRD]Mar1 View Post
Use GetPlayerIp(playerid, ip, 50); Directly

No that's wrong the ip can't exceed 16 letters. https://sampwiki.blast.hk/wiki/GetPlayerIp
Not wrong (Recommended 16)...
Reply
#13

But why you used to check for 50 , i think no ip can exceed the '16'. no ip like this 23.23.123.124.124.213.21.323.1.321.3.123.12312.32 only in range of 16.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)