 |
|
Member
|

01-31-2016
, 12:18
Re: Clone dynamic array
|
#3
|
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:
new Float:Orig[ 3 ], Float:Angl[ 3 ]; new AmountCvar = get_pcvar_num( cvar_amountSpawn ); new ArraySizeBox = ArraySize( SupplyBoxes ); new size = ( AmountCvar == 0 || AmountCvar > ArraySizeBox ) ? ArraySizeBox : AmountCvar; new Data[ SupplyBoxesArray ]; new count, randomId; new Array:Boxes = ArrayCreate( SupplyBoxesArray ); for( new index = 0; index < ArraySizeBox; index++ ) { ArrayGetArray( SupplyBoxes, index, Data ); ArrayPushArray( Boxes, Data ); }
do { randomId = random( ArraySizeBox ); ArrayGetArray( Boxes, randomId, Data ); Orig[ 0 ] = Data[ box_origin ][ 0 ]; Angl[ 0 ] = Data[ box_angles ][ 0 ]; Orig[ 1 ] = Data[ box_origin ][ 1 ]; Angl[ 1 ] = Data[ box_angles ][ 1 ]; Orig[ 2 ] = Data[ box_origin ][ 2 ]; Angl[ 2 ] = Data[ box_angles ][ 2 ]; spawnSupplyBox( Orig, Angl, Data[ line_id ] ); count++;
ArrayDeleteItem( Boxes, randomId ); ArraySizeBox--; } while( count < size );
|
|
|
|