OnPlayerRunCmd tip
If you use OnPlayerRunCmd to block certain actions, like attacking or jumping, the client will experience the start of the action before the server can tell them to stop.
This is because Valve made our clients "predict" what we want to do. For example when our client sees +attack it starts the weapon fire animations, plays the gunshot sound and then resets. While the only one seeing this effect is the client, it can freak the client out and probably cause them to complain. I found a server cvar that actually forces the client to turn prediction off. The cvar is sv_client_predict. Any client that joins after setting this cvar to 0 (-1 to disable it) will have prediction turned off. Unfortunately this forces us to disable an important feature to reduce the lagged feeling. cl_predict is the client cvar, unfortunately it is flagged as a cheat. I haven't experimented with it much, but maybe we can use this to toggle prediction per-client. |
Re: OnPlayerRunCmd tip
Can't you just block the buttons with a PreThink hook with SDK Hooks?
|
Re: OnPlayerRunCmd tip
Ive talked with robin about this before, and turning off prediction is a horrible idea. You can feel a huge difference when you have 0 ping, imagine having 50+ with no prediction.
Psychonic is correct, blocking actions in prethink is the preferred approach. |
Re: OnPlayerRunCmd tip
Quote:
I thought those were basically synonymous. CrimsonGT: I disabled it on my local test server and didn't notice anything, but I did realize that it would cause a very noticeable effect on clients with say 50 ping. This was just a discovery I made and thought maybe we could expand on it by messing with cl_predict. This way we could enable/disable when we want. |
Re: OnPlayerRunCmd tip
I decided to force users to leave prediction on, the default is to let them turn it off.
|
Re: OnPlayerRunCmd tip
Quote:
|
Re: OnPlayerRunCmd tip
I'm guessing PreThink is before OnPlayerRunCmd?
If it stops the client from predicting, then it must. |
Re: OnPlayerRunCmd tip
PreThink occurs prior to any action being sent to the client. Using OnPlayerRunCmd is too late as the client has already started predicting the action, and while it wont actually happen they see it start. For example, if you block attack they will see the gun fire but it wont actually fire on the server.
|
Re: OnPlayerRunCmd tip
Quote:
Or PreThink can actually block predictable buttons without lag for client? If this is true I can't imagine how prediction system works. |
Re: OnPlayerRunCmd tip
Prediction was created for clients, that lag. For example if player pressed forward button, there is very big chance, that player will walk forward, so client's game become to update world with client's prediction with out server world update and permission. If server returned another world state (for example some plugin blocked walking forward) client's world will be updated again, but player will be returned to the old position.
Both OnPreThink and OnPlayerRunCmd are fired when server received client's data (if prediction is ON, clients have already walked forward) and ready to update world with client's command "forward". For example to force client to do taunt when attack fired, the right way is to force bind "mouse1" "taunt" (this wont cause any lags) and then block any attack using SDKHooks or OnPlayerRunCmd. I have felt lags connected with prediction, while fire was blocked without binding, ever on local server with ping 5, 200 client's fps and 500 server's fps. There is no better way. |
Re: OnPlayerRunCmd tip
Well, now it is clear for me. Like I thought. Thank you. :)
|
Re: OnPlayerRunCmd tip
I have never experimented with PreThink so has anyone actually tested these?
|
Re: OnPlayerRunCmd tip
I've tested PreThink before, and I found that it made no difference whether I used OnGameFrame, PreThink or OnPlayerRunCmd, I tried to block the Sniper Rifle's zoom in TF2 and I found myself constantly zooming in and out when right-click was held down.
|
Re: OnPlayerRunCmd tip
You can block zoom with prethink, I did it for a mod I was working on with no problems. Im assuming your using SDKHooks or w.e. that extension is called, might wanna make sure its a prehook on Prethink and not a posthook.
|
Re: OnPlayerRunCmd tip
Quote:
|
| All times are GMT -4. The time now is 18:15. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.