HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /* Formatright © 2009, ConnorMcLeod
  2.  
  3. TraceAttack is free software;
  4. you can redistribute it and/or modify it under the terms of the
  5. GNU General Public License as published by the Free Software Foundation.
  6.  
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11.  
  12. You should have received a copy of the GNU General Public License
  13. along with TraceAttack; if not, write to the
  14. Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  15. Boston, MA 02111-1307, USA.
  16. */
  17.  
  18. /************** CUSTOMIZATION AREA ***************/
  19.  
  20. #define TMP_IS_A_SILENCED_WEAPON // TMP tompítós fegyvernek számítson-e
  21. #define PER_PLAYER_SETTINGS // Játékosoknént állítható
  22.  
  23. /*********** END OF CUSTOMIZATION AREA ***********/
  24.  
  25. #include <amxmodx>
  26. #include <cstrike>
  27. #include <fakemeta>
  28. #include <hamsandwich>
  29.  
  30. #define VERSION "1.3.0"
  31.  
  32. #define MAX_PLAYERS 32
  33. #define IsPlayer(%1) ( 1 <= %1 <= g_iMaxPlayers )
  34. #define write_coord_f(%1) engfunc(EngFunc_WriteCoord,%1)
  35.  
  36. #define m_pActiveItem 373
  37.  
  38. const GUNS_BITSUM = ((1<<CSW_P228)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN)|(1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE))
  39. const SHOTGUNS_BITSUM = ((1<<CSW_XM1014)|(1<<CSW_M3))
  40. const SMGS_BITSUM = ((1<<CSW_MAC10)|(1<<CSW_UMP45)|(1<<CSW_MP5NAVY)|(1<<CSW_TMP)|(1<<CSW_P90))
  41. const RIFFLES_BITSUM = ((1<<CSW_AUG)|(1<<CSW_GALIL)|(1<<CSW_FAMAS)|(1<<CSW_M249)|(1<<CSW_M4A1)|(1<<CSW_SG552)|(1<<CSW_AK47))
  42. const SNIPERS_BITSUM = ((1<<CSW_SCOUT)|(1<<CSW_SG550)|(1<<CSW_AWP)|(1<<CSW_G3SG1))
  43.  
  44. const SILEN_BITSUM = ((1<<CSW_USP)|(1<<CSW_M4A1))
  45.  
  46. enum _:PcvarsNum {
  47. HandGuns = 0,
  48. ShotGuns,
  49. SmgGuns,
  50. RiffleGuns,
  51. SnipeGuns
  52. }
  53.  
  54. new const g_iWeaponBitSumList[] = { GUNS_BITSUM , SHOTGUNS_BITSUM , SMGS_BITSUM , RIFFLES_BITSUM , SNIPERS_BITSUM }
  55.  
  56. new g_iMaxPlayers
  57. new Trie:g_tClassNames
  58.  
  59. new g_pCvar[PcvarsNum], g_pCvarTraceEnabled, g_pCvarTraceHideSilen
  60.  
  61. #if defined PER_PLAYER_SETTINGS
  62. new g_bHltv[MAX_PLAYERS+1], g_bSeeTracers[MAX_PLAYERS+1]
  63. new g_pCvarTraceHltv
  64. #endif
  65.  
  66. public plugin_precache()
  67. {
  68. g_tClassNames = TrieCreate()
  69.  
  70. RegisterHam(Ham_TraceAttack, "worldspawn", "TraceAttack", 1)
  71. TrieSetCell(g_tClassNames, "worldspawn", 1)
  72. RegisterHam(Ham_TraceAttack, "player", "TraceAttack", 1)
  73. TrieSetCell(g_tClassNames, "player", 1)
  74.  
  75. register_forward(FM_Spawn, "Spawn", 1)
  76. }
  77.  
  78. public Spawn( iEnt )
  79. {
  80. if( pev_valid(iEnt) )
  81. {
  82. static szClassName[32]
  83. pev(iEnt, pev_classname, szClassName, charsmax(szClassName))
  84. if( !TrieKeyExists(g_tClassNames, szClassName) )
  85. {
  86. RegisterHam(Ham_TraceAttack, szClassName, "TraceAttack", 1)
  87. TrieSetCell(g_tClassNames, szClassName, 1)
  88. }
  89. }
  90. }
  91.  
  92. public plugin_end()
  93. {
  94. TrieDestroy(g_tClassNames)
  95. }
  96.  
  97. public plugin_init()
  98. {
  99. register_plugin("Advanced Weapon Tracers", VERSION, "ConnorMcLeod")
  100. register_cvar("awt_version", VERSION, FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_SPONLY)
  101.  
  102. g_pCvarTraceEnabled = register_cvar("amx_tracers", "1")
  103.  
  104. g_pCvar[HandGuns] = register_cvar("amx_trace_handguns", "1")
  105. g_pCvar[ShotGuns] = register_cvar("amx_trace_shotguns", "1")
  106. g_pCvar[SmgGuns] = register_cvar("amx_trace_smgguns", "1")
  107. g_pCvar[RiffleGuns] = register_cvar("amx_trace_riffleguns", "1")
  108. g_pCvar[SnipeGuns] = register_cvar("amx_trace_snipeguns", "1")
  109.  
  110. g_pCvarTraceHideSilen = register_cvar("amx_trace_hide_silen", "1")
  111.  
  112. #if defined PER_PLAYER_SETTINGS
  113. g_pCvarTraceHltv = register_cvar("amx_trace_hltv", "0")
  114. register_clcmd("say /tracers", "ClientCommand_Tracers")
  115. #endif
  116.  
  117. g_iMaxPlayers = get_maxplayers()
  118. }
  119.  
  120. #if defined PER_PLAYER_SETTINGS
  121. public client_putinserver(id)
  122. {
  123. g_bSeeTracers[id] = !is_user_bot(id)
  124. g_bHltv[id] = is_user_hltv(id)
  125. //set_task(85.0, "TaskAnnouncement", id)
  126. }
  127.  
  128. public ClientCommand_Tracers(id)
  129. {
  130. client_print(id, print_chat, "** [AWT] Tölténycsíkok %s",
  131. (g_bSeeTracers[id] = !g_bSeeTracers[id]) ? "Be" : "Ki")
  132. return PLUGIN_HANDLED
  133. }
  134.  
  135. public TaskAnnouncement(id)
  136. {
  137. client_print(id, print_chat, "** [AWT] [Be/ki]tudod kapcsolni a tölténycsíkokat a /tracers paranccsal.")
  138. }
  139. #endif
  140.  
  141. public TraceAttack(iEnt, iAttacker, Float:flDamage, Float:fDir[3], ptr, iDamageType)
  142. {
  143. if( !IsPlayer(iAttacker) || get_pcvar_num(g_pCvarTraceEnabled) == 0 )
  144. {
  145. return
  146. }
  147.  
  148. new iWeapon = get_user_weapon(iAttacker)
  149. if( iWeapon == CSW_KNIFE )
  150. {
  151. return
  152. }
  153.  
  154. new bWeapon = (1<<iWeapon)
  155. for(new a; a<sizeof(g_iWeaponBitSumList); a++)
  156. {
  157. if( bWeapon & g_iWeaponBitSumList[a] )
  158. {
  159. if( get_pcvar_num(g_pCvar[a]) )
  160. {
  161. break
  162. }
  163. else
  164. {
  165. return
  166. }
  167. }
  168. }
  169.  
  170. if( SILEN_BITSUM & bWeapon )
  171. {
  172. if( get_pcvar_num(g_pCvarTraceHideSilen) )
  173. {
  174. if( cs_get_weapon_silen(get_pdata_cbase(iAttacker, m_pActiveItem)) )
  175. {
  176. return
  177. }
  178. }
  179. }
  180. #if defined TMP_IS_A_SILENCED_WEAPON
  181. else if( iWeapon == CSW_TMP && get_pcvar_num(g_pCvarTraceHideSilen) )
  182. {
  183. return
  184. }
  185. #endif
  186.  
  187. new iOrigin[3], Float:flEnd[3]
  188.  
  189. get_user_origin(iAttacker, iOrigin, 1)
  190. get_tr2(ptr, TR_vecEndPos, flEnd)
  191.  
  192. #if defined PER_PLAYER_SETTINGS
  193. new iPlayers[MAX_PLAYERS], iNum, iPlayer, bHltv
  194. new x = iOrigin[0], y = iOrigin[1], z = iOrigin[2]
  195. new Float:fX = flEnd[0], Float:fY = flEnd[1], Float:fZ = flEnd[2]
  196. get_players(iPlayers, iNum)
  197. for(new i; i<iNum; i++)
  198. {
  199. iPlayer = iPlayers[i]
  200. if( g_bHltv[iPlayer] )
  201. {
  202. if( !bHltv && get_pcvar_num(g_pCvarTraceHltv) == 1 )
  203. {
  204. bHltv = true
  205. message_begin(MSG_SPEC, SVC_TEMPENTITY)
  206. write_byte(TE_TRACER)
  207. write_coord(x)
  208. write_coord(y)
  209. write_coord(z)
  210. write_coord_f(fX)
  211. write_coord_f(fY)
  212. write_coord_f(fZ)
  213. message_end()
  214. }
  215. }
  216. else if( g_bSeeTracers[iPlayer] )
  217. {
  218. message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, iPlayer)
  219. write_byte(TE_TRACER)
  220. write_coord(x)
  221. write_coord(y)
  222. write_coord(z)
  223. write_coord_f(fX)
  224. write_coord_f(fY)
  225. write_coord_f(fZ)
  226. message_end()
  227. }
  228. }
  229. #else
  230. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  231. write_byte(TE_TRACER)
  232. write_coord(iOrigin[0])
  233. write_coord(iOrigin[1])
  234. write_coord(iOrigin[2])
  235. write_coord_f(flEnd[0])
  236. write_coord_f(flEnd[1])
  237. write_coord_f(flEnd[2])
  238. message_end()
  239. #endif
  240. }