Discord
Steam
/
Garry's Mod
/
Developers
/
my entity is n..
Login/Join
Event Log
my entity is not showing up in the spawn menu.
1 replies, posted
Search
In This Thread
hello, im trying to create an addon where i can display various websites on a tv, and have users interact with them. I got the entity code straight from the gmod wiki, but it does not show up in the entities on my server. Here's a screenshot of the folder structure and the code sh_television.lua ENT.Type = "anim" ENT.Base = "base_gmodentity" ENT.PrintName = "tv" ENT.Author = "Sneaky" ENT.Contact = "Sneaky" ENT.Purpose = "Exemplar material" ENT.Instructions = "netflix 'n chill" ENT.Category = "Gflix" ENT.Spawnable = true cl_television.lua include("sh_television.lua") function ENT:Initialize() -- Reset material and panel and load DHTML panel self.Mat = nil self.Panel = nil self:OpenPage() end -- Load the DHTML reference panel function ENT:OpenPage() -- Iff for some reason a panel is already loaded, delete it if ( self.Panel ) then self.Panel:Remove() self.Panel = nil end -- Create a web page panel and fill the entire screen self.Panel = vgui.Create( "DHTML" ) self.Panel:Dock( FILL ) -- Wiki page URL local url = "http://wiki.garrysmod.com/page/Category:Material" -- Load the wiki page self.Panel:OpenURL( url ) -- Hide the panel self.Panel:SetAlpha( 0 ) self.Panel:SetMouseInputEnabled( false ) -- Disable HTML messages function self.Panel:ConsoleMessage( msg ) end end function ENT:Draw() -- Iff the material has already been grabbed from the panel if ( self.Mat ) then -- Apply it to the screen/model if ( render.MaterialOverrideByIndex ) then render.MaterialOverrideByIndex( 1, self.Mat ) else render.ModelMaterialOverride( self.Mat ) end -- Otherwise, check that the panel is valid and the HTML material is finished loading elseif ( self.Panel && self.Panel:GetHTMLMaterial() ) then -- Get the html material local html_mat = self.Panel:GetHTMLMaterial() -- Used to make the material fit the model screen -- May need to be changed iff using a different model local scale_x, scale_y = ScrW()/2048, ScrH()/1024 -- Create a new material with the proper scaling and shader local matdata = { ["$basetexture"]=html_mat:GetName(), ["$basetexturetransform"]="center 0 0 scale "..scale_x.." "..scale_y.." rotate 0 translate 0 0", ["$model"]=1 } -- Unique ID used for material name local uid = string.Replace( html_mat:GetName(), "__vgui_texture_", "" ) -- Create the model material self.Mat = CreateMaterial( "WebMaterial_"..uid, "VertexLitGeneric", matdata ) end -- Render the model self:DrawModel() -- Reset the material override or else everything will have a HTML material! render.ModelMaterialOverride( nil ) end function ENT:OnRemove() -- Make sure the panel is removed too if ( self.Panel ) then self.Panel:Remove() end end sv_television.lua include('sh_television.lua') include("sh_television.lua") function ENT:Initialize() self:SetModel( "models/props_phx/rt_screen.mdl" ) self:SetMoveType( MOVETYPE_VPHYSICS ) self:SetSolid( SOLID_VPHYSICS ) self:PhysicsInit( SOLID_VPHYSICS ) self:Freeze() end ENT.Spawnable = true here's my global addon sv_init.lua file, addcsluafile'ing the client and shared files MsgC( Color( 0, 0, 255 ), "////////////////////////////////////\n" ) MsgC( Color( 0, 0, 255 ), "// _____.__ .__ //\n" ) MsgC( Color( 0, 0, 255 ), "// _____/ ____\\ | |__|__ ___ //\n" ) MsgC( Color( 0, 0, 255 ), "// / ___\\ __\\| | | \\ \\/ / //\n" ) MsgC( Color( 0, 0, 255 ), "// / /_/ > | | |_| |> < //\n" ) MsgC( Color( 0, 0, 255 ), "// \\___ /|__| |____/__/__/\\_ \\ //\n" ) MsgC( Color( 0, 0, 255 ), "// /_____/ \\/ //\n" ) MsgC( Color( 0, 0, 255 ), "// Initializing Gflix... //\n" ) MsgC( Color( 0, 0, 255 ), "// Copyright © 2017 - Sneaky //\n" ) MsgC( Color( 0, 0, 255 ), "// //\n" ) MsgC( Color( 0, 0, 255 ), "// Nothing of this script may be //\n" ) MsgC( Color( 0, 0, 255 ), "// redistributed, shared or //\n" ) MsgC( Color( 0, 0, 255 ), "// resold in any way shape or //\n" ) MsgC( Color( 0, 0, 255 ), "// without prior written consent //\n" ) MsgC( Color( 0, 0, 255 ), "// from Sneaky //\n" ) MsgC( Color( 0, 0, 255 ), "// Issues ? Contact me at //\n" ) MsgC( Color( 0, 0, 255 ), "// Gmodstore! //\n" ) MsgC( Color( 0, 0, 255 ), "////////////////////////////////////\n" ) MsgC( Color( 0, 0, 255 ), "// Checking modules... //\n" ) -- check for modules !!!!!!!!!!!!!!! MsgC( Color( 0, 0, 255 ), "// Checking modules complete! //\n" ) MsgC( Color( 0, 0, 255 ), "////////////////////////////////////\n" ) AddCSLuaFile("entities/television/sh_television.lua") AddCSLuaFile("entities/television/cl_television.lua")
If you use the folder format, you must name your files cl_init.lua (clientside) and init.lua (serverside). It is common practice to name the shared file shared.lua, as well.
Sorry, you need to
Log In
to post a reply to this thread.