• Unsure why init file isn't received a net.Send message.
    2 replies, posted
Hi, I've been creating my own NPC shop and I've come to a speed bump. I've spent around an hour trying to figure out why net.Receive isn't working. Here is the code from all three files. It's the PoliceModel1 message that I'm having trouble with. Also I understand that Entity( 1 ) is a blank message and that's the way I want it. [B]cl_init.lua[/B] [CODE]include("shared.lua") ENT.RenderGroup = RENDERGROUP_BOTH function ENT:Draw() self:DrawModel() end function ENT:SetRagdollBones( b ) self.m_bRagdollSetup = b end function ENT:DrawTranslucent() self:Draw() end local function myMenu() --> Frame local frame = vgui.Create("DFrame") frame:Center() frame:SetSize(300, 200) frame:SetTitle("Police NPC") frame:SetDraggable(false) frame:ShowCloseButton(true) frame:MakePopup() local uniform = vgui.Create("DButton", frame) uniform:Center() uniform:SetSize(250, 30) uniform:SetText("Equip Police Uniform") uniform.DoClick = function() net.Start( "PoliceModel1" ) net.SendToServer( Entity( 1 ) ) print("Message sent") end end usermessage.Hook("ShopNPCUsed",myMenu) --Hook the menu, so we can use it Serverside [/CODE] [B]init.lua[/B] [CODE]AddCSLuaFile( "cl_init.lua" ) AddCSLuaFile( "shared.lua" ) include('shared.lua') function ENT:Initialize() self:SetModel("models/Humans/Group02/male_07.mdl"); self:SetHullType(HULL_HUMAN); self:SetHullSizeNormal(); self:SetNPCState(NPC_STATE_SCRIPT); self:SetSolid(SOLID_BBOX); self:SetUseType(SIMPLE_USE); self:SetBloodColor(BLOOD_COLOR_BLUE); self.Removed = true; end function ENT:AcceptInput(name, activator, caller) util.AddNetworkString( "PoliceModel1" ) umsg.Start("ShopNPCUsed", Caller) -- Prepare the usermessage to that same player to open the menu on his side. umsg.End() -- We don't need any content in the usermessage so we're sending it empty now. end net.Receive( "PoliceModel1", function( len, ply ) ply:SetModel("models/player/nypd/male_02.mdl") print("Message recieved") end )[/CODE] [B]shared.lua[/B] [CODE]ENT.Base = "base_ai" ENT.Type = "ai" ENT.PrintName = "Model Shop" ENT.Author = "Danny" ENT.Contact = "Danny" ENT.Spawnable = true ENT.AdminSpawnable = true ENT.AutomaticFrameAdvance = true function ENT:SetAutomaticFrameAdvance( anim ) self.AutomaticFrameAdvance = anim end [/CODE] The VGUI shows up fine and the print message "Message sent" shows but the init.lua file isn't receiving it. I'm sure it's just something I've done stupid.
[URL="http://wiki.garrysmod.com/page/net/SendToServer"]net.SendToServer[/URL] is a command with no arguments
[QUOTE=JasonMan34;49971521][URL="http://wiki.garrysmod.com/page/net/SendToServer"]net.SendToServer[/URL] is a command with no arguments[/QUOTE] Thanks, I'm must of overlooked this! Solved
Sorry, you need to Log In to post a reply to this thread.