[INFO]Ip different
#1

how to: if the ip is different, upload into the database, if it is not different not upload to the database.

i use mysql plugin BlueG R6.
Reply
#2

You simply need to upload your .SQL file to your PHPMYADMIN, and then update the server MySQL configuration accordingly.
Reply
#3

no, you do not understand, I already did, I asked for an example of a script
Reply
#4

What do you mean an example..?
Reply
#5

Quote:
Originally Posted by Syntax
Посмотреть сообщение
What do you mean an example..?
Код:
how to: if the ip is different, upload into the database, if it is not different not upload to the database.

i use mysql plugin BlueG R6.
Reply
#6

Quote:
Originally Posted by [HLF]Southclaw
Посмотреть сообщение
Wow, I only learnt SQL like a few days ago and I understand him!

You need to query the database IP, check it against the player IP using "strcmp" (If you save them as strings, which I would expect as GetPlayerIp saves it in string form)
If it doesn't match then update the database using the UPDATE query function.

I trust you know how to retrieve data and update using MySQL already.
example ?

if(!strcmp(_ip, ip, true)..... ?
Reply
#7

just do like:
pawn Код:
new ip[20], pname[60], query[100];
GetPlayerIp(playerid, ip, sizeof(ip));
GetPlayerName(playerid, name, sizeof(name));
format(query, sizeof(query), "SELECT * FROM <table name> WHERE username = '%s' AND ip = '%s'", pname, ip);
mysql_query(query);
if(mysql_num_rows() == 1)
{
    SendClientMessage(playerid, -1, "Your ip is the same!");
}
else {
    new update[100];
    format(update, sizeof(update), "UPDATE <table name> SET ip = '%s' WHERE username = '%s'", ip, pname);
    SendClientMessage(playerid, -1, "Your ip is different!");
}
Warning, this is just a simple code.
Reply
#8

Quote:
Originally Posted by [HLF]Southclaw
Посмотреть сообщение
The 'true' is not needed there, neither is the '!'.
If you look at the strcmp documentation on the wiki, that param you have set true is the 'ignore case' param, since an IP is numbers and dots, this isn't needed.

The exclamation means NOT when in front of a condition, strcmp returns false when a match is found and true otherwise, so you want to update the database if strcmp returns true:

pawn Код:
if(strcmp(tmpIP, tmpField))
{
   // MySQL query UPDATE...
}
tmpIP being the present IP of the player, retrieved using GetPlayerIp.
tmpField would be the MySQL field returned from your query.


Hope that helped
so, code exactly is that ?

PHP код:
new
    
tmpField[16], tmpIP[16];
mysql_fetch_field_row(tmpFieldsizeof(tmpField));
GetPlayerIp(playeridtmpIPsizeof(tmpIP));
                    
if(
strcmp(tmpIPtmpField))
{
    
format(querysizeof(query), "UPDATE `%s` SET `Last_IP` = '%s' WHERE `Name` = '%s'"TABLE_NAMEip(playerid), name(playerid));
    
mysql_query(query);
    return 
1;

Reply
#9

Quote:
Originally Posted by [HLF]Southclaw
Посмотреть сообщение
Yes exactly! Although I'm not sure if this is faster than the other code posted by kikito.

And I'm sure the bump time is 48 hours, not 24 (I got told by an admin on one of my release threads!)
OK, and this... if the ip is different, upload into the database... correct ?
Reply
#10

Quote:

And I'm sure the bump time is 48 hours, not 24 (I got told by an admin on one of my release threads!)

haa, im outdated of the rules, need to read them again -___-
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)