SA-MP Forums Archive
[Help] Indexing arrays? - 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] Indexing arrays? (/showthread.php?tid=79643)



[Help] Indexing arrays? - Ace_Menace - 29.05.2009

I have looked on the Wiki, but couldn't find anything.

If someone could show me how I go about doing this then, thank you.

Anyways, here's my issue.

Код:
C:\Documents and Settings\HP_Administrator\Desktop\bfxUDx2.pwn(469) : error 033: array must be indexed (variable "cmd")
C:\Documents and Settings\HP_Administrator\Desktop\bfxUDx2.pwn(509) : error 033: array must be indexed (variable "tmp")
C:\Documents and Settings\HP_Administrator\Desktop\bfxUDx2.pwn(512) : error 033: array must be indexed (variable "tmp")
C:\Documents and Settings\HP_Administrator\Desktop\bfxUDx2.pwn(515) : error 033: array must be indexed (variable "tmp")
C:\Documents and Settings\HP_Administrator\Desktop\bfxUDx2.pwn(518) : error 033: array must be indexed (variable "tmp")
C:\Documents and Settings\HP_Administrator\Desktop\bfxUDx2.pwn(578) : error 033: array must be indexed (variable "tmp")
And of course the lines.

Код:
469: cmd = strtok(cmdtext,idx);
509: tmp = strtok(cmdtext,idx);
512: tmp = strtok(cmdtext,idx);
515: tmp = strtok(cmdtext,idx);
518: tmp = strtok(cmdtext,idx);
578: tmp = strtok(cmdtext,idx);



Re: [Help] Indexing arrays? - Donny_k - 29.05.2009

Click me.


Re: [Help] Indexing arrays? - Ace_Menace - 29.05.2009

Sure I got That.

But aren't the lines with errors doing exactly that?


Re: [Help] Indexing arrays? - Donny_k - 29.05.2009

Well clearly not as the error is there dude.

Make sure you are using the correct sizes for cmd and tmp, try with 256 first off because I'm sure that strtok crap used that size and code always helps dude, I can't know what's going on without seeing code.


Re: [Help] Indexing arrays? - Cueball - 30.05.2009

Donny is right, you aren't indexing them properly, and it is most likely due to the fact that you don't actually give an index at all.

Use this instead:
pawn Код:
cmd[0] = strtok(cmdtext, idx); // This tells the compiler to place the returned string into the first (and following) cell(s) of your 'cmd' array.
Hopefully this helps,

~Cueball~



Re: [Help] Indexing arrays? - Ace_Menace - 30.05.2009

Quote:
Originally Posted by Cuecumber
Donny is right, you aren't indexing them properly, and it is most likely due to the fact that you don't actually give an index at all.

Use this instead:
pawn Код:
cmd[0] = strtok(cmdtext, idx); // This tells the compiler to place the returned string into the first (and following) cell(s) of your 'cmd' array.
Hopefully this helps,

~Cueball~
I got it to work.. Thanks, still a few things don't work. But i Will get them