Clients dont see a VGUI derma team selector upon joining

Can anyone help me with this? See, I developed a new gamemode for my server. In singleplayer when I connect, I have it where a screen pop’s up, asking what team you want to be on. Then you select that team, close out of the box and carry on to the server.

But in my multiplayer server, there is no screen that pop’s up. You’d have to manually open up the console and enter the command for the menu. But player’s wont know that. The derma menu is located in my Gamemode’s cl_init.lua file and it includes the share.lua.

Do I have to do anything special here to get it up and running?

<3

-snip- (realised my own stuff was untested)

Would be good to see the code involved to help, especially where you linked in the concomamnd being called.
Also, at the top of init.lua make sure AddCSLuaFile( “cl_init.lua” ) is there.

We need to see init.lua and cl_init.lua

Here’s the cl_init.lua



 
include( 'shared.lua' ) //LOAD THAT
 
function set_team() //Function for the window when joining as neither special character nor Admin
 
Ready = vgui.Create( "DFrame" ) //Define ready as a "DFrame"
Ready:SetPos( ScrW() / 2, ScrH() / 2 ) //Set the position. Half the screen height and half the screen width. This will result in being bottom right of the middle of the screen.
Ready:SetSize( 400, 150 ) //The size, in pixels of the Frame
Ready:SetTitle( "Welcome to |TC| Naval War, Choose your team!" ) //The title; It's at the top.
Ready:SetVisible( true ) // Should it be seen? 
Ready:SetDraggable( true ) // Can people drag it around?
Ready:ShowCloseButton( true ) //Show the little X top right? I chose no, because I have no alternative, meaning people would roam around with no weapons
Ready:MakePopup() //Make it popup. Of course.
 
ready1 = vgui.Create( "DButton", Ready ) // Define ready1 as a "DButton" with its parent the Ready frame we just created above.
ready1:SetPos( 20, 25 ) //Set position, relative to the frame (If you didn't parent it, it would be relative to the screen
ready1:SetSize( 140, 40 ) // How big it should be, again in pixels
ready1:SetText( "Team Red" ) //What should the button say? 
ready1.DoClick = function() //ready1.doclick = function, we just defined it as a function
RunConsoleCommand( "sb_team1" ) //When it clicks, which function does it run? sb_team1, which is defined in init.lua
end // end the doclick function

ready1 = vgui.Create( "DButton", Ready ) // Define ready1 as a "DButton" with its parent the Ready frame we just created above.
ready1:SetPos( 20, 70 ) //Set position, relative to the frame (If you didn't parent it, it would be relative to the screen
ready1:SetSize( 140, 40 ) // How big it should be, again in pixels
ready1:SetText( "Team Blue" ) //What should the button say? 
ready1.DoClick = function() //ready1.doclick = function, we just defined it as a function
RunConsoleCommand( "sb_team2" ) //When it clicks, which function does it run? sb_team1, which is defined in init.lua
end
 
end // end the set_team function
 
concommand.Add( "sb_start", set_team ) //Now we add a console command for the function we just created. It can be run straight from the console. If you look under the first couple of lines under init.lua, we
// said that it should run this command!


And basically the gamemode was from this tutorial I used:

Simple Gamemode

cl_init.lua looks fine, I took the liberty of re-writing it since it looked like butthole.

[lua]
include( ‘shared.lua’ )

function set_team()
Ready = vgui.Create( “DFrame” )
Ready:Center()
Ready:SetSize( 400, 150 )
Ready:SetTitle( “Welcome to |TC| Naval War, Choose your team!” )
Ready:SetVisible( true )
Ready:SetDraggable( true )
Ready:ShowCloseButton( true )
Ready:MakePopup()

ready1 = vgui.Create( "DButton", Ready )
ready1:SetPos( 20, 25 )
ready1:SetSize( 140, 40 )
ready1:SetText( "Team Red" )
ready1.DoClick = function()
	RunConsoleCommand( "sb_team1" )
end

ready1 = vgui.Create( "DButton", Ready )
ready1:SetPos( 20, 70 )
ready1:SetSize( 140, 40 )
ready1:SetText( "Team Blue" )
ready1.DoClick = function() 
	RunConsoleCommand( "sb_team2" ) 
