Comparing saved IP with players IP
#1

Hey, guys well im trying to compare the save IP, and players IP so that if they are the same i could log the player in instantly. Well its not working as planned, for some reason have troubles. Even if saved IP is different it still would connect me..

pawn Код:
public OnAccountCheck(playerid)
{
    new rows, fields; //a variable that will be used to retrieve rows and fields in the database.
    new stringg[120];
    new pname[100];
    new query[255];
    new IP[16];
    new SSIP;
    GetPlayerIp(playerid, IP, sizeof(IP));
    GetPlayerName(playerid, pname, 24);
    cache_get_data(rows, fields, mysql);//let's get the rows and fields from the database.
    if(rows) //if there is row
    {//then
        cache_get_field_content(0, "Slaptazodis", Slaptazodis[playerid], mysql, 129);
        new TextStringas[128];
        format(TextStringas, sizeof(TextStringas), "{009900}[{99FF00}Admin{009900}]{FFFFFF} %s", IP[playerid]);
        SendPlayerMessageToAll(playerid, TextStringas);
        SetPVarInt(playerid, "AccID", cache_get_field_content_int(0, "ID"));
        SSIP = cache_get_field_content_int(0, "IP");
        if(IP[playerid] = SSIP)
        {
            format(TextStringas, sizeof(TextStringas), "{009900}[{99FF00}KURVA{009900}]{FFFFFF} %s", SSIP);
            SendPlayerMessageToAll(playerid, TextStringas);
                //HERE SHOULD LOG IN NORMALY, BUT IT GIVES ME THIS MESSAGE EVEN THOUGH I CHANGED THE IP IN THE DATABSE
            return 1;
        }
       
        format(stringg, sizeof(stringg), "{FFFFFF}Zaidejas {FFAF00}%s {FFFFFF}yra registruotas.\nIveskite slaptazodi noredami prisijungti:",pname);
        ShowPlayerDialog(playerid,LOG_Dialog,DIALOG_STYLE_PASSWORD,"{A3E4FF}Prisijungimas",stringg,"Prisijungti","Iseiti");
    }
    else //if we didn't find any rows from the database, that means, no accounts were found
    {
        format(stringg, sizeof(stringg), "{FFFFFF}Zaidejo {FFAF00}%s {FFFFFF}registracija.\nIveskite norima slaptazodi:",pname);
        ShowPlayerDialog(playerid,REG_Dialog,DIALOG_STYLE_PASSWORD,"{A3E4FF}Registracija",stringg,"Registruotis","Iseiti");
    }
    return 1;
}
Anybody know how to fix this?
Reply
#2

PHP код:
if(strcmp(FirstIPLastIPtrue) == 0


Reply
#3

no.,

using "==" are not the true way to compare two string.
use strcmp instead.
Reply
#4

Use:
PHP код:
if(strcmp(FirstIPLastIPtrue) == 0)
{
//here, if first ip and last ip are the same.

IP is not a number.
Reply
#5

Thank you guys, i fixed it!
Reply
#6

Quote:
Originally Posted by ******
Посмотреть сообщение
Why has this suddenly become a thing? I've seen three topics on this recently, not one of them realising that IPs can change and other people can get your IP. IPs are NOT a unique identifier and trying to use them as such will result in other people being logged in to your account.
A modem gets a new IP address if you restart it (DSL)

people are just not informed about this,
by the way since I have your attention could you quickly look at my thread "things to keep in mind, while coding!"
Reply
#7

Quote:
Originally Posted by Dotayuri
Посмотреть сообщение
A modem gets a new IP address if you restart it (DSL)

people are just not informed about this,
by the way since I have your attention could you quickly look at my thread "things to keep in mind, while coding!"
With my last ISP I had the same IP address since I came to them. Which is about 10 years or so.
Reply
#8

Quote:
Originally Posted by Dotayuri
Посмотреть сообщение
PHP код:
if(strcmp(FirstIPLastIPtrue) == 0


Plagiarism..
Reply
#9

Quote:
Originally Posted by ******
Посмотреть сообщение
That doesn't mean they are unique, that just adds to their variability since you can't guarantee that they will be the same and also can't guarantee that they will change.
The IP address is not unique? What are you talking about?

Yes, some ISPs have static IPs and some don't. You also cannot really hi-jack an IP address so you would have to be really lucky to get the IP address of someone else and know the username. That makes this login method safe enough.
Reply
#10

Quote:
Originally Posted by ******
Посмотреть сообщение
Relying on luck to make your code work is just BEGGING for trouble!
What can go wrong will go wrong it's simply a matter of time.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)