• Entity error help.
    3 replies, posted
Well I was trying to make an entity which after every 3 minutes levels up and after each level the plant becomes more valuable and is worth more when sold via a derma menu which is opened when you use the plant (E). However the entity won't spawn. Any help? Thanks Server [code]-- DrugPlant made by BrutalBarnard AddCSLuaFile("cl_init.lua") AddCSLuaFile("shared.lua") -- General stuff function ENT:Initialize() self:SetModel("models/props_c17/consolebox01a.mdl") -- model self:PhysicsInit(SOLID_VPHYSICS) self:SetMoveType(MOVETYPE_VPHYSICS) self:SetSolid(SOLID_VPHYSICS) local phys = self:GetPhysicsObject() if phys:IsValid() then phys:Wake() end self.damage = 100 -- Health for enity timer.Create("leveluptime",180, 0, setlevel()) self:SetUseType(SIMPLE_USE) self.level = 1 end -- initialise entity function ENT:ontakedamage (dmg) self.damage = self.damage - dmg:getdamage() if self.damage <= 0 then self:destruct() self:remove() end end -- sets when on 0 hpor less that the entity is removed function ENT:Destruct() local vpoint = self:getpos() local effectdata = effectdata() effectdata:setstart(vPoint) effectdata:setorigin(vpoint) effectdata:setscale(1) util.effect("explosion", effectdata) notify(self:getNWEntity("owning_ent"), 1,4, "Your drug plant has died") end -- sets explosion animation and notifies owner of plant death. --function selldirect() -- Set player money((level * 1000)+500) -- ENT:Destruct() --end -- Makes sell function function selldirect(caller) caller:AddMoney(1000) self:Remove() end function setlevel(ply, cmd, args) self.level = (self.level) + 1 end -- sets plant level and increases the plant's level every 3 minutes up to a maximum of 7 times. Max level 8 -- Derma menu function sellcash() local moneybag = ents.Create("prop_physics") moneybag:SetModel("models/props/cs_assault/money.mdl") moneybag.ShareGravgun = true moneybag:SetPos(Vector(MoneyPos.x + 15, MoneyPos.y, MoneyPos.z + 15)) moneybag.nodupe = true moneybag:Spawn() moneybag:GetTable().MoneyBag = true amountmo = ((self.level * 1000)+500) moneybag:GetTable().Amount = amountmo end function ENT:Use(activator, caller) activator:ConCommand("menu") end concommand.Add("sell",selldirect) concommand.Add("destroy",ENT:Destruct()) [/code] Client [code] function ENT:Initialize() end function ENT:Draw() self.Entity:DrawModel() end function ENT:Think() end self={} self.level=1 function levelupcl(ply, cmd, args) self.level=self.level+1 end function menu() local DermaPanel = vgui.Create( "DFrame" ) DermaPanel:SetPos( 50,50 ) DermaPanel:SetSize( 200, 250 ) DermaPanel:SetTitle( "Drug plant menu" ) DermaPanel:SetVisible( true ) DermaPanel:SetDraggable( true ) DermaPanel:ShowCloseButton( true ) DermaPanel:SetMouseInputEnabled(true) DermaPanel:SetKeyboardInputEnabled(true) DermaPanel:MakePopup() local DermaButton = vgui.Create( "DButton" ) DermaButton:SetParent( DermaPanel ) DermaButton:SetText( "Sell plant" ) DermaButton:SetPos( 25, 50 ) DermaButton:SetSize( 150, 50 ) DermaButton.DoClick = function () RunConsoleCommand("sell") end local DermaButton = vgui.Create( "DButton" ) DermaButton:SetParent( DermaPanel ) DermaButton:SetText( "Destroy Drug Plant") DermaButton:SetPos( 25, 100 ) DermaButton:SetSize( 150, 50 ) DermaButton.DoClick = function () RunConsoleCommand("destroy") end end concommand.Add("menu", menu) -- lua_openscript_cl darkrp/entities/entities/DrugPlant/cl_init.lua -- lua_openscript darkrp/entities/entities/DrugPlant/init.lua [/code] Shared [code]ENT.Type = "anim" ENT.Base = "base_gmodentity" ENT.PrintName = "DrugPlant" ENT.Author = "BrutalBarnard" ENT.Spawnable = false ENT.AdminSpawnable = false [/code]
[code] ENT.Spawnable = false ENT.AdminSpawnable = false [/code] should be [code] ENT.Spawnable = true ENT.AdminSpawnable = false [/code]
Well I was spawning it using DarkRP anyway :) But it still doesn't work :(
[code]concommand.Add("menu", menu)[/code] That might already be a concommand.
Sorry, you need to Log In to post a reply to this thread.