• Entity wont draw model but will cast shadow and draw hitbox.
    3 replies, posted
Hey everyone I'm trying to create a simple custom entity. Testing it in Sandbox works fine, but when I spawn it through glua, it doesn't draw it's model. It does, however, cast the correct shadow, and also boasts a hitbox. This is my initialization (server): [lua] function ENT:Initialize() self:SetModel("models/props_lab/workspace004.mdl") self:PhysicsInit(SOLID_VPHYSICS) self:SetMoveType(MOVETYPE_VPHYSICS) self:SetSolid(SOLID_VPHYSICS) self:SetUseType(SIMPLE_USE) local phys = self:GetPhysicsObject() if phys:IsValid() then phys:Wake() end end [/lua] And yes, I am drawing it clientside: [lua] function ENT:Draw() self:DrawModel() end [/lua] This is the (serverside) code that spawns the ent: [lua] local MapFork = ents.Create("grills_wac_spawner") MapFork:SetPos(Vector(11310, -11085, -6208)) MapFork:SetModel("models/props_lab/workspace004.mdl") MapFork:SetAngles(Angle(0,115,0)) MapFork:Spawn() local l = MapFork:GetPhysicsObject() l:EnableMotion(false) end [/lua] This is the result: [IMG]http://i.imgur.com/iDjfMX9.png[/IMG]
Show your entire entity file. Everything there looks alright.
Clientside: [lua] include("shared.lua") surface.CreateFont( "grills_wac_spawner_Font", { font = "Arial", -- Use the font-name which is shown to you by your operating system Font Viewer, not the file name extended = false, size = 14, weight = 500, blursize = 0, scanlines = 0, antialias = true, underline = false, italic = false, strikeout = false, symbol = false, rotary = false, shadow = false, additive = false, outline = false, } ) -- Propper indentation: /* function something() if this and that then for kv in paris() do if dfkafd end end end ply:Kills() end */ function ENT:Draw() self:DrawModel() end net.Receive("wac_spawn_panel", function() local frame = vgui.Create("DFrame") frame:SetSize(280,160) frame:Center() frame:SetTitle("Wac Spawner") frame:SetVisible(true) frame:SetDraggable(false) frame:ShowCloseButton(true) frame:MakePopup() frame.Paint = function(self , w , h) draw.RoundedBox(4,0,0,w,h,Color(70,70,70)) draw.RoundedBox(4,2,2,w-4,h-4,Color(100,100,110)) draw.RoundedBox(0,2,2,w-4,21,Color(70,70,70)) end frame.OnKeyCodePressed = function( panel, key ) if key == KEY_E then panel:Close() end end local AirCraft_Select = vgui.Create("DComboBox", frame) AirCraft_Select:SetPos( 5, 30 ) AirCraft_Select:SetSize( 150, 20 ) AirCraft_Select:SetValue("Select AirCraft") AirCraft_Select:AddChoice( "Jet Plane" ) AirCraft_Select:AddChoice( "Indiana Jones Plane (Broken)" ) AirCraft_Select:AddChoice( "LittleBird Chopper" ) local label = vgui.Create("DLabel", frame) label:SetPos(5,55) label:SetText( [[Select an Aircraft to spawn Then press the "Spawn!" Button. Obs! - Any Aircraft within 500 units of the spawning point will get removed!]] ) label:SizeToContents() submitBtnColor = Color( 100, 190, 100 ) local submitBtn = vgui.Create("DButton",frame) submitBtn:SetSize(100,60) submitBtn:SetPos(160,30) submitBtn:SetText("Spawn!") submitBtn:SetTextColor(Color(0,0,0,255)) submitBtn.Paint = function(self , w ,h) draw.RoundedBox(4,0,0,w,h,Color(70,70,70)) draw.RoundedBox(4,2,2,w-4,h-4,submitBtnColor) end AirCraft_Select.OnSelect = function() submitBtnColor = Color( 100, 190, 100 ) submitBtn:SetText("Spawn!") end local removelabel = vgui.Create("DLabel",frame) removelabel:SetPos(162.5, 141) removelabel:SetText("Removes Wac Entity") removelabel:SizeToContents() removelabel:SetFont("grills_wac_spawner_Font") local removeBtn = vgui.Create("DButton", frame) removeBtn:SetSize(90,50) removeBtn:SetPos(165, 92) removeBtn:SetText("Remove!") removeBtn:SetTextColor(Color(0,0,0,255)) removeBtn.Paint = function(self , w ,h) draw.RoundedBox(4,0,0,w,h,Color(70,70,70)) draw.RoundedBox(4,2,2,w-4,h-4, Color(190,100,100,255)) end removeBtn.DoClick = function() net.Start("wac_remove") net.SendToServer() surface.PlaySound("ui/buttonclick.wav") end submitBtn.DoClick = function () local AIRCRAFT_TYPE = "Default" local AIRCRAFT_SPAWN = "Default" if AirCraft_Select:GetSelected() == "Jet Plane" then AIRCRAFT_SPAWN = "wac_pl_f16" AIRCRAFT_TYPE = "Jet Plane" elseif AirCraft_Select:GetSelected() == "Indiana Jones Plane (Broken)" then AIRCRAFT_SPAWN = "wac_pl_c172" AIRCRAFT_TYPE = "Indiana Jones Plane (Broken)" elseif AirCraft_Select:GetSelected() == "LittleBird Chopper" then AIRCRAFT_SPAWN = "wac_hc_littlebird_ah6" AIRCRAFT_TYPE = "LittleBird Chopper" else AIRCRAFT_SPAWN = "ERROR" AIRCRAFT_TYPE = "ERROR" end print("Grills Wac_Spawner Spawned A " .. AIRCRAFT_TYPE .. " (" .. AIRCRAFT_SPAWN .. ")") if AirCraft_Select:GetSelected() then net.Start("wac_spawn") net.WriteString(AIRCRAFT_SPAWN) net.SendToServer() frame:Close() surface.PlaySound("ui/buttonclickrelease.wav") else print("Grills Wac_Spawner Selection Error") submitBtn:SetText("Select AirCraft!") submitBtnColor = Color(255,100,100) surface.PlaySound("buttons/button10.wav") end end end) // Planes --"wac_pl_f16" - jet --"wac_pl_c172" - Indana plane // Helicopters -- "wac_hc_littlebird_ah6" [/lua] Serverside: [lua] AddCSLuaFile("cl_init.lua") AddCSLuaFile("shared.lua") include("shared.lua") util.AddNetworkString("wac_spawn_panel") util.AddNetworkString("wac_spawn") util.AddNetworkString("wac_remove") local Wac_spawn_Pos_Vector = Vector(11320,-10400,-6000) function ENT:Initialize() self:SetModel("models/props_lab/workspace004.mdl") self:PhysicsInit(SOLID_VPHYSICS) self:SetMoveType(MOVETYPE_VPHYSICS) self:SetSolid(SOLID_VPHYSICS) self:SetUseType(SIMPLE_USE) local phys = self:GetPhysicsObject() if phys:IsValid() then phys:Wake() end end function ENT:Use(_ , caller) net.Start("wac_spawn_panel") net.Send(caller) end function removeWac() for _,ent in pairs(ents.FindInSphere(Wac_spawn_Pos_Vector,500)) do if string.sub( ent:GetClass(), 1, 4 ) == "wac_" then ent:Remove() end end end hook.Add( "PlayerSay", "Spawn_Wac_Spawner", function( ply, text, public ) text = string.lower( text ) if ( text == "!wac_spawner" ) then for k , v in pairs(ents.GetAll()) do if v:GetClass() == "grills_wac_spawner" then v:Remove() end end local MapFork = ents.Create("grills_wac_spawner") MapFork:SetPos(Vector(11310, -11085, -6208)) MapFork:SetModel("models/props_lab/workspace004.mdl") MapFork:SetAngles(Angle(0,115,0)) MapFork:Spawn() local l = MapFork:GetPhysicsObject() l:EnableMotion(false) end end) net.Receive("wac_remove",function() removeWac() end) net.Receive("wac_spawn", function() local AIRCRAFT_SPAWN = net.ReadString() removeWac() local WacJet = ents.Create(AIRCRAFT_SPAWN) WacJet:SetPos(Wac_spawn_Pos_Vector) WacJet:SetAngles(Angle(0,-150,0)) WacJet:DropToFloor() WacJet:Spawn() PrintTable(WacJet:GetChildren()) for k, v in pairs(WacJet:GetChildren()) do if string.sub( v:GetClass(), 1, 7 ) == "wac_pod" then v:SetAngles(Angle(0,-150,0)) end end end) [/lua] Shared: [lua] ENT.Type = "anim" ENT.Base = "base_entity" ENT.PrintName = "Wac Spawner" ENT.Spawnable = true function ENT:SetupDataTables(type, slot, name) self:NetworkVar("Int",1,"TestInt") end [/lua]
Try removing function() something in your client file as it's using this and that (nil values) and an incorrect usage of a for loop Edit: just noticed it was commented...ignore me
Sorry, you need to Log In to post a reply to this thread.