I need some help with Entity Spawning on a location from Derma Panel
0 replies, posted
Hello,
We have been trying to make a entity (a computer) and when you press e on it, it opens a derma screen with a button. When clicking the button it should spawn a vehicle (in this case a Tie Fighter from starwars).
When we put this in our server for testing the derma does not open. Could anyone help us by saying what we have done wrong here?
[code]concommand.Add( "vehiclecomputer", function( ply, cmd, args )
local q = 650
local w = 200
local ply = LocalPlayer()
local mey = LocalPlayer()
local ich = LocalPlayer()
local main = vgui.Create( "DFrame" )
main:SetPos( q, w )
main:SetSize( 600,600 ) -- main:SetSize( ScrW() * 0.3125, ScrH() * 0.5555 )
main:Center()
main:SetTitle( " " )
main:SetVisible( true )
main:SetDraggable( false )
main:ShowCloseButton( true )
main.Paint = function()
draw.RoundedBox( 0, 0, 0, main:GetWide(), main:GetTall()-570, Color( 30, 30, 30, 254) )
draw.RoundedBox( 0, 0, 27, main:GetWide(), main:GetTall()-597, Color( 80, 80, 80, 230) )
draw.RoundedBox( 0, 0, 30, main:GetWide(), main:GetTall(), Color( 45, 45, 45, 220) )
draw.RoundedBox( 0, 0, 140, main:GetWide(), main:GetTall()-532, Color( 30, 30, 30, 254) )
end
main:MakePopup()
local close = vgui.Create ( "DButton" , main)
close:SetSize( 600,30 )
close:SetPos(0,570) --,385
close:SetTextColor( Color( 255, 255, 255, 255 ) )
close:SetText("Click here to spawn a Tie Fighter")
close.Paint = function()
draw.RoundedBox( 0, 0, 0, close:GetWide(), close:GetTall(), Color( 0, 160, 17, 220) )
end
close.DoClick = function()
chat.AddText( Color( 175, 0, 0 ), "[Vehicle System]: ",Color( 100, 100, 255 ), ply:GetName(),Color(127, 176, 255), ", you have spawned a Tie Fighter" )
ply:EmitSound( Sound( "buttons/button9.wav" ), Entity( 1 ):GetPos(), 1, CHAN_AUTO, 1, 75, 0, 100 )
function ENT:SpawnFunction( ply, tr, tie_fighterMODEL )
local pos = ply:GetPos()
local ent = ents.Create( tie_fighterMODEL )
ent:SetPos (Vector (pos + Vector(10,0,5)))
ent:Spawn()
ent:Activate()
return ent
end
main:Remove()
end
[/code]
Sorry, you need to Log In to post a reply to this thread.