VGUI, panels, and other "fun" problems

theholygod

Newbie
Joined
May 6, 2007
Messages
136
Reaction score
0
Ok, so i've just started "coding" (ie, following tutorials, chucking the odd IF statement in places, etc) for source, and my C++ knowledge is limited to say the least. So, before you flame me for being stupid, you might want to flame me for being ignorant, or whatever.

ok, enough ramble.

I have made a very simple VGUI panel with 3 buttons:

"Join" - i want this to stick the player on the "team" team_unassigned
"Spectate" - same as above but team_spectator
"Close" - hide the panel

now, firstly, i am having trouble getting the panels .cpp file to recieve the commands sent by the buttons:

the code -
Code:
void CMyPanel::OnCommand(const char* Command)
	{
	if(!Q_stricmp(Command, "turnoff"))
		cl_showmypanel.SetValue(0);
	}

the pile of errors -
Code:
.\CMyPanel.cpp(87) : error C3254: 'CMyPanelInterface' : class contains explicit override 'OnCommand' but does not derive from an interface that contains the function declaration
.\CMyPanel.cpp(87) : error C2838: 'OnCommand' : illegal qualified name in member declaration
.\CMyPanel.cpp(89) : error C2065: 'cl_showmypanel' : undeclared identifier
.\CMyPanel.cpp(89) : error C2228: left of '.SetValue' must have class/struct/union

I havnt a clue whats going on here, i've never seen these errors before.


Secondly, for the other two buttons i assume im going to have to somehow get the client to communicate with the server to use the change_team function (if thats what it's called). However it is done, i really dont know where to start, can anyone point me in the direction of a good tutorial on this?

thanks
 
What is cl_showmypanel, anyways?

Some of the example panels provided have quick escape clauses for closing panels, I think. Off the top of my head I can't remember which, though. Try looking at how the MOTD panel does it.

There's a way of telling the client to silently send a console command to the server, which is a way to do the change team thing. We use something similar in Zombie Master, but I can't quite remember what as I'm not on a coding machine.

-Angry Lawyer
 
Ooh, and your other error I think is because Command might be a reserved word. I also think somethings gone wrong with inherating, hence the weird override problem.

-Angry Lawyer
 
So, i rename "oncommand" and look up closing panels.

Could you elaborate on the sending of console commands thing? do you have a tutorial i could follow?
 
Back
Top