AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   FM_CmdStart and client_PreThink (https://forums.alliedmods.net/showthread.php?t=294836)

Fr33m@n 03-09-2017 07:18

FM_CmdStart and client_PreThink
 
I was on the move to update some forward in some plugins, for performance reasons.

I saw many usage of client_PreThink + get_user_button for the only purpose of getting what button is used at this very moment.

Since CmdStart, if i remember right, is called at the same frame and the same number of time as client_prethink, since CmdStart can directly pass the button in a uc_handle

What is better ?

client_prethink + get_user_button
or CmdStart + get_uc(uc_handle, UC_Buttons)

EFFx 03-09-2017 07:34

Re: FM_CmdStart and client_PreThink
 
https://forums.alliedmods.net/showth...823#post351823

Fr33m@n 03-09-2017 09:10

Re: FM_CmdStart and client_PreThink
 
This topic don't cover the question. Plus most of the post are vague.

edon1337 03-09-2017 09:19

Re: FM_CmdStart and client_PreThink
 
CmdStart + get_uc(uc_handle, UC_Buttons)

klippy 03-09-2017 09:47

Re: FM_CmdStart and client_PreThink
 
https://github.com/dreamstalker/rehl....cpp#L777-L808
This is the difference in code. CmdStart is called at line 777, PlayerPreThink is called at 808.

The order is: CmdStart -> PlayerPreThink -> Think -> PlayerPostThink -> CmdEnd.

HLSDK Says:

  • Code:

    CmdStart

    We're about to run this usercmd for the specified player.  We can set up groupinfo and masking here, etc.
    This is the time to examine the usercmd for anything extra.  This call happens even if think does not.


  • Code:

    PlayerPreThink

    Called every frame before physics are run


  • Code:

    PlayerPostThink

    Called every frame after physics are run


  • Code:

    CmdEnd

    Each cmdstart is exactly matched with a cmd end, clean up any group trace flags, etc. here


Only Think (Not PreThink and PostThink) may not happen every frame.

Looks like game dll inspects button presses and does physics stuff in PreThink and advances animations and such on PostThink. My best guess is to do whatever you want related to button presses/physics in PlayerPreThink post-hook and totally avoid CmdStart, unless you need that usercmd_t pointer.


All times are GMT -4. The time now is 17:52.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.