Just to make sure I'm getting this...
` Player record
type player_data
id as integer
name as string
...
...
cargo as dword
endtype
global dim Players(0) as player_data
` Cargo Record
type cargo_data
contract as integer
limb as integer
objid as integer
endtype
global dim Cargo(0) as cargo_data
` Add Player
array insert at bottom Players(0)
rec = array count(Players(0))
Players(rec).cargo = NewArray_Cargo(8)
` Receive Cargo data from server
Packet = mn recv TCP(inst, Recv, plr)
...
...
link array Cargo(0), Players(rec).cargo
for c = 1 to 8
Cargo(c).contract = mn Get Int(Recv)
Cargo(c).limb = mn Get Int(Recv)
Cargo(c).objid = mn Get Int(Recv)
next c
unlick array Cargo(0)
Function NewArray_Cargo(size)
ArrPtr as Dword
Local Dim tmpCargo(size) as cargo_data
ArrPtr = GET ARRAYPTR( tmpCargo() )
UNLINK ARRAY tmpCargo()
endfunction ArrPtr
and this will link a Cargo array with indexes 1-8 to each player?
Due to that, I'm guessing that when I remove a player from the game, the Cargo array can be removed and free up memory with...
link array Cargo(0), Players(rec).cargo
for c = 8 to 1 step -1
array delete element Cargo(0), c
next c
unlink array Cargo(0)
If that's the case, and it's a pretty fast method, which I'm sure it is from IanM, then this is perfect.