Zin
Expert
- Joined
- Aug 1, 2013
- Messages
- 1,734
- Solutions
- 2
- Reaction score
- 117
I'm looking to create some arrays in sampfuncs and then store the array to a global var so I can get the array later on and simplify the code better, however I'm unsure as if this is possible as I made a test script to test this principle and it seems like the array address changes when it is stored. So I'm wondering if me clearing the memory in the var I created the array in deletes the entire array or something, script sort of would explain it better.
Code:
{$CLEO .cs}
THREAD 'TEST'
REPEAT
WAIT 0
UNTIL 0AFA:
alloc 31@ 1024
0C20: string_array 31@ element 1 size 256 = "1000.570557 1638.594849 10.480600"
0C20: string_array 31@ element 2 size 256 = "1500.875487 1754.457845 10.834575"
0C20: string_array 31@ element 3 size 256 = "2500.875487 1638.594849 14.834575"
0BFC: set_global_var "1" = 31@
chatmsg "1: %x" 0xFFFFFF 31@
31@ = 0
free 31@
alloc 31@ 1024
0C20: string_array 31@ element 1 size 256 = "-1000.570557 -1638.594849 -10.480600"
0C20: string_array 31@ element 2 size 256 = "-1500.875487 -1754.457845 -10.834575"
0C20: string_array 31@ element 3 size 256 = "-2500.875487 -1638.594849 -14.834575"
0BFC: set_global_var "2" = 31@
chatmsg "2: %x" 0xFFFFFF 31@
31@ = 0
free 31@
0B34: samp register_client_command "TEST" to_label @TEST
WHILE TRUE
WAIT 0
0AB1: @RESTART 1 WITH_KEY 88 // KEY_X
END
:TEST
0B35: samp 0@ = get_last_command_params
IF
0AD4: $NOT_USED scan 0@ format "%d %d" 0@ 1@
THEN
alloc 0@ 1024
IF
0@ == 1
THEN
0BFD: 0@ = get_global_var "1"
ELSE
IF
0@ == 2
THEN
0BFD: 0@ = get_global_var "2"
END
END
chatmsg "%x" 0xFFFFFF 0@
0C1F: 1@ = string_array 0@ element 1@ size 256
chatmsg 1@ 0xFFFFFF
free 0@
END
samp.CmdRet()
:RESTART
IF
0AB0: 0@
THEN
REPEAT
WAIT 0
PRINT "~R~RESTART: ~w~TEST.CS" 100
UNTIL 8AB0: 0@
0A92: RESTART "TEST.CS"
004E: STOP THIS CLEO
END
0AB2: 0