• Simple weapon vendor
    4 replies, posted
So I know the basics of LUA and I thought I would try to make something with it, my idea was to make a simple weapon vendor. You click on an entity, a menu pops up and you click on one of "x" buttons. I just can't seem to get it to work. If anyone has any idea of how I should go about making this I'd appreciate any and all feedback. I've thought of multiple ideas now, but I just can't figure it out
What have you got so far?
Make a normal entity. Set usetype to SIMPLE_USE. Create ENT:Use function and use a net message to open a clientside menu.
Alright this is what I have now. Serverside util.AddNetworkString( "ClientSide" ) util.AddNetworkString( "Weapon1" ) function ENT:Use( ply, c) net.Start( "ClientSide" ) net.Send(ply) end net.Receive("Weapon1",function (ply, len) ply:Give("m9k_knife",true) end) Clientside local button1 = vgui.Create("DButton", frame ) button1:SetText("X") button1:SetSize(300,40) button1:SetPos(0, 10) button1.DoClick = function() frame:Close() net.Start("Weapon1") net.SendToServer() end I thought I'd send a signal to the server that the button was pressed so the server can give the player (ply) a knife, but I get this error message: There is more code, but this is the part im struggling with, I can get the frame open and a button works to close the panel if I press it, but it doesn't spawn a weapon. [ERROR] lua/entities/testent/init.lua:30: attempt to index local 'ply' (a number value)   1. func - lua/entities/testent/init.lua:30    2. unknown - lua/includes/extensions/net.lua:32
The order of the callback arguments matter, for net.Receive it's (len, ply) not (ply, len).
Sorry, you need to Log In to post a reply to this thread.