Yes.
Guess i shall show you guys the involved files.
gamemode/init.lua:
[lua]
function GM:PlayerLoadout(ply)
ply:Give(“weapon_physcannon”)
ply:Give(“gmod_camera”)
–ply:Give() wtb hands
end
function GM:PlayerInitialSpawn(ply)
ply:SetTeam(ply:GetNWInt(“job”))
ply:SetNWBool(“Jobotronic”,false)
gamemode.Call(“PlayerLoadout”, ply)
end
function GM:PlayerSpawn(ply)
end
function GM:ShowHelp(ply)
local Premoney = ply:GetNWInt(“money”)
ply:SetNWInt(“money”,Premoney+100)
end
function GM:InitPostEntity( )
local ent=ents.Create(“jobotronic”)
ent:SetPos(Vector(0,0,0))
ent:Spawn()
end
[/lua]
entities/entities/jobotronic/init.lua:
[lua]
AddCSLuaFile(“cl_init.lua”)
AddCSLuaFile(“shared.lua”)
include(“shared.lua”)
function ENT:Initialize()
self:SetModel(“models/props_wasteland/laundry_dryer002.mdl”)
self:PhysicsInit( SOLID_VPHYSICS ) – Make us work with physics,
self:SetMoveType( MOVETYPE_VPHYSICS ) --after all, gmod is a physics
self:SetSolid( SOLID_VPHYSICS )
end
function ENT:Use(activator,caller)
activator:SetNWBool(“Jobotronic”,true)
activator:ChatPrint(“Cake”)
end
[/lua]
gamemode/cl_jobotronic.lua: (The menu that should popup when you click E on the jobotronic), I have already comment this part and thers no diffrence. Though, i would like to know if there would be any better way to check if the player just clicked the jobotronic than having a global variable if he is in it or not.
[lua]
function Jobotronicmenu()
local pl=LocalPlayer()
if pl:GetNWBool(“Jobotronic”)==false then return end
pl:ChatPrint(“You come this far!”)
local Mainpanel = vgui.Create( “DFrame” )
Mainpanel:SetPos(ScrW()/2-256,ScrH()/2-256) --Formula for getting it in teh middle
Mainpanel:SetSize( 512, 512 )
Mainpanel:SetTitle( “Job-O-Tronic” )
Mainpanel:SetVisible( true )
Mainpanel:SetDraggable( false )
Mainpanel:ShowCloseButton( false )
Mainpanel:MakePopup()
local Closebutton = vgui.Create( "DButton",Mainpanel)
Closebutton:SetPos(ScrW()/2+206,ScrH()/2+241)
Closebutton:SetSize( 50, 15 )
Closebutton:SetText("Close")
Closebutton.DoClick = function( Closebutton )
pl:SetNWBool("Jobotronic",false)
Mainpanel.Close()
end
end
[/lua]
Dont think anymore should be needed to show.