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)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement