Aek177

TTT perk machine init.lua

Jun 13th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. AddCSLuaFile("cl_init.lua")
  2. AddCSLuaFile("shared.lua")
  3.  
  4. include("shared.lua")
  5.  
  6. function ENT:Initialize()
  7. //self:SetModel("models/yolojoenshit/bo3perks/juggernog/mc_mtl_p7_zm_vending_jugg.mdl")
  8. self:PhysicsInit(SOLID_VPHYSICS)
  9. self:SetMoveType( MOVETYPE_VPHYSICS)
  10. self:SetSolid(SOLID_VPHYSICS)
  11. self:SetUseType(SIMPLE_USE)
  12.  
  13. self.Perk = ""
  14. self.Tokens = 0
  15.  
  16. local phys = self:GetPhysicsObject()
  17. if (phys:IsValid()) then
  18. phys:Wake()
  19. end
  20. end
  21.  
  22. function ENT:SetPerk(name)
  23. self.Perk = name
  24. self:SetNWString("MachineID", name)
  25. end
  26.  
  27.  
  28. function ENT:Use(ply)
  29. if not IsValid(ply) then return end
  30. local perk = self:GetNWString("MachineID")
  31. local points = tonumber(ZARP.PerkData[perk].cost)
  32. if ply.Perks and ply.Perks[perk] then FP.SendMessage(ply, color_white, "You already have this perk!") return end
  33. if ply:PS_HasPoints(points) then
  34. ply:Give("weapon_perkbottle")
  35. ply:SelectWeapon("weapon_perkbottle")
  36. ply:SetPerk(perk, true)
  37. ply:PS_TakePoints(points)
  38. ZARP.DoSparkleEfect(self)
  39. FP.SendMessage(ply, color_white, "You have activated ", Color(255,0,0),perk,color_white," perk!")
  40. else
  41. FP.SendMessage(ply, color_white, "You do not have enough tokens!")
  42. end
  43. end
Advertisement
Add Comment
Please, Sign In to add comment