View Full Version : Various MP questions
1) I've been working on my server-side code and am now ready to move onto the single-player code. To begin with, I've setup a configurable key on the client-side. When the key is pressed, I want it to execute a command on the server. So my question is really in three parts
* How would I go about checking for the keypress on the client-side?
* How would I send a message to the server informing it of the keypress?
* How would I receive this message and act upon it?
2) My second question involves altering player movement speeds. I spent a good half hour trawling through gamemovement, and similar files. I'm relatively certain that there are restrictions on things like jump height and player speed on both the client and server. I'd like to be able to change the player speed dynamically. Is there a thread detailing how to go about this? Am I correct in thinking this would require changes on both the server and the client?
lodle
05-24-2007, 04:00 PM
1: look in in_main.cpp
2: this is auto matic if set up right
3: look at how IN_ATTACK is checked for client side
I can see how and where keys are defined in in_main. I found this tutorial (http://www.hl2coding.com/article.php?article=6) helpful in defining my custom key. But I just can't figure out how the server receives the keypress, or recognizes it.
I've tried this code on the server-side under player.cpp, in PreThink. Purely because this is where the Jump button is looked for:
if (m_nButtons & IN_CUSBUTTON)
{
Warning("Pressed CUSBUTTON");
}
Pressing the key had no effect in-game.
Can you be more specific?
Double post! But have a new question which warrants one!
I've managed to get the above working, but am getting myself incredibly confused with regards to player classes. I handle most of my player code on the server-side in player.cpp. I have a function (TestFunction) declared within CBasePlayer.
I want to check TestFunction returns a certain value within gamemovement.cpp. However, gamemovement seems to either be shared, or on the client-side. Usage of player points toward C_BasePlayer. Which I believe is the client-side BasePlayer class.
So how would I pull information from CBasePlayer?
Marine
05-25-2007, 09:15 AM
You are in the same boat as me with Networked vars. I think i've done it right, but it doesnt quite work.
We need some code Guru's here now :D
lodle
05-25-2007, 10:28 AM
well basically the player class is set up as follows:
player.cpp is server only and does all the server side things
cbaseplayer.cpp (think thats the name) does every thing client side
baseplayer_shared.cpp handles shared code that both server and client exec.
So set up your network vars like normal in plauyer.cpp and cbaseplayer.cpp then put all the shared coded into baseplayer_shared.cpp.
You really should be making new child classes instead of editing theses ones but thats prob a little advanced at your stage.
You really should be making new child classes instead of editing theses ones but thats prob a little advanced at your stage.
There's no use in learning poor practices. I'm sure that would make a helpful tutorial!
There's no use in learning poor practices. I'm sure that would make a helpful tutorial!
You can get along just fine without making child classes - it just gets a bit messy when they update the SDK.
You should be able to access server side functions from the player class in gamemovement (as it's dealt with on both sides of the game) use
#ifdef GAME_DLL
pPlayer->ServerSideFunction();
#endif
lodle
05-25-2007, 06:06 PM
But its much better to make a child class (thats the point of oo in the first place) not only do you only see your code (which is a hell of alot less than the baseclass) its easier to update and error check.
I might write one up on the sdk if i have time, busy atm.
vBulletin® v3.8.7, Copyright ©2000-2013, vBulletin Solutions, Inc.