Ive gots meh an error!
well
I got the error when i pressed E on the npc
entities/policenpc/init.lua:7: attempt to index global 'vgui' (a nil value)
my SNPC code is
[code]AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")
-- add the VGUI
function gocop()
local policeapply = vgui.Create( "DFrame" )
policeapply:SetPos( 50,50 )
policeapply:SetSize( 200, 250 )
policeapply:SetTitle( "Apply for a Police job" )
policeapply:SetVisible( true )
policeapply:SetDraggable( false )
policeapply:ShowCloseButton( false )
policeapply:MakePopup()
local policeapplyyes = vgui.Create( "DButton" )
policeapplyyes:SetParent( DermaPanel )
policeapplyyes:SetText( "Yes I would like a job" )
policeapplyyes:SetPos( 25, 50 )
policeapplyyes:SetSize( 150, 50 )
policeapplyyes.DoClick = function ()
RunConsoleCommand( "say /votecop" )
end
local policeapplyno = vgui.Create( "DButton" )
policeapplyno:SetParent( DermaPanel )
policeapplyno:SetText( "No thank you" )
policeapplyno:SetPos( 25, 300 )
policeapplyno:SetSize( 150, 50 )
policeapplyno.DoClick = function ()
policeapply:Close()
end
end
concommand.Add("opencopvgui",gocop)
--set no health
function ENT:Initialize()
self:SetModel( "models/breen.mdl" )
self:SetHullType( HULL_HUMAN )
self.Entity:SetUseType( SIMPLE_USE )
self:SetHullSizeNormal()
self:SetSolid( SOLID_BBOX )
self:SetMoveType( MOVETYPE_STEP )
self:CapabilitiesAdd( CAP_MOVE_GROUND | CAP_OPEN_DOORS | CAP_ANIMATEDFACE | CAP_TURN_HEAD | CAP_USE_SHOT_REGULATOR | CAP_AIM_GUN )
self:SetMaxYawSpeed( 5000 )
local PhysAwake = self.Entity:GetPhysicsObject()
if ( PhysAwake:IsValid() ) then
PhysAwake:Wake()
end
end
--invincible
function ENT:OnTakeDamage(dmg)
return false
end
function ENT:SelectSchedule()
schdChase = ai_schedule.New( "TraderMovement" )
schdChase:EngTask( "TASK_STOP_MOVING", 0 )
self:StartSchedule( schdChase )
end
function ENT:AcceptInput( Name, Activator, Caller )
if( Name == "Use" && ValidEntity( Activator ) && Activator:IsPlayer() ) then
RunConsoleCommand( "opencopvgui" )
end
end[/code]
Anyone can help?
Pretty sure you have to create the vgui clientside.
so i need to send it to clients so
if SERVER then
AddCSLuaFile( "location" )
end
that?
Create the vgui in cl_init.
I just did that, Im now getting a invalid command... WTF!??!?
Post the error.
Sorry, you need to Log In to post a reply to this thread.