HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <engine>
  4. #include <csstats>
  5. #include <hamsandwich>
  6.  
  7. #define PLUGIN "Score Admin Info"
  8. #define VERSION "1.1"
  9. #define AUTHOR "vato loco [GE-S]"
  10. #define PLUGIN_CVAR "score_admin_info"
  11.  
  12. #define MAX_PLAYERS 32 + 1
  13. #define MAX_NAME_LENGTH 31 + 1
  14. #define MAX_CVARS 6
  15. #define MAX_CHACHE_CVARS 3
  16. #define MSG_DELAY 90.0
  17. #define ACCESS_HIDE ADMIN_BAN
  18.  
  19. enum { KILLS = 0, DEATH, SCORE_TYPES }
  20. enum { RED = 0, GREEN, BLUE, MSG_COLORS }
  21. enum { POSITIVE = 0, STANDARD ,NEGATIVE, MSG_TYPES }
  22.  
  23. new g_Blank[] = ""
  24. new g_ClassName[] = "sai_info"
  25. new Float:g_fLastMsg
  26. new Float:g_fMsgDelay = MSG_DELAY
  27. new bool:g_bShowScore[MAX_PLAYERS]
  28. new bool:g_bIsAdmin[MAX_PLAYERS]
  29. new bool:g_bIsAlive[MAX_PLAYERS]
  30. new bool:g_bIsConnected[MAX_PLAYERS]
  31. new bool:g_bIsBot[MAX_PLAYERS]
  32. new g_iRank[MAX_PLAYERS]
  33. new g_iPlayerName[MAX_PLAYERS][MAX_NAME_LENGTH]
  34. new g_iScore[MAX_PLAYERS][SCORE_TYPES]
  35. new g_pCvar[MAX_CVARS]
  36. new g_CachepCvar[MAX_CHACHE_CVARS]
  37. new g_iColor[MSG_TYPES][MSG_COLORS]
  38. new g_SyncScoreInfo
  39. new g_iMaxStats
  40. new g_iMaxPlayers
  41.  
  42. public plugin_init()
  43. {
  44. register_plugin(PLUGIN, VERSION, AUTHOR)
  45. register_cvar(PLUGIN_CVAR, VERSION, FCVAR_SERVER|FCVAR_SPONLY, 0.0)
  46.  
  47. register_think(g_ClassName,"ForwardThink")
  48.  
  49. register_event("HLTV", "ev_RoundStart", "a", "1=0", "2=0")
  50. register_event("ScoreInfo", "ev_ScoreInfo", "a")
  51.  
  52. RegisterHam(Ham_Spawn, "player", "client_alive", 1)
  53. RegisterHam(Ham_Killed, "player", "client_alive", 1)
  54.  
  55. register_clcmd("say /statom", "client_showscore")
  56. register_clcmd("say .statom", "client_showscore")
  57. register_clcmd("say /sm", "client_showscore")
  58. register_clcmd("say .sm", "client_showscore")
  59. register_clcmd("say_team /statom", "client_showscore")
  60. register_clcmd("say_team .statom", "client_showscore")
  61. register_clcmd("say_team /sm", "client_showscore")
  62. register_clcmd("say_team .sm", "client_showscore")
  63. register_clcmd("say /elrejt", "client_hide", ACCESS_HIDE)
  64. register_clcmd("say .elrejt", "client_hide", ACCESS_HIDE)
  65. register_clcmd("say_team /elrejt", "client_hide", ACCESS_HIDE)
  66. register_clcmd("say_team .elrejt", "client_hide", ACCESS_HIDE)
  67.  
  68. g_pCvar[0] = register_cvar("sai_enabled", "1")
  69. g_pCvar[1] = register_cvar("sai_show_admin", "1")
  70. g_pCvar[2] = register_cvar("sai_on_join", "1")
  71. g_pCvar[3] = register_cvar("sai_positive_color", "0 160 0")
  72. g_pCvar[4] = register_cvar("sai_standard_color", "255 255 0")
  73. g_pCvar[5] = register_cvar("sai_negative_color", "255 0 0")
  74.  
  75. g_SyncScoreInfo = CreateHudSyncObj()
  76. g_iMaxPlayers = get_maxplayers()
  77.  
  78. new iEnt = create_entity("info_target")
  79. entity_set_string(iEnt, EV_SZ_classname, g_ClassName)
  80. entity_set_float(iEnt, EV_FL_nextthink, get_gametime() + 1.0)
  81. }
  82.  
  83. public plugin_cfg()
  84. {
  85. set_task(0.5, "ev_RoundStart")
  86. }
  87.  
  88. public client_putinserver(id)
  89. {
  90. g_bIsConnected[id] = true
  91. g_bIsBot[id] = bool:is_user_bot(id)
  92. if(!g_bIsBot[id])
  93. {
  94. g_bShowScore[id] = bool:g_CachepCvar[2]
  95. g_bIsAdmin[id] = bool:is_user_admin(id)
  96. }
  97. get_user_name(id, g_iPlayerName[id], 31)
  98. }
  99.  
  100. public client_disconnect(id)
  101. {
  102. g_bIsAlive[id] = false
  103. g_bIsConnected[id] = false
  104. g_bShowScore[id] = false
  105. g_bIsAdmin[id] = false
  106. g_bIsBot[id] = false
  107. }
  108.  
  109. public client_infochanged(id)
  110. {
  111. get_user_info(id, "name", g_iPlayerName[id], 31)
  112. }
  113.  
  114. public client_showscore(id)
  115. {
  116. g_bShowScore[id] = !g_bShowScore[id]
  117. client_print(id, print_center, g_bShowScore[id] ? "Statisztika engedelyezve!" : "Statisztika bezarva!")
  118. }
  119.  
  120. public client_hide(id, lvl, cid)
  121. {
  122. if(!cmd_access(id, lvl, cid, 1))
  123. {
  124. return PLUGIN_HANDLED
  125. }
  126. g_bIsAdmin[id] = !g_bIsAdmin[id]
  127. client_print(id, print_center, g_bIsAdmin[id] ? "Elrejtés feloldva" : "Elrejtes engedelyezve")
  128.  
  129. return PLUGIN_CONTINUE
  130. }
  131.  
  132. public client_alive(id)
  133. {
  134. g_bIsAlive[id] = bool:is_user_alive(id)
  135. }
  136.  
  137. public ev_RoundStart()
  138. {
  139. g_CachepCvar[0] = get_pcvar_num(g_pCvar[0])
  140. g_CachepCvar[1] = get_pcvar_num(g_pCvar[1])
  141. g_CachepCvar[2] = get_pcvar_num(g_pCvar[2])
  142.  
  143. GetCvarColor(g_pCvar[3], g_iColor[POSITIVE][RED], g_iColor[POSITIVE][GREEN], g_iColor[POSITIVE][BLUE])
  144. GetCvarColor(g_pCvar[4], g_iColor[STANDARD][RED], g_iColor[STANDARD][GREEN], g_iColor[STANDARD][BLUE])
  145. GetCvarColor(g_pCvar[5], g_iColor[NEGATIVE][RED], g_iColor[NEGATIVE][GREEN], g_iColor[NEGATIVE][BLUE])
  146.  
  147. new stats[8], bodyhits[8], id
  148. g_iMaxStats = get_statsnum()
  149.  
  150. for(id = 1; id <= g_iMaxPlayers; id++)
  151. {
  152. if(g_bIsConnected[id])
  153. {
  154. g_iRank[id] = get_user_stats(id, stats, bodyhits)
  155. }
  156. }
  157. }
  158.  
  159. public ev_ScoreInfo()
  160. {
  161. g_iScore[read_data(1)][KILLS] = read_data(2)
  162. g_iScore[read_data(1)][DEATH] = read_data(3)
  163. }
  164.  
  165. public ForwardThink(iEnt)
  166. {
  167. if(g_CachepCvar[0])
  168. {
  169. static id, target, specmode
  170.  
  171. for(id = 1; id <= g_iMaxPlayers; id++)
  172. {
  173. if(g_bIsConnected[id])
  174. {
  175. specmode = entity_get_int(id, EV_INT_iuser1)
  176.  
  177. if(g_bIsAlive[id])
  178. {
  179. if(g_bShowScore[id])
  180. {
  181. ShowPlayerInfo(id, g_iScore[id][KILLS], g_iScore[id][DEATH], 0.86, g_Blank, g_Blank, g_iRank[id])
  182. }
  183. }
  184. else if(specmode == 2 || specmode == 4)
  185. {
  186. target = entity_get_int(id, EV_INT_iuser2)
  187. if(target && target != id)
  188. {
  189. ShowPlayerInfo(id, g_iScore[target][KILLS], g_iScore[target][DEATH], 0.81, g_CachepCvar[1] ? g_bIsAdmin[target] ? "| Admin: Stat |" : g_Blank : g_Blank, g_iPlayerName[target], g_iRank[target])
  190. }
  191. }
  192. }
  193. }
  194. }
  195. entity_set_float(iEnt, EV_FL_nextthink, get_gametime() + 0.1)
  196. }
  197.  
  198. ShowPlayerInfo(id, iFrags, iDeath, Float:yPos, sAdmin[], sName[], iRank)
  199. {
  200. if(!g_bIsBot[id])
  201. {
  202. static Float:fEff, Float:fGameTime, r, g, b
  203. fGameTime = get_gametime()
  204. fEff = (100.0 * float(iFrags) / float(iFrags + iDeath))
  205.  
  206. if(iFrags > iDeath)
  207. {
  208. r = g_iColor[POSITIVE][RED]
  209. g = g_iColor[POSITIVE][GREEN]
  210. b = g_iColor[POSITIVE][BLUE]
  211. }
  212. else if(iFrags == iDeath)
  213. {
  214. r = g_iColor[STANDARD][RED]
  215. g = g_iColor[STANDARD][GREEN]
  216. b = g_iColor[STANDARD][BLUE]
  217. }
  218. else if(iFrags < iDeath)
  219. {
  220. r = g_iColor[NEGATIVE][RED]
  221. g = g_iColor[NEGATIVE][GREEN]
  222. b = g_iColor[NEGATIVE][BLUE]
  223. }
  224. if(g_fLastMsg + g_fMsgDelay <= fGameTime)
  225. {
  226. client_print(id, print_chat, g_bShowScore[id] ? "[AMXX] Ird Chat be /statom hogy bezard a statisztikad Hud-ban." : "[AMXX] Ird Chat-be /statom hogy lasd a statod Hud-ban.")
  227. g_fLastMsg = fGameTime
  228. }
  229. set_hudmessage(r, g, b, -1.0, yPos, _, _, 0.2, _, _, -1)
  230. ShowSyncHudMsg(id, g_SyncScoreInfo, "%s^n| Oles: %d | Eff: %0.2f%% | Halal: %d |^n%s Rank: %d of %d", sAdmin, iFrags, fEff, iDeath, sName, iRank, g_iMaxStats)
  231. }
  232. }
  233.  
  234. GetCvarColor(cvar, &r, &g, &b)
  235. {
  236. static colors[16], piece[5]
  237. get_pcvar_string(cvar, colors, 15)
  238.  
  239. strbreak(colors, piece, 4, colors, 15)
  240. r = str_to_num(piece)
  241.  
  242. strbreak(colors, piece, 4, colors, 15)
  243. g = str_to_num(piece)
  244. b = str_to_num(colors)
  245. }
  246. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  247. *{\\ rtf1\\ ansi\\ ansicpg1250\\ deff0\\ deflang1038{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ f0\\ fs16 \n\\ par }
  248. */
  249.