Dini help?
#1

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))
Reply
#2

Ip ? use strcmp
Reply
#3

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))
Reply
#4

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.
Reply
#5

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.
Reply
#6

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)
Reply
#7

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

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
Reply
#9

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)
Reply
#10

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)