huytruong
Member
- Joined
- Dec 16, 2016
- Messages
- 6
- Reaction score
- 0
Code Group
Code:
{$CLEO}
0000:
{there are 2 data sets and 2 threads, one thread displays colors/numbers from the first array while the other thread builds the new array with fresh data,
then the switch occurs, the built array starts being displayed and the old one is reset and built again}
const
ARRAY = 0@
/*
int clr
int count
*/
INDEX = 1@
CLR = 2@
COUNT = 3@
THREAD_DISPLAY = 4@
ARRAY_2 = 5@
ARRAY_BUFF = 6@
CMD = 7@
BOOL = 8@
INT_BUFF = 9@
MOD_SWITCH = 10@
POSITION_MODE = 11@
POSX = 12@
POSY = 13@
SIZE_MODE = 14@
INITIAL_RUN = 16@
end
alloc ARRAY 2500
alloc ARRAY_2 2500
call @ResetArray 1 ARRAY
call @ResetArray 1 ARRAY_2
repeat
wait 50
until 0AFA: is_samp_available
0AF8: samp add_message_to_chat "{F7F694}colorGroups mod. Use {FF4800}/cghelp {F7F694}to see commands"
0B34: samp register_client_command "cg" to_label @cmd_toggle
0B34: samp register_client_command "cgline" to_label @cmd_line_limit
0B34: samp register_client_command "cgpos" to_label @cmd_adjustpos
0B34: samp register_client_command "cgsize" to_label @cmd_size
0B34: samp register_client_command "cghelp" to_label @cmd_help
if 0AAB: file_exists "CLEO\colorGroupsSettings.ini"
then
0AF0: MOD_SWITCH = get_int_from_ini_file "CLEO\colorGroupsSettings.ini" section "Settings" key "switch"
0AF0: 15@ = get_int_from_ini_file "CLEO\colorGroupsSettings.ini" section "Settings" key "size"
else
0AF8: samp add_message_to_chat "{F7F694}CLEO\colorGroupsSettings.ini {FF4800}not found. {F7F694}The mod won't work"
0A93: end_custom_thread
end
wait 12000
if MOD_SWITCH == 1
then
0C6A: THREAD_DISPLAY = create_custom_thread_at_label @Display
end
if 0AAB: file_exists "CLEO\colorGroupsSettings.ini"
then
0AF0: INT_BUFF = get_int_from_ini_file "CLEO\colorGroupsSettings.ini" section "Settings" key "line"
0C6C: set_thread THREAD_DISPLAY local_var 7 = INT_BUFF
0AF0: INT_BUFF = get_int_from_ini_file "CLEO\colorGroupsSettings.ini" section "Settings" key "x"
0C6C: set_thread THREAD_DISPLAY local_var 8 = INT_BUFF
0AF0: INT_BUFF = get_int_from_ini_file "CLEO\colorGroupsSettings.ini" section "Settings" key "y"
0C6C: set_thread THREAD_DISPLAY local_var 9 = INT_BUFF
0C6C: set_thread THREAD_DISPLAY local_var 10 = 15@
end
//0C6E: destroy_custom_thread 0@
//0C6F: restart_custom_thread 0@
0085: ARRAY_BUFF = ARRAY
INITIAL_RUN = 2
:main
wait 0
if MOD_SWITCH == 1
then
if POSITION_MODE == 1
then
0B5D: samp toggle_cursor 1
if key_down 1
then
0B5E: get_cursor_pos POSX POSY
0C6C: set_thread THREAD_DISPLAY local_var 8 = POSX
0C6C: set_thread THREAD_DISPLAY local_var 9 = POSY
end
0AD1: show_formatted_text_highpriority "Click anywhere + use /cgpos again to exit editing" time 100 0xF7F694
jump @main
end
if SIZE_MODE == 1
then
call @Adjust_Size 1 15@ _returned 15@
0C6C: set_thread THREAD_DISPLAY local_var 10 = 15@ //size
0C6C: set_thread THREAD_DISPLAY local_var 26 = 1 //reload font bool
jump @main
end
call @ResetArray 1 ARRAY_BUFF
for INDEX = 0 to 1000
if INITIAL_RUN < 1
then
wait 3
end
if 0B23: samp is_player_connected INDEX
then
0B37: samp CLR = get_player_color INDEX
call @AddColor 2 ARRAY_BUFF CLR
end
if or
POSITION_MODE == 1
SIZE_MODE == 1
then
jump @main
end
end
INITIAL_RUN -= 1
0C6C: set_thread THREAD_DISPLAY local_var 0 = ARRAY_BUFF
if 003B: ARRAY_BUFF == ARRAY // (int)
then
0085: ARRAY_BUFF = ARRAY_2
else
0085: ARRAY_BUFF = ARRAY
end
end
jump @main
:cmd_adjustpos
0B12: POSITION_MODE = POSITION_MODE XOR 1
if POSITION_MODE == 1
then
0B5D: samp toggle_cursor 1
else
0AF1: write_int 12@ to_ini_file "CLEO\colorGroupsSettings.ini" section "Settings" key "x"
0AF1: write_int POSY to_ini_file "CLEO\colorGroupsSettings.ini" section "Settings" key "y"
0B5D: samp toggle_cursor 0
end
samp.CmdRet()
:cmd_size
0B12: SIZE_MODE = SIZE_MODE XOR 1
if SIZE_MODE == 0
then
0AF1: write_int 15@ to_ini_file "CLEO\colorGroupsSettings.ini" section "Settings" key "size"
end
samp.CmdRet()
:Adjust_Size
31@ = false
if key_down 104
then
0@ += 1
31@ = true
0485: return_true
else
if key_down 98
then
0@ -= 1
31@ = true
end
end
if 001B: 1 > 0@
then
0@ = 1
else
if 0019: 0@ > 63
then
0@ = 63
end
end
0AD1: show_formatted_text_highpriority "Use numpad 8 and 2 to increase/decrease font size + use /cgsize again to exit editing" time 100 0xF7F694
if 31@ == true
then
//0AF1: write_int 0@ to_ini_file "CLEO\colorGroupsSettings.ini" section "Settings" key "size"
0485: return_true
else
059A: return_false
end
0AB2: ret 1 0@
:cmd_toggle
0B12: MOD_SWITCH = MOD_SWITCH XOR 1
0AF1: write_int MOD_SWITCH to_ini_file "CLEO\colorGroupsSettings.ini" section "Settings" key "switch"
if MOD_SWITCH == 1
then
0C6A: THREAD_DISPLAY = create_custom_thread_at_label @Display
0AD1: show_formatted_text_highpriority "colorGroups is ~G~ON" time 700
0AF0: INT_BUFF = get_int_from_ini_file "CLEO\colorGroupsSettings.ini" section "Settings" key "line"
0C6C: set_thread THREAD_DISPLAY local_var 7 = INT_BUFF
0AF0: INT_BUFF = get_int_from_ini_file "CLEO\colorGroupsSettings.ini" section "Settings" key "x"
0C6C: set_thread THREAD_DISPLAY local_var 8 = INT_BUFF
0AF0: INT_BUFF = get_int_from_ini_file "CLEO\colorGroupsSettings.ini" section "Settings" key "y"
0C6C: set_thread THREAD_DISPLAY local_var 9 = INT_BUFF
0C6C: set_thread THREAD_DISPLAY local_var 10 = 15@
INITIAL_RUN = 2
else
0C6E: destroy_custom_thread THREAD_DISPLAY
0AD1: show_formatted_text_highpriority "colorGroups is ~R~OFF" time 700
end
samp.CmdRet()
:cmd_line_limit
0B35: samp CMD = get_last_command_params
if 0AD4: BOOL = scan_string CMD format "%d" INT_BUFF //IF and SET
then
0C6C: set_thread THREAD_DISPLAY local_var 7 = INT_BUFF
0AF1: write_int INT_BUFF to_ini_file "CLEO\colorGroupsSettings.ini" section "Settings" key "line"
end
samp.CmdRet()
:cmd_help
0AF8: samp add_message_to_chat "{FF4800}colorGroups {F7F694}commands:"
0AF8: samp add_message_to_chat "{FFFFFF}/cg {F7F694}(toggle whole mod)"
0AF8: samp add_message_to_chat "{FFFFFF}/cgpos {F7F694}(set position)"
0AF8: samp add_message_to_chat "{FFFFFF}/cgsize {F7F694}(set size)"
0AF8: samp add_message_to_chat "{FFFFFF}/cgline <num> {F7F694}(set max squares per horizontal line)"
samp.CmdRet()
:Display //THREAD (var 26@ is going to be a trigger to reset the font height)
wait 0
0@ = 0
while 0@ == 0
wait 50
end
alloc 4@ 16
//printf "line x y size = %d %d %d %d" 5000 7@ 8@ 9@ 10@
0085: 11@ = 10@ // (int)
11@ *= 2
11@ /= 5
0B6D: render 3@ = create "Verdana" height 11@ flags 9
0085: 12@ = 10@
12@ *= 2
12@ /= 6
while true
wait 0
//30@ = 200
//28@ = 50
0085: 28@ = 8@
0085: 30@ = 9@
6@ = 0 //move down every few squares
0085: 27@ = 0@ // (int)
for 31@ = 0 to 300
call @GetColor 2 27@ 31@ _returned_color_and_count 1@ 2@
if or
2@ == 0
2@ > 1000
then
break
end
//draw here...
0085: 29@ = 28@
005A: 29@ += 10@
//29@ += 30
0B68: render draw_line_point1 28@ 30@ point2 29@ 30@ width 10@ color 1@
//0B68: render draw_line_point1 28@ 30@ point2 29@ 30@ width 30 color 1@
format 4@ "%d" 2@
0B6B: render 5@ = font 3@ draw_text 4@ length
5@ /= 2
0062: 28@ -= 5@ // (int)
28@ -= 1
//30@ -= 13
0062: 30@ -= 12@
0B6F: render 3@ draw_text 4@ of pos 28@ 30@ color 0xFFFFFFFF
28@ += 1
005A: 30@ += 12@
005A: 28@ += 5@ // (int)
28@ += 1
005A: 28@ += 10@
//28@ += 30
6@++
//if 6@ >= 10 //(could make it variable)
if 002D: 6@ >= 7@ // (int)
then
005A: 30@ += 10@
//30@ += 30
30@ += 1
6@ = 0
0085: 28@ = 8@
end
//alloc 20@ 64
//0AD3: 20@ = "%d %d ind:%d" 1@ 2@ 31@
//0AF8: samp add_message_to_chat 20@ color -1
//free 20@
end
if 26@ == 1
then
26@ = 0
0B6E: render release_font 3@
0085: 11@ = 10@ // (int)
11@ *= 2
11@ /= 5
0B6D: render 3@ = create "Verdana" height 11@ flags 9
0085: 12@ = 10@
12@ *= 2
12@ /= 6
end
end
:GetColor
1@ *= 8
005A: 0@ += 1@ // (int)
0A8D: 31@ = read_memory 0@ size 4 virtual_protect 0 //color
0@+=4
0A8D: 30@ = read_memory 0@ size 4 virtual_protect 0 //count
ret 2 31@ 30@
:AddColor
for 31@ = 0 to 300
0A8D: 30@ = read_memory 0@ size 4 virtual_protect 0 //read color value
if 003B: 1@ == 30@ // compare color value with player color
then
0@ += 4 //get count address
0A8D: 29@ = read_memory 0@ size 4 virtual_protect 0 //get count value
29@ += 1
0A8C: write_memory 0@ size 4 value 29@ virtual_protect 0
ret 0
end
if 30@ == 0
then
0A8C: write_memory 0@ size 4 value 1@ virtual_protect 0 //add new color
0@ += 4 //count addr
0A8C: write_memory 0@ size 4 value 1 virtual_protect 0 //add new color count (1)
ret 0
end
0@ += 8
end
ret 0
:ResetArray
for 31@ = 0 to 600 step 8
0A8C: write_memory 0@ size 8 value 0 virtual_protect 0
0@ += 8
end
ret 0