Advertisement
BuilderGaming

Golden crowbar

Jul 10th, 2015
337
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.56 KB | None | 0 0
  1. ITEM.Name = "Golden crowbar"
  2. ITEM.Price = 80000
  3. ITEM.Model = "models/weapons/w_crowbar.mdl"
  4. ITEM.DonatorOnly = true
  5.  
  6.  
  7. local _gold     = Color(255,204,0,255)
  8. local _white    = Color(255,255,255,255)
  9. local _swep     = "weapon_zm_improvised"
  10. local _swep1    = "weapon_ttt_crowbar1"
  11. local _shine    = "models/shiny"
  12.  
  13. if CLIENT then 
  14.     hook.Add("PreDrawViewModel", "GoldCrowbar", function(vm, p, w )
  15.         if vm and vm:IsValid() then
  16.             local ply = ( p and p:GetObserverTarget() and p:GetObserverTarget():IsValid() and p:GetObserverTarget():IsPlayer() ) and p:GetObserverTarget() or p
  17.             if w and w:IsValid() and w:GetClass() == _swep or _swep1 and ply and ply:IsValid() and ply:GetNWBool("golden",false) then
  18.                 if not vm._golden then
  19.                     vm._golden = true
  20.                     vm:SetColor( _gold )
  21.                     vm:SetMaterial( _shine )
  22.                 end
  23.             elseif vm._golden then
  24.                 vm:SetMaterial("")
  25.                 vm:SetColor( _white )
  26.                 vm._golden = false
  27.             end
  28.         end
  29.     end )
  30. end
  31.  
  32.  
  33. function ITEM:OnBuy( ply )
  34.     ply:SetNWBool("golden", true)
  35.     local crowbar = ply:GetWeapon(weapon_zm_improvised) or ply:GetWeapon("weapon_ttt_crowbar1")
  36.     if crowbar and crowbar:IsValid() then
  37.         print(crowbar)
  38.         crowbar:SetColor( _gold )
  39.         crowbar:SetMaterial(_shine)
  40.     end
  41. end
  42. ITEM.PlayerLoadout      = ITEM.OnBuy
  43. ITEM.OnEquip            = ITEM.OnBuy
  44.  
  45. function ITEM:OnSell(ply)
  46.     ply:SetNWBool("golden", false)
  47.     local crowbar = ply:GetWeapon(weapon_zm_improvised) or ply:GetWeapon("weapon_ttt_crowbar1")
  48.     if crowbar and crowbar:IsValid() then
  49.         crowbar:SetMaterial("")
  50.         crowbar:SetColor( _white )
  51.     end
  52. end
  53. ITEM.OnHolster = ITEM.OnSell
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement