HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <fakemeta>
  4. #include <cstrike>
  5.  
  6. #define Plugin "Fegyver Eladas"
  7. #define Version "1.4"
  8. #define Author "PHP"
  9.  
  10. #define MAX_WEAPONS 33
  11.  
  12. new const g_prices[MAX_WEAPONS][] = {
  13. "0",
  14. "600",
  15. "0",
  16. "2750",
  17. "0",
  18. "3000",
  19. "0",
  20. "1400",
  21. "3500",
  22. "0",
  23. "800",
  24. "750",
  25. "1700",
  26. "4200",
  27. "2000",
  28. "2250",
  29. "500",
  30. "400",
  31. "4750",
  32. "1500",
  33. "5750",
  34. "1700",
  35. "3100",
  36. "1250",
  37. "5000",
  38. "0",
  39. "650",
  40. "3500",
  41. "2500",
  42. "0",
  43. "2350",
  44. "0",
  45. "0"
  46. }
  47.  
  48. new cvar, buyzone, annonce, divide
  49. public plugin_init()
  50. {
  51. register_plugin(Plugin, Version, Author)
  52.  
  53. register_clcmd("say /sell", "cmd_sell")
  54. register_clcmd("say_team /sell", "cmd_sell")
  55.  
  56. cvar = register_cvar("SW_enabled", "1")
  57. buyzone = register_cvar("SW_buyzone", "1")
  58. annonce = register_cvar("SW_annonce", "120")
  59. divide = register_cvar("SW_divide", "2")
  60.  
  61. if(get_pcvar_num(annonce) > 1)
  62. set_task(get_pcvar_float(annonce), "print_annonce",_,_,_,"b")
  63. }
  64.  
  65. public print_annonce()
  66. {
  67. if(get_pcvar_num(annonce) < 1)
  68. return PLUGIN_CONTINUE
  69.  
  70. client_print(0, print_chat, "Elakarod adni ezt a fegyvert? Ird be a chatbe hogy /sell")
  71. return PLUGIN_CONTINUE //Continue...
  72. }
  73.  
  74. stock fm_find_ent_by_owner(index, const classname[], owner, jghgtype = 0)
  75. {
  76. new strtype[11] = "classname", ent = index
  77. switch (jghgtype) {
  78. case 1: copy(strtype, 6, "target")
  79. case 2: copy(strtype, 10, "targetname")
  80. }
  81.  
  82. while ((ent = engfunc(EngFunc_FindEntityByString, ent, strtype, classname)) && pev(ent, pev_owner) != owner) {}
  83.  
  84. return ent
  85. }
  86.  
  87. stock bool:fm_strip_user_gun(index, wid = 0, const wname[] = "")
  88. {
  89. new ent_class[32]
  90. if (!wid && wname[0])
  91. copy(ent_class, 31, wname)
  92. else {
  93. new weapon = wid, clip, ammo
  94. if (!weapon && !(weapon = get_user_weapon(index, clip, ammo)))
  95. return false
  96.  
  97. get_weaponname(weapon, ent_class, 31)
  98. }
  99.  
  100. new ent_weap = fm_find_ent_by_owner(-1, ent_class, index)
  101. if (!ent_weap)
  102. return false
  103.  
  104. engclient_cmd(index, "drop", ent_class)
  105.  
  106. new ent_box = pev(ent_weap, pev_owner)
  107. if (!ent_box || ent_box == index)
  108. return false
  109.  
  110. dllfunc(DLLFunc_Think, ent_box)
  111.  
  112. return true
  113. }
  114.  
  115. public cmd_sell(id)
  116. {
  117. if(get_pcvar_num(cvar) < 1)
  118. return PLUGIN_CONTINUE
  119.  
  120. if(get_pcvar_num(buyzone) == 1 && cs_get_user_buyzone(id) == 0)
  121. {
  122. client_print(id, print_chat, "[Sell] Buyzone-ban kell lenned hogy eladhasd a fegyvert!")
  123. return PLUGIN_HANDLED
  124. }
  125.  
  126. if(!is_user_alive(id))
  127. {
  128. client_print(id, print_chat, "[Sell] Csak elve adhatsz el fegyvert!")
  129. return PLUGIN_HANDLED
  130. }
  131.  
  132. new temp, weapon = get_user_weapon(id, temp, temp)
  133. new price = str_to_num(g_prices[weapon])
  134.  
  135. if(price == 0)
  136. {
  137. client_print(id, print_chat, "[Sell] Nem lehet eladni ezt a fegyvert!")
  138. return PLUGIN_HANDLED
  139. }
  140.  
  141. new weaponname[32]
  142. get_weaponname(weapon, weaponname, 31)
  143.  
  144. new oldmoney = cs_get_user_money(id)
  145. new cash = clamp(oldmoney + (price / get_pcvar_num(divide)), 0, 16000)
  146.  
  147. fm_strip_user_gun(id, weapon)
  148. cs_set_user_money(id, cash)
  149.  
  150. client_print(id, print_chat, "[Sell] Kaptal %d$-t amiert eladtal egy %s -t", cs_get_user_money(id) - oldmoney, weaponname[7])
  151. return PLUGIN_HANDLED
  152. }
  153.