HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <amxmodx>
  2. #include <fakemeta>
  3. #include <fakemeta_util>
  4. #include <hamsandwich>
  5. #include <cstrike>
  6.  
  7. #define PLUGIN "Fegyver Hang"
  8. #define VERSION "1.0"
  9. #define AUTHOR "KCs"
  10.  
  11. enum _:WeaponData
  12. {
  13. WD_WeaponId,
  14. WD_Sound[64],
  15. WD_Anim
  16. }
  17.  
  18. new const g_WeaponData[][WeaponData] =
  19. {
  20. { CSW_AK47, "weapons/fegyver_hangok/ak47.wav", 4 },
  21. { CSW_AUG, "weapons/fegyver_hangok/aug-6.wav", 4 },
  22. { CSW_AWP, "weapons/fegyver_hangok/awp_12yn.wav", 2 },
  23. { CSW_SG552, "weapons/fegyver_hangok/sg552-5.wav", 4 },
  24. { CSW_FAMAS, "weapons/fegyver_hangok/famas-6.wav", 4 },
  25. { CSW_P90, "weapons/fegyver_hangok/p90-2.wav", 4 },
  26. { CSW_MP5NAVY, "weapons/fegyver_hangok/mp5-2.wav", 4 },
  27. { CSW_MAC10, "weapons/fegyver_hangok/mac10.wav", 4 },
  28. { CSW_M249, "weapons/fegyver_hangok/m249.wav", 2 },
  29. { CSW_GLOCK18, "weapons/fegyver_hangok/glock18-12yn.wav", 5 },
  30. { CSW_GALIL, "weapons/fegyver_hangok/galil-2.wav", 4 },
  31. { CSW_DEAGLE, "weapons/fegyver_hangok/deagle_012yn.wav", 2 },
  32. { CSW_SCOUT, "weapons/fegyver_hangok/scout-2.wav", 2 },
  33. { CSW_UMP45, "weapons/fegyver_hangok/ump45-2.wav", 4 },
  34. { CSW_M3, "weapons/fegyver_hangok/m3-2.wav", 2 },
  35. { CSW_P228, "weapons/fegyver_hangok/usp-sesli.wav", 2 },
  36. { CSW_XM1014, "weapons/fegyver_hangok/xm1014-2.wav", 2 }
  37. }
  38.  
  39. new const g_SilencedUSP[] = "weapons/fegyver_hangok/usp-sessiz.wav"
  40. new const g_SilencedM4A1[] = "weapons/fegyver_hangok/m4a1-Susturuculuxx.wav"
  41. new const g_UnsilencedUSP[] = "weapons/fegyver_hangok/usp-sesli.wav"
  42. new const g_UnsilencedM4A1[] = "weapons/fegyver_hangok/m4a4soundwf.wav"
  43.  
  44. public plugin_precache()
  45. {
  46. for (new i = 0; i < sizeof g_WeaponData; i++)
  47. precache_sound(g_WeaponData[i][WD_Sound])
  48.  
  49. precache_sound(g_SilencedUSP)
  50. precache_sound(g_SilencedM4A1)
  51. precache_sound(g_UnsilencedUSP)
  52. precache_sound(g_UnsilencedM4A1)
  53. }
  54.  
  55. public plugin_init()
  56. {
  57. register_plugin(PLUGIN, VERSION, AUTHOR)
  58.  
  59. RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack")
  60. RegisterHam(Ham_TraceAttack, "player", "fw_TraceAttack")
  61.  
  62. register_forward(FM_PlaybackEvent, "fw_PlaybackEvent")
  63. }
  64.  
  65. public fw_PlaybackEvent(flags, id, eventid, Float:delay, Float:origin[3], Float:angles[3],
  66. Float:f1, Float:f2, p1, p2, b1, b2)
  67. {
  68. if (!is_user_alive(id))
  69. return FMRES_IGNORED
  70.  
  71. new weapon = get_user_weapon(id)
  72.  
  73.  
  74. if (!(1 <= weapon <= 30))
  75. return FMRES_IGNORED
  76.  
  77.  
  78. engfunc(EngFunc_PlaybackEvent, flags | FEV_HOSTONLY, id, eventid,
  79. delay, origin, angles, f1, f2, p1, p2, b1, b2)
  80.  
  81.  
  82. for (new i = 0; i < sizeof g_WeaponData; i++)
  83. {
  84. if (weapon == g_WeaponData[i][WD_WeaponId])
  85. {
  86. UTIL_PlayWeaponAnimation(id, g_WeaponData[i][WD_Anim])
  87. emit_sound(id, CHAN_WEAPON, g_WeaponData[i][WD_Sound],
  88. VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  89. return FMRES_SUPERCEDE
  90. }
  91. }
  92.  
  93.  
  94. if (weapon == CSW_M4A1)
  95. {
  96. new ent = fm_get_user_weapon_entity(id, CSW_M4A1)
  97.  
  98. if (cs_get_weapon_silen(ent))
  99. {
  100. UTIL_PlayWeaponAnimation(id, 2)
  101. emit_sound(id, CHAN_WEAPON, g_SilencedM4A1, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  102. }
  103. else
  104. {
  105. UTIL_PlayWeaponAnimation(id, 9)
  106. emit_sound(id, CHAN_WEAPON, g_UnsilencedM4A1, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  107. }
  108.  
  109. return FMRES_SUPERCEDE
  110. }
  111.  
  112.  
  113. if (weapon == CSW_USP)
  114. {
  115. new ent = fm_get_user_weapon_entity(id, CSW_USP)
  116.  
  117. if (cs_get_weapon_silen(ent))
  118. {
  119. UTIL_PlayWeaponAnimation(id, 2)
  120. emit_sound(id, CHAN_WEAPON, g_SilencedUSP, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  121. }
  122. else
  123. {
  124. UTIL_PlayWeaponAnimation(id, 10)
  125. emit_sound(id, CHAN_WEAPON, g_UnsilencedUSP, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  126. }
  127.  
  128. return FMRES_SUPERCEDE
  129. }
  130.  
  131. return FMRES_IGNORED
  132. }
  133.  
  134. stock UTIL_PlayWeaponAnimation(id, anim)
  135. {
  136. set_pev(id, pev_weaponanim, anim)
  137.  
  138. message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = id)
  139. write_byte(anim)
  140. write_byte(pev(id, pev_body))
  141. message_end()
  142. }
  143.  
  144. public fw_TraceAttack(victim, attacker, Float:damage, Float:dir[3], ptr, dmgBits)
  145. {
  146. if (!is_user_connected(attacker))
  147. return HAM_IGNORED
  148.  
  149. new weapon = get_user_weapon(attacker)
  150. if (weapon == CSW_KNIFE)
  151. return HAM_IGNORED
  152.  
  153. static Float:end[3]
  154. get_tr2(ptr, TR_vecEndPos, end)
  155.  
  156. Make_BulletHole(attacker, end, damage)
  157. return HAM_IGNORED
  158. }
  159. stock Make_BulletHole(id, const Float:origin[3], Float:damage)
  160. {
  161. new decal = random_num(41, 45)
  162. new loops = (damage > 100.0) ? 2 : 1
  163.  
  164. for (new i = 0; i < loops; i++)
  165. {
  166. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  167. write_byte(TE_WORLDDECAL)
  168. engfunc(EngFunc_WriteCoord, origin[0])
  169. engfunc(EngFunc_WriteCoord, origin[1])
  170. engfunc(EngFunc_WriteCoord, origin[2])
  171. write_byte(decal)
  172. message_end()
  173.  
  174. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  175. write_byte(TE_GUNSHOTDECAL)
  176. engfunc(EngFunc_WriteCoord, origin[0])
  177. engfunc(EngFunc_WriteCoord, origin[1])
  178. engfunc(EngFunc_WriteCoord, origin[2])
  179. write_short(id)
  180. write_byte(decal)
  181. message_end()
  182. }
  183. }
  184.