SA-MP Forums Archive
Dini help? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Dini help? (/showthread.php?tid=443560)



Dini help? - Affan - 12.06.2013

Help?

pawn Код:
if(fexist(file))
        {
                GetPlayerIp(playerid, ip, sizeof(ip));
                tmp = dini_Int(file, "IP");
            if(strval(tmp) != strval(IP))  
            {
                SendClientMessage(playerid, COLOR_YELLOW, "That nick is registered. Please change name or /login");
            }
            else
            {
                gPlayerLogged[playerid] = 1;
                SendClientMessage(playerid, COLOR_WHITE, "You have been automatically logged in.");
            }
        }
Error:
pawn Код:
X:\XXX\XXX\XXX\XXX\gamemodes\XXX.pwn(1941) : error 035: argument type mismatch (argument 1)
Line 1491:
pawn Код:
if(strval(tmp) != strval(IP))



Re: Dini help? - DaTa[X] - 12.06.2013

Ip ? use strcmp


Re: Dini help? - [MG]Dimi - 12.06.2013

In case you use strval it expects Param to be string. And you have forwarded Integer in it.
pawn Код:
tmp = dini_Int(file, "IP");
            if(strval(tmp) != strval(IP))
But as DaTa[X] said use !strcmp
pawn Код:
if(strcmp(dini_Get(file, "IP"),IP))



Re: Dini help? - Affan - 12.06.2013

I don't understand.
If you are saying to change
pawn Код:
if(strval(tmp) != strval(IP))
To
pawn Код:
if(strval(tmp) != strval(strcmp))
It doesn't work.

@UP: Your one doesn't work either.


Re: Dini help? - [MG]Dimi - 12.06.2013

No.
pawn Код:
//Replace this
if(strval(tmp) != strval(IP))
//with this
if(strcmp(dini_Get(file, "IP"),IP))
IP is String so like that you can't compare it as number. That's why you use strcmp. Also you have to use dini_Get to get it as string.


Re: Dini help? - Affan - 12.06.2013

Quote:
Originally Posted by [MG]Dimi
Посмотреть сообщение
No.
pawn Код:
//Replace this
if(strval(tmp) != strval(IP))
//with this
if(strcmp(dini_Get(file, "IP"),IP))
IP is String so like that you can't compare it as number. That's why you use strcmp. Also you have to use dini_Get to get it as string.
Yes I did that. But same error
pawn Код:
error 035: argument type mismatch (argument 2)



Re: Dini help? - Aly - 12.06.2013

problem is here use this:
pawn Код:
if(strval(tmp) != strval(ip))



Re: Dini help? - Affan - 12.06.2013

Quote:
Originally Posted by Aly
Посмотреть сообщение
problem is here use this:
pawn Код:
if(strval(tmp) != strval(ip))
Yes. I changed it to
pawn Код:
if(strcmp(dini_Get(file, "IP"),IP))
So how can I fix it? It's not working


Re: Dini help? - Aly - 12.06.2013

Damn it. It's an IP, that means string.
When you save the IP use: dini_Set(file,"IP",IP);
and when you get it from file use: dini_Get(file,"IP",IP);
After you did that do like this:
pawn Код:
if(strcmp(dini_Get(file,"IP"),ip) == 0)



Re: Dini help? - Affan - 12.06.2013

Quote:
Originally Posted by Aly
Посмотреть сообщение
Damn it. It's an IP, that means string.
When you save the IP use: dini_Set(file,"IP",IP);
and when you get it from file use: dini_Get(file,"IP",IP);
After you did that do like this:
pawn Код:
if(strcmp(dini_Get(file,"IP"),ip) == 0)
Now that's working. Thanks. +rep