HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. // Feltoltotte: PaT. ~ arenacity@windowslive.com [ www.amxx.try.hu ]
  2.  
  3. #include <amxmodx>
  4. #include <fakemeta>
  5. #include <hamsandwich>
  6.  
  7. new money
  8.  
  9. new plr_money[33]
  10. new plr_cur_money[33]
  11. new bool:plr_prespawn[33]
  12.  
  13. new onoff,speed_per_sec
  14.  
  15. public plugin_init() {
  16. register_plugin("Money HUD Effect","0.9","Sh!nE")
  17.  
  18. register_event("Money","update_money","b")
  19.  
  20. onoff = register_cvar("amx_mhe_money","1")
  21. speed_per_sec = register_cvar("amx_mhe_money_speed","10")
  22.  
  23. RegisterHam(Ham_Spawn,"player","player_prespawn",0)
  24. RegisterHam(Ham_Spawn,"player","player_spawn",1)
  25.  
  26. money = get_user_msgid("Money")
  27.  
  28. register_message(money,"hook_money")
  29. }
  30.  
  31. public client_disconnect(id) {
  32. plr_money[id]=0
  33. plr_cur_money[id]=0
  34. plr_prespawn[id]=false
  35.  
  36. remove_task(id)
  37. }
  38.  
  39. public player_prespawn(id) {
  40. if(get_pcvar_num(onoff) && is_user_connected(id)) {
  41. plr_prespawn[id]=true
  42.  
  43. plr_money[id]=get_pdata_int(id,115,5)
  44. plr_cur_money[id]=0
  45.  
  46. set_pdata_int(id,115,0,5)
  47.  
  48. set_plr_money(id,0)
  49. }
  50. }
  51.  
  52. public player_spawn(id) {
  53. if(get_pcvar_num(onoff) && is_user_connected(id)) {
  54. plr_prespawn[id]=false
  55.  
  56. set_pdata_int(id,115,plr_money[id],5)
  57.  
  58. set_plr_money(id,plr_money[id])
  59. }
  60. }
  61.  
  62. public update_money(id) {
  63. if(!get_pcvar_num(onoff) || !is_user_connected(id) || plr_prespawn[id]) return PLUGIN_HANDLED
  64.  
  65. new cur_money=read_data(1)
  66.  
  67. if(cur_money!=plr_money[id]) {
  68. plr_money[id]=cur_money
  69.  
  70. if(!task_exists(id)) set_task(0.1,"money_effect",id,_,_,"b")
  71.  
  72. set_plr_money(id,plr_cur_money[id])
  73. }
  74. return PLUGIN_HANDLED
  75. }
  76.  
  77. public hook_money(msg_id,msg_dest,id) {
  78. if(!get_pcvar_num(onoff)) return PLUGIN_CONTINUE
  79.  
  80. new cash = get_msg_arg_int(1)
  81.  
  82. if(plr_cur_money[id]!=cash) return PLUGIN_HANDLED
  83.  
  84. return PLUGIN_CONTINUE
  85. }
  86.  
  87. public money_effect(id) {
  88. static Add
  89.  
  90. if(plr_cur_money[id]==plr_money[id]) {
  91. remove_task(id)
  92. plr_cur_money[id]=plr_money[id]
  93.  
  94. return PLUGIN_HANDLED
  95. }
  96. else if(plr_cur_money[id] < plr_money[id]) {
  97. Add=(plr_money[id]-plr_cur_money[id])/get_pcvar_num(speed_per_sec)
  98.  
  99. if(!Add) Add=1
  100.  
  101. plr_cur_money[id]+=Add
  102. }
  103. else {
  104. Add=(plr_cur_money[id]-plr_money[id])/get_pcvar_num(speed_per_sec)
  105.  
  106. if(!Add) Add=1
  107.  
  108. plr_cur_money[id]-=Add
  109. }
  110.  
  111. set_plr_money(id,plr_cur_money[id])
  112.  
  113. return PLUGIN_CONTINUE
  114. }
  115.  
  116. set_plr_money(id,Money,flash=0) {
  117. message_begin(MSG_ONE_UNRELIABLE,money,_,id)
  118. write_long(Money)
  119. write_byte(flash)
  120. message_end()
  121. }
  122.  
  123.  
  124.  
  125.