Resizing array & lists
#1

Is there something like list avaible in SA-MP? By list i mean that i can add and remove array members at runtime without knowing max ammount of items at coding time. If not, is there any way to resize array at runtime?
Reply
#2

The only solution id know atm is to create an array and to write the old one in the new one. You could add/remove something then to resize it.
Reply
#3

Array i want to resize is global. Can i create global arrays at runtime?
Reply
#4

That is not possible. You cannot create global variables during run time.
Reply
#5

I have an idea about workaround, if anyone needs it:

Код:
new array[200], pointer;
pointer = 0;

//adding member
array[pointer]=something
pointer = pointer + 1

//getting members
for (new i = 0;i < pointer;i++)
{
// do something
}
Idea is that instead of using sizeof, you can use another variable that will determine highest member. It's working on my server, but there are two main problems: memory usage can be high since you have to initialize large array and what to do if number of entries still exceeds array size.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)