Help with strings..
#1

I'm trying to make an auto-login system by gettimg their ip..

But I have a problem with strings..

pawn Код:
new IP[16][MAX_PLAYERS];
But if I do this:

pawn Код:
GetPlayerIp(playerid, IP[playerid], 16);
It will give me an error because I didn't index the [16] part..

Help
Reply
#2

You're doing it wrong!

pawn Код:
new IP[MAX_PLAYERS][16];
Reply
#3

Well, then if I do this

pawn Код:
if(IP[playerid] == bla bla)
It gives me error, I guess it is because of the [16] again...

Thanks
Reply
#4

IP is a string, so to compare it you must use strcmp.
pawn Код:
if(!strcmp(IP[playerid], "127.0.0.1", true))
Reply
#5

First when you are definning an array, for example, Array[16] it will contain elements from 0 to 15 not 16.

Also, this is wrong
pawn Код:
GetPlayerIp(playerid, IP[playerid], 16);
So, try this
pawn Код:
GetPlayerIp(playerid, IP[15][playerid]);
Reply
#6

No, yours is wrong.

With yours you are only assigning the 15th element of the array, not the whole array.
Reply
#7

Thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)