Guest User

Playback Counter 2

a guest
Nov 20th, 2025
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | Source Code | 0 0
  1. desc:Playback Counter
  2.  
  3. @init
  4. ext_noinit = 1;
  5. playback_count = 0;
  6. last_play_state = 0;
  7.  
  8. @block
  9. // Check play state changes
  10. current_play_state = play_state;
  11.  
  12. // Detect when playback starts
  13. current_play_state == 1 && last_play_state != 1 ? (
  14. playback_count += 1;
  15. );
  16. last_play_state = current_play_state;
  17.  
  18. @gfx 200 100
  19.  
  20. // Set minimum size
  21. gfx_w = max(gfx_w, 200);
  22. gfx_h = max(gfx_h, 100);
  23.  
  24. // Deep slate background (dark blue-gray)
  25. gfx_r = 0.15;
  26. gfx_g = 0.20;
  27. gfx_b = 0.25;
  28. gfx_a = 1;
  29. gfx_rect(0, 0, gfx_w, gfx_h);
  30.  
  31. // Set white text color
  32. gfx_r = 1;
  33. gfx_g = 1;
  34. gfx_b = 1;
  35. gfx_a = 1;
  36.  
  37. // Calculate font size based on window size
  38. font_size = min(gfx_w * 0.15, gfx_h * 0.4);
  39. font_size = max(font_size, 12);
  40. gfx_setfont(1, "Arial", font_size);
  41.  
  42. // Format the count text
  43. count_text = sprintf(#, "%d", playback_count);
  44.  
  45. // Calculate text position (centered)
  46. str_width = 0;
  47. str_height = 0;
  48. gfx_measurestr(count_text, str_width, str_height);
  49. text_x = (gfx_w - str_width) * 0.5;
  50. text_y = (gfx_h - str_height) * 0.5;
  51.  
  52. // Draw the count
  53. gfx_x = text_x;
  54. gfx_y = text_y;
  55. gfx_drawstr(count_text);
  56.  
  57. // Draw label below the count
  58. label_font_size = font_size * 0.4;
  59. gfx_setfont(1, "Arial", label_font_size);
  60. label_text = "Playback Count";
  61. label_width = 0;
  62. label_height = 0;
  63. gfx_measurestr(label_text, label_width, label_height);
  64. label_x = (gfx_w - label_width) * 0.5;
  65. label_y = text_y + str_height + 5;
  66. gfx_x = label_x;
  67. gfx_y = label_y;
  68. gfx_drawstr(label_text);
Advertisement
Add Comment
Please, Sign In to add comment