HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1.  
  2. #include amxmodx
  3. #include fakemeta
  4.  
  5. new decal
  6.  
  7. public plugin_init() {
  8. register_forward(FM_EmitSound, "forward_emit_sound")
  9. decal = engfunc(EngFunc_DecalIndex,"{bproof1")
  10. register_plugin("Knife Scratch", "1.0", "PahanCS")
  11. }
  12.  
  13. public forward_emit_sound(id, channel, const Sound[]) {
  14. if(!equali(Sound, "weapons/knife_hitwall1.wav"))
  15. return FMRES_IGNORED
  16. if(!is_user_alive(id))
  17. return FMRES_IGNORED
  18. static iStart[3], iEnd[3]
  19. get_user_origin(id, iStart)
  20. get_user_origin(id, iEnd, 3)
  21. if((pev(id, pev_button) & IN_ATTACK || pev(id, pev_oldbuttons) & IN_ATTACK) && get_distance(iStart, iEnd) < 66) {
  22. static ent, body
  23. get_user_aiming(id, ent, body)
  24. create_decal(iEnd, decal, true, ent)
  25. }
  26. else if((pev(id, pev_button) & IN_ATTACK2 || pev(id, pev_oldbuttons) & IN_ATTACK2) && get_distance(iStart, iEnd) < 51) {
  27. static ent, body
  28. get_user_aiming(id, ent, body)
  29. create_decal(iEnd, decal, true, ent)
  30. }
  31. else
  32. return FMRES_SUPERCEDE // This therefor that was will not begin sound.
  33. return FMRES_IGNORED
  34. }
  35.  
  36. stock create_decal(iOrigin[3], decal_index, bool:create_sparks = false, entity = 0) {
  37. if(decal_index && !entity) {
  38. message_begin(MSG_ALL, SVC_TEMPENTITY)
  39. write_byte(TE_WORLDDECAL)
  40. write_coord(iOrigin[0])
  41. write_coord(iOrigin[1])
  42. write_coord(iOrigin[2])
  43. write_byte(decal_index)
  44. message_end()
  45. }
  46. else if(decal_index && !is_user_alive(entity) && pev_valid(entity)) {
  47. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  48. write_byte(TE_DECAL)
  49. write_coord(iOrigin[0])
  50. write_coord(iOrigin[1])
  51. write_coord(iOrigin[2])
  52. write_byte(decal_index)
  53. write_short(entity)
  54. message_end()
  55. }
  56. if(create_sparks) {
  57. message_begin(MSG_ALL, SVC_TEMPENTITY)
  58. write_byte(TE_SPARKS)
  59. write_coord(iOrigin[0])
  60. write_coord(iOrigin[1])
  61. write_coord(iOrigin[2])
  62. message_end()
  63. }
  64. return 1
  65. }
  66.