Advertisement
Guest User

Untitled

a guest
Jul 19th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. if SERVER then
  2. function AlterEquipment(ply, id, is_item)
  3. if is_item then
  4. //local tab = EquipmentItems[ply:GetRole()]
  5. local item = GetEquipmentItem(ply:GetRole(), tonumber(id))
  6. //print(is_item)
  7. if item then
  8. if item.cost then
  9. local credits = ply:GetCredits()
  10. local cost = item.cost
  11. if ply:HasEquipmentItem(id) then return false end
  12. if credits-cost < 0 then
  13. CustomMsg(ply, "You cannot afford this item! (require +".. cost-credits.. " credit".. (cost-credits != 1 and "s" or "") .. ")", Color(255,0,0,255))
  14. ply:SendLua([[surface.PlaySound('/buttons/weapon_cant_buy.wav')]])
  15. return false
  16. else
  17. ply:SubtractCredits(cost-1) // -1 because the game takes one anyways
  18. return true
  19. end
  20. end
  21. end
  22. else
  23. local swep_table = weapons.GetStored(id) or nil
  24. if !swep_table then return true end
  25. if swep_table.Cost then
  26. local credits = ply:GetCredits()
  27. local cost = swep_table.Cost
  28. if swep_table.LimitedStock and ply:HasBought(id) then return false end
  29. //print(credits-cost)
  30. if credits-cost < 0 then
  31. CustomMsg(ply, "You cannot afford this item! (require +".. cost-credits.. " credit".. (cost-credits != 1 and "s" or "") .. ")", Color(255,0,0,255))
  32. ply:SendLua([[surface.PlaySound('/buttons/weapon_cant_buy.wav')]])
  33. return false
  34. else
  35. ply:SubtractCredits(cost-1) // -1 because the game takes one anyways
  36. return true
  37. end
  38. end
  39. end
  40. end
  41. hook.Add("TTTCanOrderEquipment","AlterEquipCost", AlterEquipment)
  42.  
  43. local function GetEquipID(role,id)
  44. local re_id = 0
  45. for k,v in pairs(EquipmentItems[role]) do
  46. if v.id == id then
  47. re_id = k
  48. break
  49. end
  50. end
  51. return re_id
  52. end
  53.  
  54. local function OverrideEquip(role,equip,cost)
  55. local id = GetEquipID(role,equip)
  56. if id == 0 then Error("No equip found!") end
  57. EquipmentItems[role][id].cost = cost
  58. end
  59.  
  60. hook.Add("InitPostEntity", "OverrideEquipTTT", function()
  61. OverrideEquip(ROLE_TRAITOR,EQUIP_RADAR, 1)
  62. end)
  63. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement