Clone dynamic array
I made code which randomly spawns entities from dynamic array, the problem is that when deleting from temporary array it also deletes from the main array, is it possible to clone the array or something so that the main array could not be edited, tried ArrayClone( ); but it gets undefined.
PHP Code:
|
Re: Clone dynamic array
If you are doing stuff on a temp array, it should not affect the main array if it is not referenced. Which one is the one you want modified and which should remain untouched?
|
Re: Clone dynamic array
The temp array is
new Array:Boxes; And the main array is SupplyBoxes which is filled when plugin starts. The spawn event is made after some time from round start. I came up with a temporary solution but I think it isn't efficient ( to push main arrays items to temp by a loop ). PHP Code:
|
Re: Clone dynamic array
What is the actual purpose (in English) of what this code is doing.
|
Re: Clone dynamic array
1. The items from main array are passed to a temporary array.
2. The code randomly chooses array items and passes their info to another function while deleting temporary arrays items. But somehow it deletes not only the temporary arrays items but the mains too. |
Re: Clone dynamic array
You can consider variables containing dynamic arrays handles as references. That means that by doing:
PHP Code:
You said you tried ArrayClone but it didn't work. Can you show us what did you try? |
Re: Clone dynamic array
I used it like new Array: Arr2 = ArrayClone( Arr1 ); but the compiler showed me that the function is undefined so I checked the cellarray.inc and there wasn't such a function, maybe I am using an older amxmodx but I downloaded it from the original website
|
Re: Clone dynamic array
Right, doesn't look like there is ArrayClone pre-1.8.3. Well, too bad, I guess you'll have to copy the array yourself (like you tried), or think of another system for managing your array for what you are trying to do.
|
| All times are GMT -4. The time now is 09:23. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.