Hey guys I am trying to make an entity that when you press E on it, it equips a PAC outfit. I know that you have to do setup, but I am not sure where to put it in the file. I was hoping someone can point me where to put it. Here is the code:
AddCSLuaFile("shared.lua")
include("shared.lua")
local outfit = {
-- start of outfit.txt
[1] = {
["children"] = {
[1] = {
["children"] = {
[1] = {
["children"] = {
},
["self"] = {
["ClassName"] = "proxy",
["UniqueID"] = "3120004463",
["Expression"] = "hsv_to_color(time()*100)",
["GlobalID"] = "4180875644",
["VariableName"] = "Color",
},
},
},
["self"] = {
["UniqueID"] = "884479784",
["GlobalID"] = "1864536752",
["Position"] = Vector(0, 0, 28),
["Size"] = 2.175,
["Color"] = Vector(255, 12, 0),
["EditorExpand"] = true,
["Model"] = "models/pac/default.mdl",
["ClassName"] = "model",
["Name"] = "ball",
},
},
},
["self"] = {
["ClassName"] = "group",
["OwnerName"] = "self",
["EditorExpand"] = true,
["GlobalID"] = "3872319760",
["UniqueID"] = "3296086797",
["Name"] = "my outfit",
["Description"] = "add parts to me!",
},
},
-- end of outfit.txt
}
function ENT:Initialize()
self:SetModel("models/Items/car_battery01.mdl")
self:PhysicsInit(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_VPHYSICS)
self:SetSolid(SOLID_VPHYSICS)
local phys = self:GetPhysicsObject()
phys:Wake()
self.damage = 10
end
function ENT:OnTakeDamage(dmg)
self.damage = self.damage - dmg:GetDamage()
if (self.damage <= 0) then
local effectdata = EffectData()
effectdata:SetOrigin(self:GetPos())
effectdata:SetMagnitude(2)
effectdata:SetScale(2)
effectdata:SetRadius(3)
util.Effect("Sparks", effectdata)
self:Remove()
end
end
function ENT:Use(activator, caller)
activator:SetArmor(activator:Armor() + 10)
self:Remove()
activator:EmitSound("vo/sandwicheat09.mp3", 100, 100)
activator:addPart(outfit)
end
function ENT:OnRemove()
local ply = self:Getowning_ent()
ply.maxFoods = ply.maxFoods and ply.maxFoods - 1 or 0
end
This is the code I need to implement somehow:
if CLIENT then
local outfit = pac.luadata.ReadFile("pac3/test.txt")
pac.SetupENT(ENT) -- this can also be used in initialize using "self" instead of "ENT"
function ENT:Initialize()
self:AttachPACPart(outfit)
end
function ENT:OnRemove()
self:RemovePACPart(outfit)
end
end
Sorry, you need to Log In to post a reply to this thread.