SA-MP Forums Archive
array - dimension problem - 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 - dimension problem (/showthread.php?tid=521357)



array - dimension problem - Crayder - 22.06.2014

Ok, so I'm using Y-Commands because it offers so much more than any other processor. But that has nothing to do with the problem, the problem is that the script freezes at the point where I call "aCommandsA[i]", to better explain, let me give you my code!

Here is the array! Which is the list of commands to be used in the ycmd function.
pawn Код:
new aCommandsA[][]={"commands1", "coommands2", "commands3"};
Here is where I call "aCommandsA[i]" using the ycmd function, Group_SetGlobalCommand.
pawn Код:
for(new i=sizeof(aCommandsA); i!=0; i--) Group_SetGlobalCommand(Command_GetID(aCommandsA[i]), false);
Using my knowledge I was able to narrow thge rpoblem down to the point that "aCommandsA[i]" is called for sure. So can anyone explain what is wrong with the array? Note that the the script just seems to skip the rest of onplayerconnect after this, its very important to me...


Re: array - dimension problem - Konstantinos - 22.06.2014

It goes out of bounds. Change to:
pawn Код:
for (new i; i != sizeof (aCommandsA); ++i)
or with your way:
pawn Код:
for (new i = sizeof (aCommandsA) - 1; i != -1; i--)



Re: array - dimension problem - Crayder - 22.06.2014

It gets through opc now, but this somehow corrupted my cmd command, it may be ok with tweaking though..