HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <amxmodx>
  2. #include <hamsandwich>
  3. #include <fakemeta>
  4. #include <engine>
  5.  
  6. #define PLUGIN "Chat Icon"
  7. #define VERSION "1.0"
  8. #define AUTHOR "DJ_WEST"
  9.  
  10. #define CHAT_ICON "sprites/chat_icon1.spr"
  11. #define BIND_TASKID 7829
  12. #define ICON_SIZE 0.47
  13. #define ICON_ALPHA 255
  14.  
  15. new bool:g_b_PlayerInChat[33]
  16. new HamHook:g_h_PlayerPostThink[33]
  17. new g_PlayerIcon[33]
  18. new g_InfoTarget
  19.  
  20. public plugin_init()
  21. {
  22. register_plugin(PLUGIN, VERSION, AUTHOR)
  23.  
  24. register_clcmd("chat", "Start_Chat")
  25. register_clcmd("chat_team", "Start_Chat")
  26. register_clcmd("say", "Check_Chat")
  27. register_clcmd("say_team", "Check_Chat")
  28.  
  29. g_InfoTarget = engfunc(EngFunc_AllocString, "info_target")
  30. }
  31.  
  32. public plugin_precache()
  33. precache_model(CHAT_ICON)
  34.  
  35. public client_putinserver(id)
  36. {
  37. if (is_user_bot(id) || is_user_hltv(id))
  38. return
  39.  
  40. g_b_PlayerInChat[id] = false
  41. g_PlayerIcon[id] = 0
  42. set_task(5.0, "Bind_Delay", id + BIND_TASKID)
  43. }
  44.  
  45. public client_disconnect(id)
  46. remove_task(id + BIND_TASKID)
  47.  
  48. public Bind_Delay(taskid)
  49. {
  50. static id
  51.  
  52. id = taskid - BIND_TASKID
  53. client_cmd(id, "bind y ^"chat;messagemode^";bind u ^"chat_team;messagemode2")
  54. }
  55.  
  56. public Start_Chat(id)
  57. {
  58. g_b_PlayerInChat[id] = true
  59.  
  60. Enable_Icon(id)
  61.  
  62. if (g_h_PlayerPostThink[id])
  63. EnableHamForward(g_h_PlayerPostThink[id])
  64. else
  65. g_h_PlayerPostThink[id] = RegisterHamFromEntity(Ham_Player_PostThink, id, "Player_Moving", 1)
  66.  
  67. return PLUGIN_HANDLED
  68. }
  69.  
  70. public Player_Moving(id)
  71. {
  72. static i_Buttons
  73.  
  74. i_Buttons = pev(id, pev_button)
  75.  
  76. if (i_Buttons)
  77. Disable_Icon(id)
  78. }
  79.  
  80. public Check_Chat(id)
  81. {
  82. if (g_b_PlayerInChat[id])
  83. Disable_Icon(id)
  84. }
  85.  
  86. public Enable_Icon(id)
  87. {
  88. new i_Ent
  89.  
  90. i_Ent = engfunc(EngFunc_CreateNamedEntity, g_InfoTarget)
  91. engfunc(EngFunc_SetModel, i_Ent, CHAT_ICON)
  92. set_pev(i_Ent, pev_aiment, id)
  93. set_pev(i_Ent, pev_movetype, MOVETYPE_FOLLOW)
  94. set_pev(i_Ent, pev_scale, ICON_SIZE)
  95. set_rendering(i_Ent, kRenderFxNone, 0, 0, 0, kRenderTransAlpha, ICON_ALPHA)
  96. g_PlayerIcon[id] = i_Ent
  97. }
  98.  
  99. public Disable_Icon(id)
  100. {
  101. static i_Ent
  102.  
  103. if (g_h_PlayerPostThink[id])
  104. DisableHamForward(g_h_PlayerPostThink[id])
  105.  
  106. g_b_PlayerInChat[id] = false
  107.  
  108. i_Ent = g_PlayerIcon[id]
  109.  
  110. if (i_Ent && pev_valid(i_Ent))
  111. remove_entity(i_Ent)
  112. }
  113.