Help with Console Command

First of all ill just say that these are the files in my gamemode:
cl_init – you know what it does
init – you know what it does
shared – you know what it does
PLoadout – contains the function for creating a vgui panel.

So what im trying to do is to have a console command for the player that runs the function that opens the VGUI, but as far as i know you need to put the “concommand.Add( “Test_Loadout”, EnableLP )” code in the cl_init file and i have the function it is executing EnableLP in PLoadout.lua so here is my question:

  1. Where do i put concommand.Add( “Test_Loadout”, EnableLP )?(shared, cl or init)
  2. How do i make it execute a command in another lua file?
  1. You put it in client, or you could put it anywhere if you made the function global.

  2. Well if it is a concommand you would have this. Do you want the button to run the console command or something?

Now i’ve got a new problem, when i have in cl_init

include( 'shared.lua' )
include( 'vgui/PLoadout.lua' )

// Clientside only stuff goes here

concommand.Add("Test", PLoadoutPanel())

and you type “Test” in console it says the there are no console command called that, i don’t get why

Because concommand.Add(“Test”, PLoadoutPanel()) means add the result of PLoadoutPanel to the console commands. What you probably want to do is concommand.Add(“Test”, PLoadoutPanel), where you’re adding the function PLoadoutPanel to a console command.

I had it there before but i got the same result

Does the function PLoadoutPanel exist and if so is it global?

How do i know if it’s global?

and another quick question, if i have a function to post a message to another player which is a client side func so it has to be executed in cl_init which after what you’ve said can’t interact with the server init, so if i have that function in client init and i want it to execute if something happens to the server like PlayerJoinTeam() which is a server only function how do i go about doing that?

[lua]hook.Add(“PlayerJoinTeam”, function(pl, team)

[lua]usermessage.Hook(“PlayerJoinTeam”, function(um)
local pl = um:ReadPlayer()
local team = um:ReadShort()
hook.Call(“PlayerJoinTeam”, GAMEMODE, pl, team)

hook.Add(“PlayerJoinTeam”, “MyFunction”, function(pl, team)
– do stuff here