timer menu! test


SUBMITTED BY: daniptvk

DATE: June 1, 2016, 7:30 p.m.

FORMAT: autohotkey

SIZE: 3.3 kB

HITS: 3553

  1. /*
  2. * Plugin generated by AMXX-Studio
  3. * Plugin create by Hisence
  4. */
  5. #include <amxmodx>
  6. #define PLUGIN "Timer menu"
  7. #define VERSION "1.0"
  8. #define AUTHOR "Hisence"
  9. const TASK_TIMER = 8080;
  10. new szPrefix[] = "Amxx";
  11. new Float:g_fTimer[2];
  12. public plugin_init()
  13. {
  14. register_plugin(PLUGIN, VERSION, AUTHOR)
  15. register_clcmd("say /timer", "TimerMenu")
  16. }
  17. public TimerMenu(id)
  18. {
  19. if(get_user_team(id) != 2 || !is_user_alive(id))
  20. return client_print(id, print_chat, "[%s] You cannot use this command!", szPrefix);
  21. new menu,Text[40];
  22. formatex(Text, 39, "\r%s\w Timer menu:", szPrefix);
  23. menu = menu_create(Text, "SubTimer");
  24. menu_additem(menu, "Start timer");
  25. menu_additem(menu, "Stop timer");
  26. menu_additem(menu, "\yReset timer");
  27. menu_display(id, menu);
  28. return 1;
  29. }
  30. public SubTimer(id, menu, item)
  31. {
  32. switch(item)
  33. {
  34. case 0:
  35. {
  36. if(g_fTimer[0] > 0.0)
  37. client_print(id, print_chat, "[%s] Timer is already running", szPrefix);
  38. else
  39. {
  40. client_print(0, print_chat, "[%s] %s started the timer", szPrefix, get_name(id));
  41. set_task(0.1, "CreateTimer",TASK_TIMER,_,_, "b");
  42. }
  43. menu_display(id, menu);
  44. }
  45. case 1:
  46. {
  47. if(g_fTimer[0] > 0.0)
  48. {
  49. remove_task(TASK_TIMER);
  50. client_print(0, print_chat, "[%s] %s stoped the timer at %.1f", szPrefix, get_name(id), g_fTimer[0]);
  51. g_fTimer[1] = g_fTimer[0];
  52. g_fTimer[0] = 0.0;
  53. }
  54. else
  55. client_print(id, print_chat, "[%s] The timer isnt started yet!", szPrefix);
  56. menu_display(id, menu);
  57. }
  58. case 2:
  59. {
  60. if(g_fTimer[0] > 0.0)
  61. {
  62. client_print(0, print_chat, "[%s] %s reset the timer at %.1f", szPrefix, get_name(id), g_fTimer[0]);
  63. g_fTimer[1] = 0.0;
  64. g_fTimer[0] = 0.0;
  65. }
  66. else
  67. client_print(id, print_chat, "[%s] The timer isnt started yet!", szPrefix);
  68. menu_display(id, menu);
  69. }
  70. }
  71. }
  72. public CreateTimer()
  73. {
  74. g_fTimer[0] += 0.1;
  75. set_hudmessage(0, 170, 255, 0.0, 0.75, 0, 6.0, 0.1)
  76. show_hudmessage(0, "Timer Menu:^nTime: %.1f^nLast reset: %.1f",g_fTimer[0], g_fTimer[1])
  77. }
  78. stock get_name( index )
  79. {
  80. new szName[32];
  81. get_user_name(index, szName, 31);
  82. return szName;
  83. }

comments powered by Disqus