Advertisement
Guest User

Untitled

a guest
Jul 16th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.54 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. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement