SA-MP Forums Archive
Array?What?i don't know any of these... - 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: Array?What?i don't know any of these... (/showthread.php?tid=504676)



Array?What?i don't know any of these... - Dziugsas - 05.04.2014

Hello guys!

Today i'm in a trouble.

Код:
error 006: must be assigned to an array
Line :
Код:
ApartmentInfo[apid][Adresas] = GetPlayerZone(playerid);
I don't know how to work with strings :/


Re: Array?What?i don't know any of these... - RajatPawar - 05.04.2014

Read through this.

https://sampforum.blast.hk/showthread.php?tid=318212

Learn, and you'll be able to fix it.


Re: Array?What?i don't know any of these... - Konstantinos - 05.04.2014

pawn Код:
strcpy(ApartmentInfo[apid][Adresas], GetPlayerZone(playerid), 129);
pawn Код:
#define strcpy(%0,%1,%2) strcat((%0[0] = '\0', %0), %1, %2)



Re: Array?What?i don't know any of these... - Dziugsas - 05.04.2014

i have already read it before and i'm felling like in space .

I tried like this

Код:
new zonename[129] = GetPlayerZone(playerid)

ApartmentInfo[apid][Adresas] = zonename;
Still getting errors :/


Re: Array?What?i don't know any of these... - Dziugsas - 05.04.2014

Konstantinos , i don't really understand :/


Re: Array?What?i don't know any of these... - Konstantinos - 05.04.2014

I'm not sure if you read my post after I edited it because I added the size you declared the array.

You cannot copy a string to another with assignment (=) if the sizes do not match so you should use strcat, memcpy, format.

This:
pawn Код:
strcpy(ApartmentInfo[apid][Adresas], GetPlayerZone(playerid), 129);
it's like doing:
pawn Код:
format(ApartmentInfo[apid][Adresas], 129, GetPlayerZone(playerid));
but format is slower.


Re: Array?What?i don't know any of these... - Dziugsas - 05.04.2014

Nevermind , i made it with format .Thanks anyway!