• Attempt to call method 'ProduceBomb' (a nil value)
    9 replies, posted
Well ive been worknig on a entity lately and its intended to make bombs but somehow it makes the first bomb without a problem however the 2nd time i select it and click produce it doesnt seem to work and i get that error here is the code [code] function ENT:Use(user) umsg.Start( "bombfabmenu", user ) umsg.Entity( self ) umsg.End() end util.AddNetworkString("ButtonClicked") net.Receive("ButtonClicked", function(len, player) selfEnt:ProduceBomb(player) end) util.AddNetworkString("Selected") net.Receive("Selected", function(len, player) selected = net.ReadString() end) function ENT:ProduceBomb(ply) if The_Bombs[selected] then if ply:canAfford(The_Bombs[selected].Money) then print("Hello") local produce = ents.Create(The_Bombs[selected].Produce) produce:SetPos(selfEnt:GetPos() + self:GetAngles():Up() * 40) produce:Spawn() elseif not ply:canAfford(The_Bombs[selected].Money) then print("No") end end end [/code] ss: [url]http://puu.sh/6OcLm.png[/url] also if you need the cl init or shared just post a reply with what part u want and il send it , thanks in advance
What is "selfEnt"? It is nil.
sorry forgot to add this and selfent is just a way to refrence to self [CODE] function ENT:Initialize() self:SetUseType(SIMPLE_USE) self:SetModel("models/props_lab/reciever_cart.mdl") self:PhysicsInit(SOLID_VPHYSICS) self:SetMoveType(MOVETYPE_VPHYSICS) self:SetSolid(SOLID_VPHYSICS) local phys = self:GetPhysicsObject() phys:Wake() self.damage = 650 self.sound = CreateSound(self, Sound("ambient/machines/lab_loop1.wav")) self.sound:SetSoundLevel(300) self.sound:PlayEx(1,100) selfEnt = self end [/CODE]
bump
[code]util.AddNetworkString("ButtonClicked") net.Receive("ButtonClicked", function(len, player) selfEnt:ProduceBomb(player) end)[/code] selfEnt here doesn't exist.
yes but it doesn't say that is a issue it only says ProduceBomb(player) is nill
[QUOTE=KillZone_SRB;43871621]yes but it doesn't say that is a issue it only says ProduceBomb(player) is nill[/QUOTE] That's because nil/NULL entity doesn't have that method.
Any idea on a possible fix ?
Since you are sending the entity, why not just read and use it? [code] net.Receive("ButtonClicked", function(len, player) local selfEnt = net.ReadEntity() selfEnt:ProduceBomb(player) end)[/code]
No luck same error , can it be something to do with shared.lua ? [CODE] function ENT:Initialize() end function ENT:SetupDataTables() self:NetworkVar("Entity", 0, "owning_ent") end The_Bombs = {} The_Bombs["Regular Timed Bomb"] = { Money = 4500, Produce = "regular_timed_bomb", } The_Bombs["Advanced Timed Bomb"] = { Money = 4500, Produce = "advanced_timed_bomb", } The_Bombs["Ultimate Timed Bomb"] = { Money = 4500, Produce = "ultimate_timed_bomb", } [/CODE]
Sorry, you need to Log In to post a reply to this thread.