HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include < amxmodx >
  2. #include < amxmisc >
  3. #include < fakemeta >
  4. #include < hamsandwich >
  5.  
  6. #define PLUGIN "Info Message HUD"
  7. #define VERSION "1.3"
  8. #define AUTHOR "Blizzard/guipatinador"
  9.  
  10. new const szColors[ ][ ] = {
  11. "white",
  12. "red",
  13. "green",
  14. "blue",
  15. "aqua",
  16. "purple",
  17. "orange",
  18. "yellow",
  19. "gold",
  20. "silver"
  21. }
  22.  
  23. new const COLORS[ ][ ] = {
  24. { 255, 255, 255 },
  25. { 255, 0, 0 },
  26. { 0, 255, 0 },
  27. { 0, 0, 255 },
  28. { 0, 255, 255 },
  29. { 255, 0, 255 },
  30. { 255, 170, 0 },
  31. { 255, 255, 0 },
  32. { 212, 255, 0 },
  33. { 210, 210, 210 }
  34. }
  35.  
  36. enum _:Structure {
  37. iRedValue,
  38. iGreenValue,
  39. iBlueValue,
  40. }
  41.  
  42. new g_HudColors[ Structure ]
  43.  
  44. enum ( += 1 ) {
  45. ALIVE = 1,
  46. DEAD,
  47. ALL
  48. }
  49.  
  50. new Trie:g_tColors
  51. new Trie:g_tClassName
  52.  
  53. new g_szClassName[ ] = "Timer"
  54. new g_szMapName[ 32 ]
  55. new g_szHostname[ 64 ]
  56.  
  57. new g_pcvarHudType
  58.  
  59. new bool:g_IsAlive[ 33 ]
  60.  
  61. new x_pos, y_pos;
  62.  
  63. public plugin_init( )
  64. {
  65. register_plugin( PLUGIN, VERSION, AUTHOR )
  66.  
  67. get_mapname( g_szMapName, charsmax( g_szMapName ) )
  68. get_cvar_string( "hostname", g_szHostname, charsmax( g_szHostname ) )
  69.  
  70. register_concmd( "hud_color", "ChangeColor", ADMIN_RCON, "white or red or green or blue" )
  71.  
  72. x_pos = register_cvar("hud_x_pos", "-1.0");
  73. y_pos = register_cvar("hud_y_pos", "0.0");
  74.  
  75. g_pcvarHudType = register_cvar( "hud_type", "3" )
  76. // 1 = csak az élő embereknek
  77. // 2 = csak a halott embereknek
  78. // 3 = mindenkinek
  79.  
  80. g_tColors = TrieCreate( )
  81.  
  82. new i
  83. for( i = 0; i < sizeof COLORS; i++ )
  84. {
  85. TrieSetCell( g_tColors, szColors[ i ], i )
  86. }
  87.  
  88. g_tClassName = TrieCreate( )
  89. TrieSetCell( g_tClassName, g_szClassName, 1 )
  90.  
  91. new iEnt = engfunc( EngFunc_CreateNamedEntity, engfunc( EngFunc_AllocString,"info_target" ) )
  92. set_pev( iEnt, pev_classname, g_szClassName )
  93. set_pev( iEnt, pev_nextthink, 1.0 )
  94.  
  95. RegisterHam( Ham_Spawn, "player", "FwdPlayerSpawnPost", 1 )
  96. RegisterHam( Ham_Killed, "player", "FwdPlayerKilledPost", 1 )
  97.  
  98. register_forward( FM_Think,"ForwardThink" )
  99. }
  100.  
  101. public plugin_cfg( )
  102. {
  103. server_cmd( "hud_color white" )
  104. }
  105.  
  106. public client_connect( id )
  107. {
  108. g_IsAlive[ id ] = false
  109. }
  110.  
  111.  
  112. public FwdPlayerSpawnPost( id )
  113. {
  114. if( is_user_alive( id ) )
  115. {
  116. g_IsAlive[ id ] = true
  117. }
  118. }
  119.  
  120. public FwdPlayerKilledPost( iVictim )
  121. {
  122. g_IsAlive[ iVictim ] = false
  123. }
  124.  
  125. public ChangeColor( id, level, cid )
  126. {
  127. if ( !cmd_access( id, level, cid, 2 ) )
  128. return PLUGIN_HANDLED
  129.  
  130. static szColor[ 16 ]
  131. read_argv( 1, szColor, charsmax( szColor ) )
  132.  
  133. strtolower( szColor )
  134.  
  135. static iPos
  136. if( TrieGetCell( g_tColors, szColor, iPos ) )
  137. {
  138. g_HudColors[ iRedValue ] = COLORS[ iPos ][ 0 ]
  139. g_HudColors[ iGreenValue ] = COLORS[ iPos ][ 1 ]
  140. g_HudColors[ iBlueValue ] = COLORS[ iPos ][ 2 ]
  141.  
  142. console_print( id, "HUD szin modositva erre: %s", szColor )
  143. }
  144.  
  145. else
  146. {
  147. console_print( id, "%s ervenytelen szin!", szColor )
  148. }
  149.  
  150. return PLUGIN_HANDLED
  151. }
  152.  
  153. public ForwardThink( iEnt )
  154. {
  155. static szClassName[ 32 ]
  156. pev( iEnt, pev_classname, szClassName, charsmax( szClassName ) )
  157.  
  158. if( !TrieKeyExists( g_tClassName, szClassName ) )
  159. return FMRES_IGNORED
  160.  
  161. new iHudType = get_pcvar_num( g_pcvarHudType )
  162.  
  163. new Players[ 32 ]
  164. new iNum
  165. new i
  166.  
  167. get_players( Players, iNum, "ch" )
  168.  
  169. for( --iNum; iNum >= 0; iNum-- )
  170. {
  171. i = Players[ iNum ]
  172.  
  173. switch( iHudType )
  174. {
  175. case ALIVE:
  176. {
  177. if( g_IsAlive[ i ] )
  178. {
  179. ShowTimer( i )
  180. }
  181. }
  182.  
  183. case DEAD:
  184. {
  185. if( !g_IsAlive[ i ] )
  186. {
  187. ShowTimer( i )
  188. }
  189. }
  190.  
  191. case ALL:
  192. {
  193. ShowTimer( i )
  194. }
  195. }
  196. }
  197.  
  198.  
  199. static Float:fGlobalTime
  200. global_get( glb_time, fGlobalTime )
  201.  
  202. set_pev( iEnt, pev_nextthink, fGlobalTime + 1.0 )
  203.  
  204. return FMRES_IGNORED
  205. }
  206.  
  207. public ShowTimer( id )
  208. {
  209. new iTimeLeft = get_timeleft( )
  210.  
  211. set_hudmessage( g_HudColors[ iRedValue ], g_HudColors[ iGreenValue ], g_HudColors[ iBlueValue ], get_pcvar_float(x_pos), get_pcvar_float(y_pos), 0, 0.0, 1.0 )
  212. show_hudmessage( id, "Hátralévő idő: %d:%02d | %s | Pálya: %s", iTimeLeft / 60, iTimeLeft % 60, g_szHostname, g_szMapName )
  213. }
  214.