• ents.create help please
    2 replies, posted
so im at the moment making an vending machine that when you buy the food it drops it out of the vending machine this is my error [DarkRP] gamemodes/darkrp/gamemode/modules/workarounds/sh_workarounds.lua:191: bad argument #1 to 'entsCreate' (string expected, got nil)   1. entsCreate - [C]:-1    2. Create - gamemodes/darkrp/gamemode/modules/workarounds/sh_workarounds.lua:191     3. func - addons/police_locker/lua/entities/drp_vend/init.lua:52      4. unknown - lua/includes/extensions/net.lua:32 My server side ents.create net.Receive("GivePoliceVending", function(len, pl) local recievedent = net.ReadEntity() if( not recievedent ) then return end if( not IsValid( recievedent ) ) then return end recievedent:ResetSequence( "push" ) -- Play the open sequence recievedent:SetSequence( "push" ) sound.Play( "buttons/bell1.wav", Vector( recievedent:GetPos() ) ) local button = ents.Create( VendingMachineList[class] ) if ( !IsValid( button ) ) then return end button:SetModel( VendingMachineList[model] ) button:SetPos( recievedent:GetPos()+(recievedent:GetForward()*10) ) button:Spawn() end) my client side local vendingmachinebutton = vgui.Create( "DButton", vendingmachinebackkkk) vendingmachinebutton:SetPos( 200, 15) vendingmachinebutton:SetSize( 300, 600) vendingmachinebutton:SetFont( "buytext" ) vendingmachinebutton:SetTextColor( Color(200,200,200,200) ) vendingmachinebutton:SetExpensiveShadow( 2, Color(0,0,0, 200) ) vendingmachinebutton:SetText( "" ) vendingmachinebutton.Paint = function( self, w, h ) draw.RoundedBox( 0, 0, 0,self:GetWide(),self:GetTall(),Color(40,40,40,0)) draw.SimpleText( PoliceLocker.Config.Language.PurchaseButton, "buytext", 30, 2, Color( 200, 200, 200, 200 ) ) end function vendingmachinebutton:DoClick() net.Start("GivePoliceVending") net.WriteEntity( ReceivedEnt ) net.SendToServer() bg_show = Material( "icons/comp_bg.png" ) //surface.PlaySound( "buttons/bell1.wav" ) timer.Simple( 3, function()  bg_show = Material( "icons/v_bg.png" ) end ) end end else ReceivedEnt.PoliceVendingMachine:SetVisible( true ) end end ) config file VendingMachineList = { ["Chocolate Donut"] = {price = 1000, class = "drp_donut_c", model = "models/donut_c/pdonut_c.mdl"}, ["Cup of Coffee"] = {price = 1000, class = "drp_cof", model = "models/cof/pcof.mdl"}, ["Regular Donut"] = {price = 1000, class = "drp_donut", model = "models/donut/pdonut.mdl"}, }
You're clearly not posting the full code. There is a ton of unknown stuff in your code. For example, what is "class" in VendingMachineList[class] in your net.Receive function? I don't see it defined anywhere? What is "ReceivedEnt" in your net.Start block? Again, don't see it defined anywhere.
yea but if i put this a button comes out net.Receive("GivePoliceVending", function(len, pl) local recievedent = net.ReadEntity() if( not recievedent ) then return end if( not IsValid( recievedent ) ) then return end local button = ents.Create( "gmod_button" ) if ( !IsValid( button ) ) then return end button:SetModel( "models/dav0r/buttons/button.mdl" ) button:SetPos( recievedent:GetPos()+(recievedent:GetForward()*10) ) button:Spawn() end)
Sorry, you need to Log In to post a reply to this thread.