Advertisement
michalmonday

colorGroups.cs

Nov 13th, 2016
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.66 KB | None | 0 0
  1. {$CLEO}
  2. 0000:
  3.  
  4. {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,
  5. then the switch occurs, the built array starts being displayed and the old one is reset and built again}
  6.  
  7. const
  8. ARRAY = 0@
  9. /*
  10. int clr
  11. int count
  12. */
  13. INDEX = 1@
  14. CLR = 2@
  15. COUNT = 3@
  16. THREAD_DISPLAY = 4@
  17. ARRAY_2 = 5@
  18. ARRAY_BUFF = 6@
  19. CMD = 7@
  20. BOOL = 8@
  21. INT_BUFF = 9@
  22. MOD_SWITCH = 10@
  23. POSITION_MODE = 11@
  24. POSX = 12@
  25. POSY = 13@
  26. SIZE_MODE = 14@
  27. INITIAL_RUN = 16@
  28. end
  29.  
  30. alloc ARRAY 2500
  31. alloc ARRAY_2 2500
  32.  
  33. call @ResetArray 1 ARRAY
  34. call @ResetArray 1 ARRAY_2
  35.  
  36. repeat
  37. wait 50
  38. until 0AFA: is_samp_available
  39.  
  40. 0AF8: samp add_message_to_chat "{F7F694}colorGroups mod. Use {FF4800}/cghelp {F7F694}to see commands"
  41.  
  42. 0B34: samp register_client_command "cg" to_label @cmd_toggle
  43. 0B34: samp register_client_command "cgline" to_label @cmd_line_limit
  44. 0B34: samp register_client_command "cgpos" to_label @cmd_adjustpos
  45. 0B34: samp register_client_command "cgsize" to_label @cmd_size
  46. 0B34: samp register_client_command "cghelp" to_label @cmd_help
  47.  
  48.  
  49. if 0AAB: file_exists "CLEO\colorGroupsSettings.ini"
  50. then
  51. 0AF0: MOD_SWITCH = get_int_from_ini_file "CLEO\colorGroupsSettings.ini" section "Settings" key "switch"
  52. 0AF0: 15@ = get_int_from_ini_file "CLEO\colorGroupsSettings.ini" section "Settings" key "size"
  53. else
  54. 0AF8: samp add_message_to_chat "{F7F694}CLEO\colorGroupsSettings.ini {FF4800}not found. {F7F694}The mod won't work"
  55. 0A93: end_custom_thread
  56. end
  57.  
  58. wait 12000
  59.  
  60. if MOD_SWITCH == 1
  61. then
  62. 0C6A: THREAD_DISPLAY = create_custom_thread_at_label @Display
  63. end
  64.  
  65. if 0AAB: file_exists "CLEO\colorGroupsSettings.ini"
  66. then
  67. 0AF0: INT_BUFF = get_int_from_ini_file "CLEO\colorGroupsSettings.ini" section "Settings" key "line"
  68. 0C6C: set_thread THREAD_DISPLAY local_var 7 = INT_BUFF
  69. 0AF0: INT_BUFF = get_int_from_ini_file "CLEO\colorGroupsSettings.ini" section "Settings" key "x"
  70. 0C6C: set_thread THREAD_DISPLAY local_var 8 = INT_BUFF
  71. 0AF0: INT_BUFF = get_int_from_ini_file "CLEO\colorGroupsSettings.ini" section "Settings" key "y"
  72. 0C6C: set_thread THREAD_DISPLAY local_var 9 = INT_BUFF
  73. 0C6C: set_thread THREAD_DISPLAY local_var 10 = 15@
  74. end
  75.  
  76. //0C6E: destroy_custom_thread 0@
  77. //0C6F: restart_custom_thread 0@
  78.  
  79. 0085: ARRAY_BUFF = ARRAY
  80. INITIAL_RUN = 2
  81. :main
  82. wait 0
  83. if MOD_SWITCH == 1
  84. then
  85. if POSITION_MODE == 1
  86. then
  87. 0B5D: samp toggle_cursor 1
  88. if key_down 1
  89. then
  90. 0B5E: get_cursor_pos POSX POSY
  91. 0C6C: set_thread THREAD_DISPLAY local_var 8 = POSX
  92. 0C6C: set_thread THREAD_DISPLAY local_var 9 = POSY
  93. end
  94. 0AD1: show_formatted_text_highpriority "Click anywhere + use /cgpos again to exit editing" time 100 0xF7F694
  95. jump @main
  96. end
  97.  
  98. if SIZE_MODE == 1
  99. then
  100. call @Adjust_Size 1 15@ _returned 15@
  101. 0C6C: set_thread THREAD_DISPLAY local_var 10 = 15@ //size
  102. 0C6C: set_thread THREAD_DISPLAY local_var 26 = 1 //reload font bool
  103. jump @main
  104. end
  105.  
  106.  
  107. call @ResetArray 1 ARRAY_BUFF
  108.  
  109. for INDEX = 0 to 1000
  110. if INITIAL_RUN < 1
  111. then
  112. wait 3
  113. end
  114.  
  115. if 0B23: samp is_player_connected INDEX
  116. then
  117. 0B37: samp CLR = get_player_color INDEX
  118. call @AddColor 2 ARRAY_BUFF CLR
  119. end
  120.  
  121. if or
  122. POSITION_MODE == 1
  123. SIZE_MODE == 1
  124. then
  125. jump @main
  126. end
  127. end
  128.  
  129. INITIAL_RUN -= 1
  130.  
  131. 0C6C: set_thread THREAD_DISPLAY local_var 0 = ARRAY_BUFF
  132.  
  133. if 003B: ARRAY_BUFF == ARRAY // (int)
  134. then
  135. 0085: ARRAY_BUFF = ARRAY_2
  136. else
  137. 0085: ARRAY_BUFF = ARRAY
  138. end
  139. end
  140. jump @main
  141.  
  142. :cmd_adjustpos
  143. 0B12: POSITION_MODE = POSITION_MODE XOR 1
  144. if POSITION_MODE == 1
  145. then
  146. 0B5D: samp toggle_cursor 1
  147. else
  148. 0AF1: write_int 12@ to_ini_file "CLEO\colorGroupsSettings.ini" section "Settings" key "x"
  149. 0AF1: write_int POSY to_ini_file "CLEO\colorGroupsSettings.ini" section "Settings" key "y"
  150. 0B5D: samp toggle_cursor 0
  151. end
  152. samp.CmdRet()
  153.  
  154. :cmd_size
  155. 0B12: SIZE_MODE = SIZE_MODE XOR 1
  156. if SIZE_MODE == 0
  157. then
  158. 0AF1: write_int 15@ to_ini_file "CLEO\colorGroupsSettings.ini" section "Settings" key "size"
  159. end
  160. samp.CmdRet()
  161.  
  162. :Adjust_Size
  163. 31@ = false
  164. if key_down 104
  165. then
  166. 0@ += 1
  167. 31@ = true
  168. 0485: return_true
  169. else
  170. if key_down 98
  171. then
  172. 0@ -= 1
  173. 31@ = true
  174. end
  175. end
  176. if 001B: 1 > 0@
  177. then
  178. 0@ = 1
  179. else
  180. if 0019: 0@ > 63
  181. then
  182. 0@ = 63
  183. end
  184. end
  185. 0AD1: show_formatted_text_highpriority "Use numpad 8 and 2 to increase/decrease font size + use /cgsize again to exit editing" time 100 0xF7F694
  186. if 31@ == true
  187. then
  188. //0AF1: write_int 0@ to_ini_file "CLEO\colorGroupsSettings.ini" section "Settings" key "size"
  189. 0485: return_true
  190. else
  191. 059A: return_false
  192. end
  193. 0AB2: ret 1 0@
  194.  
  195.  
  196.  
  197. :cmd_toggle
  198. 0B12: MOD_SWITCH = MOD_SWITCH XOR 1
  199. 0AF1: write_int MOD_SWITCH to_ini_file "CLEO\colorGroupsSettings.ini" section "Settings" key "switch"
  200. if MOD_SWITCH == 1
  201. then
  202. 0C6A: THREAD_DISPLAY = create_custom_thread_at_label @Display
  203. 0AD1: show_formatted_text_highpriority "colorGroups is ~G~ON" time 700
  204.  
  205. 0AF0: INT_BUFF = get_int_from_ini_file "CLEO\colorGroupsSettings.ini" section "Settings" key "line"
  206. 0C6C: set_thread THREAD_DISPLAY local_var 7 = INT_BUFF
  207. 0AF0: INT_BUFF = get_int_from_ini_file "CLEO\colorGroupsSettings.ini" section "Settings" key "x"
  208. 0C6C: set_thread THREAD_DISPLAY local_var 8 = INT_BUFF
  209. 0AF0: INT_BUFF = get_int_from_ini_file "CLEO\colorGroupsSettings.ini" section "Settings" key "y"
  210. 0C6C: set_thread THREAD_DISPLAY local_var 9 = INT_BUFF
  211. 0C6C: set_thread THREAD_DISPLAY local_var 10 = 15@
  212. INITIAL_RUN = 2
  213. else
  214. 0C6E: destroy_custom_thread THREAD_DISPLAY
  215. 0AD1: show_formatted_text_highpriority "colorGroups is ~R~OFF" time 700
  216. end
  217. samp.CmdRet()
  218.  
  219. :cmd_line_limit
  220. 0B35: samp CMD = get_last_command_params
  221. if 0AD4: BOOL = scan_string CMD format "%d" INT_BUFF //IF and SET
  222. then
  223. 0C6C: set_thread THREAD_DISPLAY local_var 7 = INT_BUFF
  224. 0AF1: write_int INT_BUFF to_ini_file "CLEO\colorGroupsSettings.ini" section "Settings" key "line"
  225. end
  226. samp.CmdRet()
  227.  
  228. :cmd_help
  229. 0AF8: samp add_message_to_chat "{FF4800}colorGroups {F7F694}commands:"
  230. 0AF8: samp add_message_to_chat "{FFFFFF}/cg {F7F694}(toggle whole mod)"
  231. 0AF8: samp add_message_to_chat "{FFFFFF}/cgpos {F7F694}(set position)"
  232. 0AF8: samp add_message_to_chat "{FFFFFF}/cgsize {F7F694}(set size)"
  233. 0AF8: samp add_message_to_chat "{FFFFFF}/cgline <num> {F7F694}(set max squares per horizontal line)"
  234. samp.CmdRet()
  235.  
  236.  
  237. :Display //THREAD (var 26@ is going to be a trigger to reset the font height)
  238. wait 0
  239. 0@ = 0
  240. while 0@ == 0
  241. wait 50
  242. end
  243.  
  244. alloc 4@ 16
  245. //printf "line x y size = %d %d %d %d" 5000 7@ 8@ 9@ 10@
  246. 0085: 11@ = 10@ // (int)
  247. 11@ *= 2
  248. 11@ /= 5
  249. 0B6D: render 3@ = create "Verdana" height 11@ flags 9
  250. 0085: 12@ = 10@
  251. 12@ *= 2
  252. 12@ /= 6
  253.  
  254. while true
  255. wait 0
  256. //30@ = 200
  257. //28@ = 50
  258. 0085: 28@ = 8@
  259. 0085: 30@ = 9@
  260. 6@ = 0 //move down every few squares
  261. 0085: 27@ = 0@ // (int)
  262. for 31@ = 0 to 300
  263. call @GetColor 2 27@ 31@ _returned_color_and_count 1@ 2@
  264. if or
  265. 2@ == 0
  266. 2@ > 1000
  267. then
  268. break
  269. end
  270.  
  271. //draw here...
  272.  
  273. 0085: 29@ = 28@
  274. 005A: 29@ += 10@
  275. //29@ += 30
  276. 0B68: render draw_line_point1 28@ 30@ point2 29@ 30@ width 10@ color 1@
  277. //0B68: render draw_line_point1 28@ 30@ point2 29@ 30@ width 30 color 1@
  278.  
  279.  
  280. format 4@ "%d" 2@
  281. 0B6B: render 5@ = font 3@ draw_text 4@ length
  282. 5@ /= 2
  283. 0062: 28@ -= 5@ // (int)
  284. 28@ -= 1
  285. //30@ -= 13
  286. 0062: 30@ -= 12@
  287. 0B6F: render 3@ draw_text 4@ of pos 28@ 30@ color 0xFFFFFFFF
  288. 28@ += 1
  289. 005A: 30@ += 12@
  290. 005A: 28@ += 5@ // (int)
  291. 28@ += 1
  292. 005A: 28@ += 10@
  293. //28@ += 30
  294. 6@++
  295.  
  296. //if 6@ >= 10 //(could make it variable)
  297. if 002D: 6@ >= 7@ // (int)
  298. then
  299. 005A: 30@ += 10@
  300. //30@ += 30
  301. 30@ += 1
  302. 6@ = 0
  303. 0085: 28@ = 8@
  304. end
  305.  
  306. //alloc 20@ 64
  307. //0AD3: 20@ = "%d %d ind:%d" 1@ 2@ 31@
  308. //0AF8: samp add_message_to_chat 20@ color -1
  309. //free 20@
  310. end
  311.  
  312. if 26@ == 1
  313. then
  314. 26@ = 0
  315. 0B6E: render release_font 3@
  316. 0085: 11@ = 10@ // (int)
  317. 11@ *= 2
  318. 11@ /= 5
  319. 0B6D: render 3@ = create "Verdana" height 11@ flags 9
  320. 0085: 12@ = 10@
  321. 12@ *= 2
  322. 12@ /= 6
  323. end
  324. end
  325.  
  326.  
  327.  
  328. :GetColor
  329. 1@ *= 8
  330. 005A: 0@ += 1@ // (int)
  331. 0A8D: 31@ = read_memory 0@ size 4 virtual_protect 0 //color
  332. 0@+=4
  333. 0A8D: 30@ = read_memory 0@ size 4 virtual_protect 0 //count
  334. ret 2 31@ 30@
  335.  
  336. :AddColor
  337. for 31@ = 0 to 300
  338. 0A8D: 30@ = read_memory 0@ size 4 virtual_protect 0 //read color value
  339.  
  340. if 003B: 1@ == 30@ // compare color value with player color
  341. then
  342. 0@ += 4 //get count address
  343. 0A8D: 29@ = read_memory 0@ size 4 virtual_protect 0 //get count value
  344. 29@ += 1
  345. 0A8C: write_memory 0@ size 4 value 29@ virtual_protect 0
  346. ret 0
  347. end
  348.  
  349. if 30@ == 0
  350. then
  351. 0A8C: write_memory 0@ size 4 value 1@ virtual_protect 0 //add new color
  352. 0@ += 4 //count addr
  353. 0A8C: write_memory 0@ size 4 value 1 virtual_protect 0 //add new color count (1)
  354. ret 0
  355. end
  356.  
  357. 0@ += 8
  358. end
  359. ret 0
  360.  
  361.  
  362.  
  363.  
  364. :ResetArray
  365. for 31@ = 0 to 600 step 8
  366. 0A8C: write_memory 0@ size 8 value 0 virtual_protect 0
  367. 0@ += 8
  368. end
  369. ret 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement