Advertisement
michalmonday

statDisplay.cs

Jul 26th, 2016
540
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.62 KB | None | 0 0
  1. {$CLEO}
  2. 0000:
  3.  
  4. const
  5. FONT = 0@
  6. ID = 1@
  7. PING = 2@
  8. STR_PING = 3@
  9. STR_ZONE = 4@
  10. STR_FPS = 5@
  11. PLAYER_POS_X = 6@
  12. PLAYER_POS_Y = 7@
  13. PLAYER_POS_Z = 8@
  14. FPS_COUNT = 9@
  15. FPS_COUNT_COPY = 10@
  16. SYSTEM_TICK_COUNT = 11@
  17. DISPLAY_POS_X = 12@
  18. DISPLAY_POS_Y = 13@
  19. DISPLAY_POS_Y_BUFF = 14@
  20. TOGGLE_MODE_ADJUSTPOS = 15@
  21. TOGGLE_PING = 16@
  22. TOGGLE_FPS = 17@
  23. TOGGLE_ZONE = 18@
  24. STR_FONT_NAME = 19@
  25. MOD_SWITCH = 20@
  26. FONT_SIZE = 21@
  27. FONT_FLAGS = 22@
  28. TOGGLE_MODE_ADJUSTSIZE = 23@
  29. TOGGLE_MODE_ADJUSTFLAGS = 24@
  30. FONT_SIZE_BUFF = 25@
  31. TEXT_LENGTH = 26@
  32. DISPLAY_POS_X_BUFF = 27@
  33. ALIGNMENT = 28@
  34.  
  35. GTX_ZONENAME = s$93
  36. end
  37.  
  38. alloc STR_PING 64
  39. alloc STR_ZONE 64
  40. alloc STR_FPS 64
  41. alloc STR_FONT_NAME 64
  42.  
  43. repeat
  44. wait 50
  45. until 0AFA: is_samp_available
  46. 0B34: samp register_client_command "sd" to_label @toggle
  47. 0B34: samp register_client_command "sdpos" to_label @adjustpos
  48. 0B34: samp register_client_command "sdhelp" to_label @help
  49. 0B34: samp register_client_command "sdping" to_label @tog_ping
  50. 0B34: samp register_client_command "sdfps" to_label @tog_fps
  51. 0B34: samp register_client_command "sdzone" to_label @tog_zone
  52. 0B34: samp register_client_command "sdflags" to_label @adjustflags
  53. 0B34: samp register_client_command "sdsize" to_label @adjustsize
  54. 0B34: samp register_client_command "sdalign" to_label @changeAlignment
  55. 0AF8: samp add_message_to_chat "{F7F694}statDisplay mod. Use {FF4800}/sdhelp {F7F694}to see commands"
  56.  
  57. /* flags
  58. FCR_NONE 0 Text without features
  59. FCR_BOLD 1 Fat content of the text
  60. FCR_ITALICS 2 Bent (italic) text
  61. FCR_BORDER 4 Dribbling text
  62. FCR_SHADOW 8 text Shadow
  63. FCR_UNDERLINE 16 Underlined text
  64. FCR_STRIKEOUT 32 Strikethrough text
  65. */
  66.  
  67. if 0AAB: file_exists "CLEO\statDisplaySettings.ini"
  68. then
  69. 0AF4: STR_FONT_NAME = read_string_from_ini_file "CLEO\statDisplaySettings.ini" section "Settings" key "font_name"
  70. 0AF0: DISPLAY_POS_X = get_int_from_ini_file "CLEO\statDisplaySettings.ini" section "Settings" key "x"
  71. 0AF0: DISPLAY_POS_Y = get_int_from_ini_file "CLEO\statDisplaySettings.ini" section "Settings" key "y"
  72. 0AF0: MOD_SWITCH = get_int_from_ini_file "CLEO\statDisplaySettings.ini" section "Settings" key "switch"
  73. 0AF0: TOGGLE_PING = get_int_from_ini_file "CLEO\statDisplaySettings.ini" section "Settings" key "ping"
  74. 0AF0: TOGGLE_FPS = get_int_from_ini_file "CLEO\statDisplaySettings.ini" section "Settings" key "fps"
  75. 0AF0: TOGGLE_ZONE = get_int_from_ini_file "CLEO\statDisplaySettings.ini" section "Settings" key "location"
  76. 0AF0: FONT_SIZE = get_int_from_ini_file "CLEO\statDisplaySettings.ini" section "Settings" key "font_size"
  77. 0AF0: FONT_FLAGS = get_int_from_ini_file "CLEO\statDisplaySettings.ini" section "Settings" key "font_flags"
  78. 0AF0: ALIGNMENT = get_int_from_ini_file "CLEO\statDisplaySettings.ini" section "Settings" key "alignment"
  79. else
  80. 0AF8: samp add_message_to_chat "{F7F694}CLEO\statDisplaySettings.ini {FF4800}not found. {F7F694}The mod won't work"
  81. jump @Idle_loop
  82. end
  83.  
  84. 0B6D: render FONT = create STR_FONT_NAME height FONT_SIZE flags FONT_FLAGS
  85.  
  86. while true
  87. wait 0
  88. if MOD_SWITCH == 1
  89. then
  90. 0085: DISPLAY_POS_Y_BUFF = DISPLAY_POS_Y // (int)
  91.  
  92. //adjust modes
  93. if TOGGLE_MODE_ADJUSTPOS == 1
  94. then 0AB1: @Position_stats 2 DISPLAY_POS_X DISPLAY_POS_Y _return DISPLAY_POS_X DISPLAY_POS_Y
  95. end
  96.  
  97. if TOGGLE_MODE_ADJUSTSIZE == 1
  98. then
  99. if 0AB1: @Adjust_Font_Size 1 FONT_SIZE _ret FONT_SIZE
  100. then
  101. 0B6E: render release FONT
  102. 0B6D: render FONT = create STR_FONT_NAME height FONT_SIZE flags FONT_FLAGS
  103. wait 100
  104. end
  105. end
  106.  
  107. if TOGGLE_MODE_ADJUSTFLAGS == 1
  108. then
  109. if 0AB1: @Adjust_Font_Flags 1 FONT_FLAGS _ret FONT_FLAGS
  110. then
  111. 0B6E: render release FONT
  112. 0B6D: render FONT = create_font STR_FONT_NAME height FONT_SIZE flags FONT_FLAGS
  113. wait 100
  114. end
  115. end
  116.  
  117. //texts
  118. if TOGGLE_ZONE == 1
  119. then
  120. 00A0: store_actor $PLAYER_ACTOR position_to PLAYER_POS_X PLAYER_POS_Y PLAYER_POS_Z
  121. 0843: get_zone_at PLAYER_POS_X PLAYER_POS_Y PLAYER_POS_Z nameA_to GTX_ZONENAME
  122. 0ADE: STR_ZONE = text_by_GXT_entry GTX_ZONENAME
  123. if ALIGNMENT == 0 // left
  124. then
  125. 0B6F: render FONT draw_text STR_ZONE of pos DISPLAY_POS_X DISPLAY_POS_Y color 0xFFFFFFFF
  126. else
  127. 0B6B: render TEXT_LENGTH = FONT get_length_of STR_ZONE
  128. if ALIGNMENT == 1 //center
  129. then
  130. 0016: TEXT_LENGTH /= 2
  131. end
  132. 0085: DISPLAY_POS_X_BUFF = DISPLAY_POS_X
  133. 0062: DISPLAY_POS_X_BUFF -= TEXT_LENGTH
  134. 0B6F: render FONT draw_text STR_ZONE of pos DISPLAY_POS_X_BUFF DISPLAY_POS_Y color 0xFFFFFFFF
  135. end
  136. end
  137.  
  138. if TOGGLE_PING == 1
  139. then
  140. 0B2B: samp ID = get_player_id_by_actor_handle $PLAYER_ACTOR
  141. 0B2A: samp PING = get_player_ping ID
  142. 0AD3: STR_PING = format "Ping: %d" PING
  143. 0085: FONT_SIZE_BUFF = FONT_SIZE // (int)
  144. 0012: FONT_SIZE_BUFF *= 10
  145. 0016: FONT_SIZE_BUFF /= 7
  146. 005A: DISPLAY_POS_Y_BUFF += FONT_SIZE_BUFF // (int)
  147. if ALIGNMENT == 0 // left
  148. then
  149. 0B6F: render FONT draw_text STR_PING of pos DISPLAY_POS_X DISPLAY_POS_Y_BUFF color 0xFFFFFFFF
  150. else
  151. 0B6B: render TEXT_LENGTH = FONT get_length_of STR_PING
  152. if ALIGNMENT == 1 //center
  153. then
  154. 0016: TEXT_LENGTH /= 2
  155. end
  156. 0085: DISPLAY_POS_X_BUFF = DISPLAY_POS_X
  157. 0062: DISPLAY_POS_X_BUFF -= TEXT_LENGTH
  158. 0B6F: render FONT draw_text STR_PING of pos DISPLAY_POS_X_BUFF DISPLAY_POS_Y_BUFF color 0xFFFFFFFF
  159. end
  160. end
  161.  
  162. if TOGGLE_FPS == 1
  163. then
  164. FPS_COUNT += 1
  165. if 0AB1: @HalfSecondPassed 1 SYSTEM_TICK_COUNT _ret SYSTEM_TICK_COUNT
  166. then
  167. 0085: FPS_COUNT_COPY = FPS_COUNT // get time interval
  168. 0012: FPS_COUNT_COPY *= 2
  169. FPS_COUNT = 0
  170. end
  171. 0AD3: STR_FPS = format "Fps: %d" FPS_COUNT_COPY
  172. 0085: FONT_SIZE_BUFF = FONT_SIZE // (int)
  173. 0012: FONT_SIZE_BUFF *= 10
  174. 0016: FONT_SIZE_BUFF /= 7
  175. 005A: DISPLAY_POS_Y_BUFF += FONT_SIZE_BUFF // (int)
  176. if ALIGNMENT == 0 // left
  177. then
  178. 0B6F: render FONT draw_text STR_FPS of pos DISPLAY_POS_X DISPLAY_POS_Y_BUFF color 0xFFFFFFFF
  179. else
  180. 0B6B: render TEXT_LENGTH = FONT get_length_of STR_FPS
  181. if ALIGNMENT == 1 //center
  182. then
  183. 0016: TEXT_LENGTH /= 2
  184. end
  185. 0085: DISPLAY_POS_X_BUFF = DISPLAY_POS_X
  186. 0062: DISPLAY_POS_X_BUFF -= TEXT_LENGTH
  187. 0B6F: render FONT draw_text STR_FPS of pos DISPLAY_POS_X_BUFF DISPLAY_POS_Y_BUFF color 0xFFFFFFFF
  188. end
  189. end
  190. end
  191. end
  192.  
  193. :Idle_loop
  194. wait 5000
  195. jump @Idle_loop
  196.  
  197. :changeAlignment
  198. ALIGNMENT++
  199. if ALIGNMENT > 2
  200. then
  201. ALIGNMENT = 0
  202. end
  203. 0AF1: write_int ALIGNMENT to_ini_file "CLEO\statDisplaySettings.ini" section "Settings" key "alignment"
  204. samp.CmdRet()
  205.  
  206. :adjustpos
  207. wait 0
  208. 0B12: TOGGLE_MODE_ADJUSTPOS = TOGGLE_MODE_ADJUSTPOS XOR 1
  209. if TOGGLE_MODE_ADJUSTPOS == 1
  210. then
  211. 0B5D: samp toggle_cursor 1
  212. else
  213. 0B5D: samp toggle_cursor 0
  214. end
  215. samp.CmdRet
  216.  
  217. :adjustsize
  218. 0B12: TOGGLE_MODE_ADJUSTSIZE = TOGGLE_MODE_ADJUSTSIZE XOR 1
  219. if TOGGLE_MODE_ADJUSTSIZE == 0
  220. then
  221. 0AF1: write_int FONT_SIZE to_ini_file "CLEO\statDisplaySettings.ini" section "Settings" key "font_size"
  222. end
  223. samp.CmdRet
  224.  
  225. :adjustflags
  226. 0B12: TOGGLE_MODE_ADJUSTFLAGS = TOGGLE_MODE_ADJUSTFLAGS XOR 1
  227. if TOGGLE_MODE_ADJUSTFLAGS == 0
  228. then
  229. 0AF1: write_int FONT_FLAGS to_ini_file "CLEO\statDisplaySettings.ini" section "Settings" key "font_flags"
  230. end
  231. samp.CmdRet
  232.  
  233. :tog_zone
  234. 0B12: TOGGLE_ZONE = TOGGLE_ZONE XOR 1
  235. 0AF1: write_int TOGGLE_ZONE to_ini_file "CLEO\statDisplaySettings.ini" section "Settings" key "location"
  236. samp.CmdRet
  237.  
  238. :tog_ping
  239. 0B12: TOGGLE_PING = TOGGLE_PING XOR 1
  240. 0AF1: write_int TOGGLE_PING to_ini_file "CLEO\statDisplaySettings.ini" section "Settings" key "ping"
  241. samp.CmdRet
  242.  
  243. :tog_fps
  244. 0B12: TOGGLE_FPS = TOGGLE_FPS XOR 1
  245. 0AF1: write_int TOGGLE_FPS to_ini_file "CLEO\statDisplaySettings.ini" section "Settings" key "fps"
  246. samp.CmdRet
  247.  
  248. /*
  249. :tog_
  250. 0B12: TOGGLE_ = TOGGLE_ XOR 1
  251. 0AF1: write_int 16 to_ini_file "CLEO\statDisplaySettings.ini" section "Settings" key ""
  252. samp.CmdRet
  253. :tog_
  254. 0B12: TOGGLE_ = TOGGLE_ XOR 1
  255. 0AF1: write_int 16 to_ini_file "CLEO\statDisplaySettings.ini" section "Settings" key ""
  256. samp.CmdRet
  257. */
  258.  
  259. :help
  260. 0AF8: samp add_message_to_chat "{FF4800}statDisplay {F7F694}commands:"
  261. 0AF8: samp add_message_to_chat "{FFFFFF}/sd {F7F694}(toggle whole mod)"
  262. 0AF8: samp add_message_to_chat "{FFFFFF}/sdpos {F7F694}(allows to adjust the position of the stats)"
  263. 0AF8: samp add_message_to_chat "{FFFFFF}/sdsize {F7F694}(set size of the font)"
  264. 0AF8: samp add_message_to_chat "{FFFFFF}/sdalign {F7F694}(change text alignment, left, center, right)"
  265. 0AF8: samp add_message_to_chat "{FFFFFF}/sdflags {F7F694}(set flags of the font)"
  266. 0AF8: samp add_message_to_chat "{FFFFFF}/sdzone {F7F694}(toggle location)"
  267. 0AF8: samp add_message_to_chat "{FFFFFF}/sdping {F7F694}(toggle ping)"
  268. 0AF8: samp add_message_to_chat "{FFFFFF}/sdfps {F7F694}(toggle fps)"
  269. samp.CmdRet()
  270.  
  271. :toggle
  272. 0B12: MOD_SWITCH = MOD_SWITCH XOR 1
  273. 0AF1: write_int MOD_SWITCH to_ini_file "CLEO\statDisplaySettings.ini" section "Settings" key "switch"
  274. if MOD_SWITCH == 1
  275. then
  276. FPS_COUNT = 0
  277. FPS_COUNT_COPY = 0
  278. //0A8D: 12@ = read_memory 0xB7CB84 size 4 virtual_protect 0
  279. 0AD1: show_formatted_text_highpriority "statDisplay is ~G~ON" time 700
  280. else
  281. 0AD1: show_formatted_text_highpriority "statDisplay is ~R~OFF" time 700
  282. end
  283. samp.CmdRet()
  284.  
  285. //0AB1: @SecondPassed 1 second 0@ _second 0@
  286. :halfSecondPassed
  287. 0AA2: 2@ = load_library "kernel32.dll" // IF and SET
  288. if 0AA4: 3@ = get_proc_address "GetTickCount" library 2@ // http://www.geoffchappell.com/studies/windows/win32/kernel32/api/index.htm https://msdn.microsoft.com/en-us/library/windows/desktop/ms724408(v=vs.85).aspx
  289. then
  290. 1@ = 0 //GetSystemTimeA results in access violation if the pointer is NULL so just in case it's set to 1 first
  291. //0AA5: call_function 3@ num_params 1 pop 0 1@
  292. 0AA7: call_function 3@ num_params 0 pop 0 31@
  293. 30@ = 0
  294. 0085: 30@ = 31@ //
  295. 0062: 30@ -= 0@ //
  296. if 0019: 30@ >= 500
  297. then
  298. 0085: 0@ = 31@
  299. 0485: return_true
  300. else
  301. 059A: return_false
  302. end
  303. else
  304. 059A: return_false
  305. end
  306. 0AA3: free_library 2@
  307. 0AB2: ret 1 0@
  308.  
  309. //0AB1: @Position_stats 3 XY 26@ 27@
  310. :Position_stats
  311. 0B5D: samp toggle_cursor 1
  312. if key_down 1
  313. then
  314. 0B5E: get_cursor_pos 0@ 1@
  315. //0B5F: convert_window_screen_coords 8@ 9@ to_game_screen_coords 10@ 11@
  316. 0AF1: write_int 0@ to_ini_file "CLEO\statDisplaySettings.ini" section "Settings" key "x"
  317. 0AF1: write_int 1@ to_ini_file "CLEO\statDisplaySettings.ini" section "Settings" key "y"
  318. end
  319. //03E3: set_texture_to_be_drawn_antialiased 6
  320. //03F0: enable_text_draw 1
  321. //038D: draw_texture 6 position 0@ 1@ size 129.142960 45.333576 RGBA 150 150 150 150
  322. 0AD1: show_formatted_text_highpriority "Click anywhere + use /sdpos again to exit editing" time 100 0xF7F694
  323. 0AB2: ret 2 0@ 1@
  324.  
  325. //0AB1: @Adjust_Font_Size 1
  326. :Adjust_Font_Size
  327. 31@ = false
  328. if key_down 104
  329. then
  330. 0@ += 1
  331. 31@ = true
  332. 0485: return_true
  333. else
  334. if key_down 98
  335. then
  336. 0@ -= 1
  337. 31@ = true
  338. end
  339. end
  340. if 001B: 0 > 0@
  341. then
  342. 0@ = 0
  343. else
  344. if 0019: 0@ > 63
  345. then
  346. 0@ = 63
  347. end
  348. end
  349. 0AD1: show_formatted_text_highpriority "Use numpad 8 and 2 to increase/decrease font size + use /sdsize again to exit editing" time 100 0xF7F694
  350. if 31@ == true
  351. then
  352. 0485: return_true
  353. else
  354. 059A: return_false
  355. end
  356. 0AB2: ret 1 0@
  357.  
  358. //0AB1: @Adjust_Font_Flags 1
  359. :Adjust_Font_Flags
  360. 31@ = false
  361. if key_down 104
  362. then
  363. 0@ += 1
  364. 31@ = true
  365. 0485: return_true
  366. else
  367. if key_down 98
  368. then
  369. 0@ -= 1
  370. 31@ = true
  371. end
  372. end
  373. if 001B: 0 > 0@
  374. then
  375. 0@ = 0
  376. else
  377. if 0019: 0@ > 63
  378. then
  379. 0@ = 63
  380. end
  381. end
  382. 0AD1: show_formatted_text_highpriority "Use numpad 8 and 2 to set font flags + use /sdflags again to exit editing" time 100 0xF7F694
  383. if 31@ == true
  384. then
  385. 0485: return_true
  386. else
  387. 059A: return_false
  388. end
  389. 0AB2: ret 1 0@
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement