HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <amxmodx>
  2. #include <fakemeta>
  3. #include <engine>
  4. #include <xs>
  5.  
  6. #define MAX_SOUNDS 5
  7. new g_BulletSounds[MAX_SOUNDS][] =
  8. {
  9. "misc/whizz1.wav",
  10. "misc/whizz2.wav",
  11. "misc/whizz3.wav",
  12. "misc/whizz4.wav",
  13. "misc/whizz5.wav"
  14. }
  15.  
  16. new g_LastWeapon[33]
  17. new g_LastAmmo[33]
  18.  
  19. new PLUGIN_NAME[] = "Bullet Whizz"
  20. new PLUGIN_AUTHOR[] = "Cheap_Suit"
  21. new PLUGIN_VERSION[] = "1.4"
  22.  
  23. public plugin_init()
  24. {
  25. register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
  26. register_event("CurWeapon", "Event_CurWeapon", "be", "1=1")
  27. register_cvar("amx_bulletwhizz_dis", "40")
  28. register_cvar("amx_bulletwhizz", "1")
  29. }
  30.  
  31. public plugin_precache()
  32. {
  33. for(new i = 0; i < MAX_SOUNDS; ++i) {
  34. precache_sound(g_BulletSounds[i])
  35. }
  36. }
  37.  
  38. public Event_CurWeapon(id)
  39. {
  40. if(!get_cvar_num("amx_bulletwhizz") || !is_user_connected(id) || !is_user_alive(id)) {
  41. return PLUGIN_CONTINUE
  42. }
  43.  
  44. new WeaponID = read_data(2), Clip = read_data(3)
  45. switch(WeaponID) {
  46. case CSW_HEGRENADE, CSW_FLASHBANG, CSW_SMOKEGRENADE, CSW_C4, CSW_KNIFE: return PLUGIN_CONTINUE
  47. }
  48.  
  49. if(g_LastWeapon[id] == WeaponID && g_LastAmmo[id] > Clip)
  50. {
  51. new Players[32], iNum
  52. get_players(Players, iNum, "a")
  53. for(new i = 0; i < iNum; ++i) if(id != Players[i])
  54. {
  55. new target = Players[i]
  56. new Float:fOrigin[2][3], temp[3], Float:fAim[3]
  57. entity_get_vector(id, EV_VEC_origin, fOrigin[0])
  58. entity_get_vector(target, EV_VEC_origin, fOrigin[1])
  59.  
  60. get_user_origin(id, temp, 3)
  61. IVecFVec(temp, fAim)
  62.  
  63. new iDistance = get_distance_to_line(fOrigin[0], fOrigin[1], fAim)
  64. if(iDistance > get_cvar_num("amx_bulletwhizz_dis") || iDistance < 0
  65. || !fm_is_ent_visible(id, target)) {
  66. continue
  67. }
  68.  
  69. new RandomSound[64]
  70. format(RandomSound, 63, "%s", g_BulletSounds[random_num(0, MAX_SOUNDS-1)])
  71. client_cmd(target, "spk %s", RandomSound)
  72. }
  73. }
  74. g_LastWeapon[id] = WeaponID
  75. g_LastAmmo[id] = Clip
  76.  
  77. return PLUGIN_CONTINUE
  78. }
  79.  
  80. stock get_distance_to_line(Float:pos_start[3], Float:pos_end[3], Float:pos_object[3])
  81. {
  82. new Float:vec_start_end[3], Float:vec_start_object[3], Float:vec_end_object[3], Float:vec_end_start[3]
  83. xs_vec_sub(pos_end, pos_start, vec_start_end) // vector from start to end
  84. xs_vec_sub(pos_object, pos_start, vec_start_object) // vector from end to object
  85. xs_vec_sub(pos_start, pos_end, vec_end_start) // vector from end to start
  86. xs_vec_sub(pos_end, pos_object, vec_end_object) // vector object to end
  87.  
  88. new Float:len_start_object = getVecLen(vec_start_object)
  89. new Float:angle_start = floatacos(xs_vec_dot(vec_start_end, vec_start_object) / (getVecLen(vec_start_end) * len_start_object), degrees)
  90. new Float:angle_end = floatacos(xs_vec_dot(vec_end_start, vec_end_object) / (getVecLen(vec_end_start) * getVecLen(vec_end_object)), degrees)
  91.  
  92. if(angle_start <= 90.0 && angle_end <= 90.0)
  93. return floatround(len_start_object * floatsin(angle_start, degrees))
  94. return -1
  95. }
  96.  
  97. stock Float:getVecLen(Float:Vec[3])
  98. {
  99. new Float:VecNull[3] = {0.0, 0.0, 0.0}
  100. new Float:len = get_distance_f(Vec, VecNull)
  101. return len
  102. }
  103.  
  104. stock bool:fm_is_ent_visible(index, entity)
  105. {
  106. new Float:origin[3], Float:view_ofs[3], Float:eyespos[3]
  107. pev(index, pev_origin, origin)
  108. pev(index, pev_view_ofs, view_ofs)
  109. xs_vec_add(origin, view_ofs, eyespos)
  110.  
  111. new Float:entpos[3]
  112. pev(entity, pev_origin, entpos)
  113. engfunc(EngFunc_TraceLine, eyespos, entpos, 0, index)
  114.  
  115. switch (pev(entity, pev_solid)) {
  116. case SOLID_BBOX..SOLID_BSP: return global_get(glb_trace_ent) == entity
  117. }
  118.  
  119. new Float:fraction
  120. global_get(glb_trace_fraction, fraction)
  121. if (fraction == 1.0)
  122. return true
  123.  
  124. return false
  125. }
  126. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  127. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
  128. */
  129.