iFenomenal

Efect bani money

Jan 11th, 2020
337
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <fakemeta>
  3. #include <hamsandwich>
  4.  
  5. new money
  6.  
  7. new plr_money[33]
  8. new plr_cur_money[33]
  9. new bool:plr_prespawn[33]
  10.  
  11. new onoff,speed_per_sec
  12.  
  13. public plugin_init() {
  14. register_plugin("Money HUD Effect","0.9","Sh!nE")
  15.  
  16. register_event("Money","update_money","b")
  17.  
  18. onoff = register_cvar("amx_mhe_money","1")
  19. speed_per_sec = register_cvar("amx_mhe_money_speed","10")
  20.  
  21. RegisterHam(Ham_Spawn,"player","player_prespawn",0)
  22. RegisterHam(Ham_Spawn,"player","player_spawn",1)
  23.  
  24. money = get_user_msgid("Money")
  25.  
  26. register_message(money,"hook_money")
  27. }
  28.  
  29. public client_disconnect(id) {
  30. plr_money[id]=0
  31. plr_cur_money[id]=0
  32. plr_prespawn[id]=false
  33.  
  34. remove_task(id)
  35. }
  36.  
  37. public player_prespawn(id) {
  38. if(get_pcvar_num(onoff) && is_user_connected(id)) {
  39. plr_prespawn[id]=true
  40.  
  41. plr_money[id]=get_pdata_int(id,115,5)
  42. plr_cur_money[id]=0
  43.  
  44. set_pdata_int(id,115,0,5)
  45.  
  46. set_plr_money(id,0)
  47. }
  48. }
  49.  
  50. public player_spawn(id) {
  51. if(get_pcvar_num(onoff) && is_user_connected(id)) {
  52. plr_prespawn[id]=false
  53.  
  54. set_pdata_int(id,115,plr_money[id],5)
  55.  
  56. set_plr_money(id,plr_money[id])
  57. }
  58. }
  59.  
  60. public update_money(id) {
  61. if(!get_pcvar_num(onoff) || !is_user_connected(id) || plr_prespawn[id]) return PLUGIN_HANDLED
  62.  
  63. new cur_money=read_data(1)
  64.  
  65. if(cur_money!=plr_money[id]) {
  66. plr_money[id]=cur_money
  67.  
  68. if(!task_exists(id)) set_task(0.1,"money_effect",id,_,_,"b")
  69.  
  70. set_plr_money(id,plr_cur_money[id])
  71. }
  72. return PLUGIN_HANDLED
  73. }
  74.  
  75. public hook_money(msg_id,msg_dest,id) {
  76. if(!get_pcvar_num(onoff)) return PLUGIN_CONTINUE
  77.  
  78. new cash = get_msg_arg_int(1)
  79.  
  80. if(plr_cur_money[id]!=cash) return PLUGIN_HANDLED
  81.  
  82. return PLUGIN_CONTINUE
  83. }
  84.  
  85. public money_effect(id) {
  86. static Add
  87.  
  88. if(plr_cur_money[id]==plr_money[id]) {
  89. remove_task(id)
  90. plr_cur_money[id]=plr_money[id]
  91.  
  92. return PLUGIN_HANDLED
  93. }
  94. else if(plr_cur_money[id] < plr_money[id]) {
  95. Add=(plr_money[id]-plr_cur_money[id])/get_pcvar_num(speed_per_sec)
  96.  
  97. if(!Add) Add=1
  98.  
  99. plr_cur_money[id]+=Add
  100. }
  101. else {
  102. Add=(plr_cur_money[id]-plr_money[id])/get_pcvar_num(speed_per_sec)
  103.  
  104. if(!Add) Add=1
  105.  
  106. plr_cur_money[id]-=Add
  107. }
  108.  
  109. set_plr_money(id,plr_cur_money[id])
  110.  
  111. return PLUGIN_CONTINUE
  112. }
  113.  
  114. set_plr_money(id,Money,flash=0) {
  115. message_begin(MSG_ONE_UNRELIABLE,money,_,id)
  116. write_long(Money)
  117. write_byte(flash)
  118. message_end()
  119. }
Add Comment
Please, Sign In to add comment