HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <amxmodx>
  2. #include <engine>
  3. #include <fakemeta>
  4. #include <hamsandwich>
  5. #include <cstrike>
  6.  
  7. #define PLUGIN "Drop Money"
  8. #define VERSION "1.0"
  9. #define AUTHOR "m4m3ts"
  10.  
  11. #define Dropped_Money 400
  12. #define Money_Remove_Time 5.0
  13.  
  14. new const MONEY_MODEL[] = "models/money.mdl"
  15.  
  16. new const Sounds[][] =
  17. {
  18. "money1.wav",
  19. "money2.wav",
  20. "money3.wav",
  21. "pickup.wav"
  22. }
  23.  
  24. new sound_voice[33]
  25.  
  26. public plugin_init()
  27. {
  28. register_plugin(PLUGIN, VERSION, AUTHOR)
  29. register_think("money", "fw_Think")
  30. register_touch("money", "*", "fw_touch")
  31. RegisterHam(Ham_Spawn, "player", "Player_Spawn", 1)
  32. register_clcmd("dropmoney", "drop_money")
  33. }
  34.  
  35. public plugin_precache()
  36. {
  37. precache_model(MONEY_MODEL)
  38.  
  39. for(new i = 0; i < sizeof(Sounds); i++)
  40. precache_sound(Sounds[i])
  41. }
  42.  
  43. public Player_Spawn(id)
  44. {
  45. if(is_user_alive(id))
  46. sound_voice[id] = 1
  47. }
  48.  
  49. public drop_money(id)
  50. {
  51. if(!is_user_alive(id) || cs_get_user_money(id) < Dropped_Money)
  52. return
  53.  
  54. new Float:origin[3],Float:velocity[3],Float:angles[3]
  55. engfunc(EngFunc_GetAttachment, id, 0, origin,angles)
  56. pev(id,pev_angles,angles)
  57. new entX = create_entity( "info_target" )
  58. set_pev( entX, pev_classname, "money" )
  59. set_pev( entX, pev_solid, SOLID_TRIGGER )
  60. set_pev( entX, pev_owner, id)
  61. set_pev( entX, pev_fuser1, get_gametime() + Money_Remove_Time)
  62. set_pev( entX, pev_nextthink, halflife_time() + 0.1)
  63. set_pev( entX, pev_movetype, MOVETYPE_TOSS )
  64. set_pev( entX, pev_mins, { -2.0,-2.0,-2.0 } )
  65. set_pev( entX, pev_maxs, { 5.0,5.0,5.0 } )
  66. entity_set_model( entX, MONEY_MODEL )
  67. set_pev( entX, pev_origin, origin )
  68. set_pev( entX, pev_angles, angles )
  69. set_pev( entX, pev_owner, id )
  70. velocity_by_aim( id, 300, velocity )
  71. set_pev( entX, pev_velocity, velocity )
  72.  
  73. cs_set_user_money(id, cs_get_user_money(id) - Dropped_Money)
  74.  
  75. if(sound_voice[id])
  76. {
  77. emit_sound(id, CHAN_VOICE, Sounds[random(sizeof(Sounds)-1)], 1.0, ATTN_NORM, 0, PITCH_NORM)
  78. sound_voice[id] = 0
  79. set_task(5.0, "back_sound", id)
  80. }
  81. }
  82.  
  83. public back_sound(id) sound_voice[id] = 1
  84.  
  85. public fw_touch(Ent, Id)
  86. {
  87. // If ent is valid
  88. static Owner; Owner = pev(Ent, pev_owner)
  89.  
  90. if(!pev_valid(Ent) || !is_user_alive(Id) || Id == Owner)
  91. return
  92.  
  93. remove_task(Id)
  94. if(cs_get_user_money(Id) >= 15600) cs_set_user_money(Id, 16000)
  95. else cs_set_user_money(Id, cs_get_user_money(Id) + Dropped_Money)
  96. emit_sound(Id, CHAN_VOICE, Sounds[3], 1.0, ATTN_NORM, 0, PITCH_NORM)
  97. remove_entity(Ent)
  98. }
  99.  
  100. public fw_Think(ent)
  101. {
  102. if(!pev_valid(ent))
  103. return
  104.  
  105. static Float:fFrame; pev(ent, pev_frame, fFrame)
  106.  
  107. fFrame += 1.5
  108. fFrame = floatmin(21.0, fFrame)
  109.  
  110. set_pev(ent, pev_frame, fFrame)
  111. set_pev(ent, pev_nextthink, get_gametime() + 0.05)
  112.  
  113. // time remove
  114. static Float:fTimeRemove, Float:Amount
  115. pev(ent, pev_fuser1, fTimeRemove)
  116. pev(ent, pev_renderamt, Amount)
  117.  
  118. if(get_gametime() >= fTimeRemove)
  119. {
  120. remove_entity(ent)
  121. }
  122. }