Resizing Arrays at runtime (global variables) and getting size of array
#1

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?
Reply
#2

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.
Reply
#3

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

However you must read the important notes of that thread.
Reply
#4

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
https://sampforum.blast.hk/showthread.php?tid=58827

However you must read the important notes of that thread.
I just spent a while fiddling with that, the compiler refuses to agree with assigning values/data to it.
Reply
#5

C++ have dynamic arrays? Right?

This could be done into samp by a plugin or sonething? Dynamic arrays would be awesome.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)