SA-MP Forums Archive
Help with strings.. - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Help with strings.. (/showthread.php?tid=185901)



Help with strings.. - The_Moddler - 26.10.2010

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


Re: Help with strings.. - LarzI - 26.10.2010

You're doing it wrong!

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



Re: Help with strings.. - The_Moddler - 26.10.2010

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


Re: Help with strings.. - Grim_ - 26.10.2010

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



Re: Help with strings.. - bilakispa - 26.10.2010

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]);



Re: Help with strings.. - Grim_ - 26.10.2010

No, yours is wrong.

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


Re: Help with strings.. - The_Moddler - 26.10.2010

Thanks!