HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <cstrike>
  4.  
  5. #define MONEY_TIER 8000 // DON'T MESS WITH, Money total at which the plugin switches over keeping track of money
  6. new money_total[33] // Keep track of peeps money if above MONEY_TIER
  7. new gmsg_Money
  8.  
  9. new amx_maxmoney
  10. new amx_startmoney
  11.  
  12. public client_connect(id)
  13. {
  14. set_cvar_float("mp_startmoney", 801.0) // So you can track when to change to amx_startmoney ammount, I know.. a crude method
  15. money_total[id] = 0
  16. }
  17.  
  18.  
  19. public read_gmsg_Money(id) {
  20. if(!is_user_connected(id)) return PLUGIN_HANDLED
  21.  
  22. new current_total = read_data(1)
  23.  
  24. if(current_total == 801){ // If CS is spawning you with mp_startmoney default
  25. current_total = get_pcvar_num(amx_startmoney) // current total is actually amx_startmoney
  26. cs_set_user_money(id, current_total,0) // so set user money to amx_startmoney
  27. money_total[id] = 0 // reset
  28. }
  29. if(current_total >= MONEY_TIER && !money_total[id]) // If first time above MONEY_TIER
  30. {
  31. money_total[id] = current_total // Keep track of current total
  32.  
  33. send_moneymsg(id,current_total-MONEY_TIER) // send money msg of current total
  34.  
  35. return PLUGIN_CONTINUE
  36. }
  37. if(money_total[id]) // If was over tier on last money message
  38. {
  39. money_total[id] += current_total - MONEY_TIER // figure the term of current total - tier
  40.  
  41. if(money_total[id] < MONEY_TIER){ // If less then tier set user money to money_total[id] and stop keeping track
  42. cs_set_user_money(id,money_total[id],1)
  43. money_total[id] = 0
  44. }
  45. else{
  46. send_moneymsg(id,current_total-MONEY_TIER) // else send money message
  47. }
  48.  
  49. return PLUGIN_CONTINUE
  50. }
  51.  
  52. return PLUGIN_CONTINUE
  53. }
  54.  
  55. //change flash to ammount
  56. public send_moneymsg(id,ammount)
  57. {
  58. cs_set_user_money(id,MONEY_TIER,0) //Set user money to tier ammount so easy to track add and subtract terms
  59.  
  60. new maxamount = get_pcvar_num(amx_maxmoney)
  61.  
  62. if(money_total[id] > maxamount)
  63. money_total[id] = maxamount
  64.  
  65. //send old money
  66. message_begin( MSG_ONE , gmsg_Money , {0,0,0}, id )
  67. write_long(money_total[id]-ammount)
  68. write_byte(0)
  69. message_end()
  70.  
  71. //send current money
  72. message_begin( MSG_ONE , gmsg_Money , {0,0,0}, id ) //Send money message with ammount stored in money_total[id]
  73. write_long(money_total[id])
  74. write_byte(1)
  75. message_end()
  76. }
  77.  
  78.  
  79. public find_money_target(id, level, cid)
  80. {
  81. if(!cmd_access(id, level, cid, 3))
  82. return PLUGIN_HANDLED
  83.  
  84. new target[16], ammount[8], players[32]
  85. new num
  86.  
  87. read_argv(1,target,15)
  88. read_argv(2,ammount,7)
  89.  
  90. if(target[0] == '@'){ //If trying to give a team money
  91. if(target[1] == 'C' || target[1] == 'c'){
  92. get_players(players, num ,"e", "CT")
  93. }
  94. else if(target[1] == 'T' || target[1] == 't'){
  95. get_players(players, num ,"e", "TERRORIST")
  96. }
  97. else{
  98. console_print(id, "*** No known team by that name. ***")
  99. return PLUGIN_HANDLED
  100. }
  101. }
  102. else if(target[0] == '#'){ //If trying to give a player(userid) money
  103. new userid = str_to_num(target[1])
  104. players[0] = find_player("k", userid)
  105. }
  106. else{ // else search for matching name to try and give money
  107. players[0] = find_player("bl", target)
  108. }
  109.  
  110. if(players[0] == 0){ //If no target(s) could be found
  111. console_print(id, "*** No target(s) could be found. ***")
  112. return PLUGIN_HANDLED
  113. }
  114. else
  115. give_money(players, str_to_num(ammount))
  116.  
  117. return PLUGIN_HANDLED
  118. }
  119.  
  120.  
  121. public give_money(players[], ammount)
  122. {
  123. new i
  124. while(players[i]){
  125. if(money_total[players[i]]){
  126. money_total[players[i]] += ammount // Keep track of current total
  127. send_moneymsg(players[i],ammount) // send money msg of current total
  128. }
  129. else if( (cs_get_user_money(players[i]) + ammount) >= MONEY_TIER){
  130. money_total[players[i]] = cs_get_user_money(players[i]) + ammount // Keep track of current total
  131. send_moneymsg(players[i],ammount) // send money msg of current total
  132. }
  133. else{
  134. ammount += cs_get_user_money(players[i])
  135. cs_set_user_money(players[i],ammount,1)
  136. money_total[players[i]] = 0
  137. }
  138.  
  139. ++i
  140. }
  141. }
  142.  
  143. public restartround()
  144. {
  145. for (new i=1; i<33; i++)
  146. money_total[i] = 0
  147. }
  148.  
  149. public plugin_init()
  150. {
  151. register_plugin("Unlimited Money","1.3","NL)Ramon(NL & Vantage aka Mouse")
  152.  
  153. register_event("Money","read_gmsg_Money","b")
  154. register_event("TextMsg", "restartround", "a", "2&#Game_C","2&#Game_w")
  155.  
  156. amx_startmoney = register_cvar("amx_startmoney", "800")
  157. amx_maxmoney = register_cvar("amx_maxmoney", "99999")
  158.  
  159. register_concmd("amx_setmoney", "find_money_target",ADMIN_LEVEL_A, "{@team, #userid, or name(can be partial)} <ammount>")
  160.  
  161. gmsg_Money = get_user_msgid("Money")
  162.  
  163. return PLUGIN_CONTINUE
  164. }
  165.  
  166.