end

end
concommand.Add( “sb_start”, set_team )[/lua]

Now paste us your init.lua please.

remove the concommand.Add line and replace it with
hook.Add( “Initialize”, “Teamselect”, set_team)

parameters for hook.Add are hookname, name, functionname
certain hooks are activated on a specific condition, in this case, the Initialize hook is called when a player joins. You can get the full list of hooks and what they do at http://wiki.garrysmod.com/?title=Gamemode_Hooks. Read up on this tutorial: http://wiki.garrysmod.com/?title=LUA:Global_and_Local , you’ll want to declare most variables like the ones in this file as locals, as it will run faster.
Fixed version:
[lua]
include( ‘shared.lua’ )

function set_team()
local Ready = vgui.Create( “DFrame” )
Ready:Center()
Ready:SetSize( 400, 150 )
Ready:SetTitle( “Welcome to |TC| Naval War, Choose your team!” )
Ready:SetVisible( true )
Ready:SetDraggable( true )
Ready:ShowCloseButton( true )
Ready:MakePopup()

local ready1 = vgui.Create( "DButton", Ready )
ready1:SetPos( 20, 25 )
ready1:SetSize( 140, 40 )
ready1:SetText( "Team Red" )
ready1.DoClick = function()
    RunConsoleCommand( "sb_team1" )
end

local ready2 = vgui.Create( "DButton", Ready )
ready2:SetPos( 20, 70 )
ready2:SetSize( 140, 40 )
ready2:SetText( "Team Blue" )
ready2.DoClick = function() 
    RunConsoleCommand( "sb_team2" ) 
end

end
hook.Add( “Initialize”, “Teamselect”, set_team)
[/lua]

Also one more problem you had: you cannot have two variables with the same name unless they are locals and in different scopes, you had two
ready1 = vgui.Create( “DButton”, Ready ) declared.

That is retarded, because what if he wants to call it else where.

I believe you only choose you team on connect, think before you say bro. If he needs to call it somewhere else he can just re-add the concommand.Add line. Anyway, it’s sad you can’t even fix up the variables to locals and figure out you’re going to need a hook or RunConsoleCommand to get the popup.

Depending on the gamemode its highly likely that team will change, either autobalance, or the player wanting to switch :S

Also according to the tutorial, the concommand is actually executed from the init.lua in GM:PlayerInitialSpawn so not sure you checked your self to see before insulting c-unit.

Fuck you, maybe someone wants to change teams after a round? And that’s why I wanted to see his init.lua, because what if he is already using RunConsoleCommand? And more than likely you will need a hook and a concommand not 1 or the other.

[editline]16th January 2011[/editline]

I’m glad someone in here isn’t a fucking retard.

Yes because running a concommand for the client on the server makes the client open it. Wow you two are idiots.

Let me get the code from the tutorial:
[lua]
function GM:PlayerInitialSpawn( ply ) // When spawning after joining the sever
CheckSpecialCharacters( ply ) //Is he defined in the specialchars.lua file? If yes, then he gets those values, and it stops here.
if ply:IsAdmin() then //Is the connecting player admin?
sb_team2( ply ) //If he is then set his team to team 2.
else // If he isn’t admin then,
joining( ply ) //Call the function joining (found near the bottom of this file)
RunConsoleCommand( “sb_start” ) //Run the console command defined in cl_init.lua.
end //Close the if
end //close the function
[/lua]

Now, clearly Skull435, you have a poor grasp of lua if you don’t understand that GM:PlayerInitialSpawn( ply ) gets the player entity, you know hooked into when they first spawn (initial spawn). Then with this entity it references the code contained within and then runs the concommand.

No, you are. You are saying to just put this code in an initizalize hook and call it a day. I’m saying to put it in a concommand and call it on PlayerInitialSpawn, because then he can do other things with it.

Well uhh gee, Skull435’s fix seemed to work fine, so thank you for that. But unfortunately, I only have a basic grasp of lua, not advanced knowledge like everyone else. So umm, yeh…I guess your guy’s work here is done.