Resizing Arrays at runtime (global variables) and getting size of 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: Resizing Arrays at runtime (global variables) and getting size of array (
/showthread.php?tid=508882)
Resizing Arrays at runtime (global variables) and getting size of array -
Hoborific - 24.04.2014
The title kind of summarizes my current problems with my script, I have an array I add and remove from during runtime and I use it for a very simplistic intelligence program which grows off the server chat, anyway I have had to store the value of the last index I wrote to and use that index++ for the next value, the problem is I cannot simply use it like a vector or a list, and as such I have been having to store deleted indexes as a separate array and reference that, it works fine but feels very dirty, another thing I tried was having two arrays and copying all non-blank values over into a temporary array, clearing the original, passing them all back, disposing the temporary array (out of scope) and then updating the index value for the script to continue
This is dirty and after a few hours it gradually takes longer and longer to execute. also how big is an array if I initialize it without a size?
Re: Resizing Arrays at runtime (global variables) and getting size of array -
Vince - 24.04.2014
Pawn does not support dynamic array (pop, push, etc). In addition, all array sizes must be known at compile time. If the compiler cannot establish the size by itself it will throw an error.
Re: Resizing Arrays at runtime (global variables) and getting size of array -
Konstantinos - 24.04.2014
https://sampforum.blast.hk/showthread.php?tid=58827
However you must read the important notes of that thread.
Re: Resizing Arrays at runtime (global variables) and getting size of array -
Hoborific - 24.04.2014
Quote:
Originally Posted by Konstantinos
|
I just spent a while fiddling with that, the compiler refuses to agree with assigning values/data to it.
Re: Resizing Arrays at runtime (global variables) and getting size of array -
arakuta - 24.04.2014
C++ have dynamic arrays? Right?
This could be done into samp by a plugin or sonething? Dynamic arrays would be awesome.