HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <amxmodx>
  2. #include <fakemeta>
  3.  
  4. #define PLUGIN "Console Icon"
  5. #define VERSION "1.1"
  6. #define AUTHOR "DJ_WEST"
  7.  
  8. #define MAX_PLAYERS 32
  9. #define ICON_TASKID 8912
  10.  
  11. new g_Sprite, bool:g_b_InConsole[MAX_PLAYERS+1], bool:g_b_Connected[MAX_PLAYERS+1]
  12.  
  13. public plugin_init()
  14. {
  15. register_plugin(PLUGIN, VERSION, AUTHOR)
  16.  
  17. register_clcmd("showconsole", "Show_Console")
  18. register_event("HLTV", "New_Round", "a", "1=0", "2=0")
  19. register_forward(FM_CmdStart, "Cmd_Start")
  20. }
  21.  
  22. public plugin_precache()
  23. g_Sprite = precache_model("sprites/console_icon.spr")
  24.  
  25. public Cmd_Start(id, uc_handle, random_seed)
  26. {
  27. if (g_b_InConsole[id])
  28. {
  29. new i_Button
  30. i_Button = get_uc(uc_handle, UC_Buttons)
  31.  
  32. if (i_Button > 0)
  33. {
  34. g_b_InConsole[id] = false
  35. remove_task(id + ICON_TASKID)
  36. Remove_Icon(id)
  37. }
  38. }
  39. }
  40.  
  41. public client_putinserver(id)
  42. {
  43. g_b_Connected[id] = true
  44. g_b_InConsole[id] = false
  45. set_task(5.0, "Bind_Console", id)
  46. }
  47.  
  48. public New_Round()
  49. {
  50. for (new id = 1; id <= MAX_PLAYERS; id++)
  51. Bind_Console(id)
  52. }
  53.  
  54. public Show_Console(id)
  55. {
  56. if (!is_user_alive(id))
  57. return PLUGIN_HANDLED
  58.  
  59. if (g_b_InConsole[id])
  60. {
  61. g_b_InConsole[id] = false
  62. remove_task(id + ICON_TASKID)
  63. Remove_Icon(id)
  64.  
  65. return PLUGIN_HANDLED
  66. }
  67.  
  68. g_b_InConsole[id] = true
  69. Show_Icon(id + ICON_TASKID)
  70. set_task(10.0, "Show_Icon", id + ICON_TASKID, _, _, "b")
  71.  
  72. return PLUGIN_HANDLED
  73. }
  74.  
  75. public Bind_Console(id)
  76. {
  77. if (g_b_Connected[id])
  78. client_cmd(id, "bind ` ^"showconsole;toggleconsole^"")
  79. }
  80.  
  81. public Show_Icon(taskid)
  82. {
  83. new id
  84. id = taskid - ICON_TASKID
  85.  
  86. message_begin(MSG_ALL, SVC_TEMPENTITY)
  87. write_byte(TE_PLAYERATTACHMENT)
  88. write_byte(id)
  89. write_coord(50)
  90. write_short(g_Sprite)
  91. write_short(100)
  92. message_end()
  93. }
  94.  
  95. public Remove_Icon(id)
  96. {
  97. message_begin(MSG_ALL, SVC_TEMPENTITY)
  98. write_byte(TE_KILLPLAYERATTACHMENTS)
  99. write_byte(id)
  100. message_end()
  101. }
  102.  
  103. public client_disconnect(id)
  104. {
  105. g_b_Connected[id] = false
  106. g_b_InConsole[id] = false
  107. remove_task(id + ICON_TASKID)
  108. }
  109.