SA-MP Forums Archive
Can I Add Value To An Array - 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: Can I Add Value To An Array (/showthread.php?tid=631450)



Can I Add Value To An Array - Novacaine - 29.03.2017

Hi everyone,

For example, i have an array like "new arr[] = {1, 3, 5, 7};". Can i add more values to this array dynamically?


Re: Can I Add Value To An Array - Toroi - 29.03.2017

In running-time nope afaik.


Re: Can I Add Value To An Array - BroZeus - 29.03.2017

You certainly cannot if you declare your array like that. If you declare it like this instead then you can :
Quote:

new arr[50] = {1, 3, 5, 7};

It is mandatory in pawn to know array size before compilation therefore dynamic memory allocation is not possible through pawn directly.

You can use plugin if you really want dynamic memory allocation, here is one i found https://sampforum.blast.hk/showthread.php?tid=364285


Re: Can I Add Value To An Array - Novacaine - 29.03.2017

Thank you for your answers.