Curious about trapping stuff sent client <-> server
I've read the functions docs about forwarding and so on but I'm still a little unclear as to how it works exactly and whats the best technique to use in each situation.
Example, I have a new weapon model but for reasons best left unexplained, the sequences don't match the ones in the model its replacing. The actually animations are there, but their in a different order. I've created a mapping, so for example the fire animation that was sequence 1 in the original v_model, is #6 in the new one. Now I have figure out how to make the v_model show sequence #6 but at various times when the player performs a certain action the game is telling it to load another. Now as these animations changes are recorded in demos, im *assuming* that the triggers are part of the client<->server communication and what I would like to do is trap them and issue an alternative. So as per the above example, when the client or server (whichever is relevant) tells the client to show sequence 1 for the original v_model, I want to trap it and issue my own command to the client to show #6 instead. Secondly, is there a generic event sent from the client to the server that can be trapped to tell when they have fired the weapon with either its primary or secondary function? Also can this event be trapped and stopped from being sent to the server but dealt with in another way? What I want to do is trap when the user fired weapon X, but prevent the server from recieving the fire command and instead catching it in the plugin and doing something else instead as the fire command for that weapon. Could anyone shed any light on whats the best and most efficient way to achieve the above? |
1. No idea, but sounds cool. People are getting very creative these days with fakemeta module around. Should probably be one way to hook this and do your own stuff instead. Which is much of what fakemeta module is about... :wink:
2. This has so far been done by checking, in client_prethink, what buttons the user is holding in its EV_INT_button integer. Either hook client_prethink with fakemeta or use the premade one in engine. You'll probably have greater control over the fakemeta one, but I'm not sure superceding client_prethink is a good idea, maybe it will just break stuff. Anyway, you have the necessary tools in engine.inc and engine_const.inc. As said, check EV_INT_button for occurance of the constant IN_ATTACK for primary attack and IN_ATTACK2 for secondary attack. I think, it just sounds likely to me. :-) Not sure what happens if you unset these buttons - I guess that you can't prevent a player from firing by unsetting IN_ATTACK, I already tried this with IN_JUMP and IN_DUCK, I got only partial success with those. It's like you press the duck button, and the client assumes that it really can duck and you could see it start doing so, but in the next couple of frames you can see the player still at his original standing Y-level. Maybe there is another way to do this, maybe not. Maybe a lot of this is up to the client side really and server has to follow it - how else would the clientside cheats work... :-( |
Well effectively *most* of what I want to do I'm guessing is triggered clientside - its just a case of stopping it reaching the server and creating my own stuff within AMX.
One example of a problem I have - I can set the v_model anim to idle, but when the user walks a few steps, eventually it tries to re-trigger what was the original idle sequence not the one I want to use. What I need to figure out is if the client just sends notification that the player is moving to the server, which then returns the command to show the relevant sequence, or if the client sets the sequence locally and then sends it to the server. I wish there was some sort of "dump" module or mode that I could use to watch events going backwards and forwards between the server and client! :( I have looked in the SDK but so far nothing jumps out at me as being anything to do with setting v_model sequences. |
Actually, I just found this in weapons.cpp:
Code:
void CBasePlayerWeapon::SendWeaponAnim( int iAnim, int skiplocal, int body )I wondered if register_event would do it actually. I've seen event "23" being hooked which is a SVC_TEMPENTITY. In this case SVC_WEAPONANIM is 30, so if I register and event for that I guess I could read out the values being sent? That sound about right? |
Indeed. Look at register_message, or even register_event. But with Bailopan's register_message you can (though its not much tested, but really the little I have tried does indeed work, if anything is wrong, just report it so we can fix it) detect a message and just pass it on untouched, block it completely or edit the parameters and then pass it along.
Also I made a metamod plugin awhile back that just registers all messages sent to clients and logs those, including the values of each argument of each message sent, you can find "jghgtrace" here: http://www.tcwonline.org/~johnnygothisgun/ |
Actually I did find that plugin last night Johnny, but for some reason its writing blank log file :( I even tried looking for the mm_trace plugin that is mentioned on the Metamod site but I cant find it anywhere!
Some things I did find last night though were that when the user changes weapon, SVC_WEAPONANIM is broadcast to the client when they change weapon. The first parameter is the sequence index in the v_model to show (usually idle) and the body parameter is always 1. However, it seems that when the fires, secondary fires or performs any action with the weapon, no SVC_WEAPONANIM message is sent which makes me think that all of that is handled client side. What puzzles me though - if when spectating a player you see what actions they perform with their weapon how do the other clients know what your doing? It must be sent at some point, or maybe only to spectators. I'll have to experiement more, although I did find an engine function in the HL-SDK called pfnSendWeaponAnim but its not included in FakeMeta. I think though if I could trap when a user usings primary attack, secondary attack and when they move I could fix it myself. |
| All times are GMT -4. The time now is 17:15. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.