Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if SERVER then
- function AlterEquipment(ply, id, is_item)
- if is_item then
- //local tab = EquipmentItems[ply:GetRole()]
- local item = GetEquipmentItem(ply:GetRole(), tonumber(id))
- //print(is_item)
- if item then
- if item.cost then
- local credits = ply:GetCredits()
- local cost = item.cost
- if ply:HasEquipmentItem(id) then return false end
- if credits-cost < 0 then
- CustomMsg(ply, "You cannot afford this item! (require +".. cost-credits.. " credit".. (cost-credits != 1 and "s" or "") .. ")", Color(255,0,0,255))
- ply:SendLua([[surface.PlaySound('/buttons/weapon_cant_buy.wav')]])
- return false
- else
- ply:SubtractCredits(cost-1) // -1 because the game takes one anyways
- return true
- end
- end
- end
- else
- local swep_table = weapons.GetStored(id) or nil
- if !swep_table then return true end
- if swep_table.Cost then
- local credits = ply:GetCredits()
- local cost = swep_table.Cost
- if swep_table.LimitedStock and ply:HasBought(id) then return false end
- //print(credits-cost)
- if credits-cost < 0 then
- CustomMsg(ply, "You cannot afford this item! (require +".. cost-credits.. " credit".. (cost-credits != 1 and "s" or "") .. ")", Color(255,0,0,255))
- ply:SendLua([[surface.PlaySound('/buttons/weapon_cant_buy.wav')]])
- return false
- else
- ply:SubtractCredits(cost-1) // -1 because the game takes one anyways
- return true
- end
- end
- end
- end
- hook.Add("TTTCanOrderEquipment","AlterEquipCost", AlterEquipment)
- local function GetEquipID(role,id)
- local re_id = 0
- for k,v in pairs(EquipmentItems[role]) do
- if v.id == id then
- re_id = k
- break
- end
- end
- return re_id
- end
- local function OverrideEquip(role,equip,cost)
- local id = GetEquipID(role,equip)
- if id == 0 then Error("No equip found!") end
- EquipmentItems[role][id].cost = cost
- end
- hook.Add("InitPostEntity", "OverrideEquipTTT", function()
- OverrideEquip(ROLE_TRAITOR,EQUIP_RADAR, 1)
- end)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement