AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   [TF2] Blocking load_itempreset / forcing tf_respawn_on_loadoutchanges 0 on clients (https://forums.alliedmods.net/showthread.php?t=336227)

heavyisgps 02-05-2022 18:53

[TF2] Blocking load_itempreset / forcing tf_respawn_on_loadoutchanges 0 on clients
 
I've tried to add command listeners for load_itempreset 0,1,2 and 3, but they never fire.

I can't find any serverside commands to override tf_respawn_on_loadoutchanges 0/1 for clients.

Any ideas on how to block or force this?

Sreaper 02-05-2022 20:02

Re: [TF2] Blocking load_itempreset / forcing tf_respawn_on_loadoutchanges 0 on client
 
Quote:

Originally Posted by heavyisgps (Post 2770618)
Any ideas on how to block or force this?

What you posted are client only cvars so you cannot change their values.
You could check their cvar and respond with the code you want. Take a look at this plugin I posted that already does this. https://forums.alliedmods.net/showthread.php?t=334971

nosoop 02-05-2022 21:58

Re: [TF2] Blocking load_itempreset / forcing tf_respawn_on_loadoutchanges 0 on client
 
The server's CTFPlayer::CheckInstantLoadoutRespawn is responsible for respawning on loadout changes; you can supercede it with a detour.

(The loadout change notification is sent from client → game coordinator → server, so the usual client-server tactics don't apply here.)

throwaway12812391 04-22-2022 21:36

Re: [TF2] Blocking load_itempreset / forcing tf_respawn_on_loadoutchanges 0 on client
 
Quote:

Originally Posted by nosoop (Post 2770630)
The server's CTFPlayer::CheckInstantLoadoutRespawn is responsible for respawning on loadout changes; you can supercede it with a detour.

Is it possible to change
PHP Code:

if ( !PointInRespawnRoomthisWorldSpaceCenter() ) ) 

to
PHP Code:

if ( !PointInRespawnRoomthisWorldSpaceCenter(), true ) ) 

in CTFPlayer::CheckInstantLoadoutRespawn with a detour to prevent usage in enemy func_respawnroom? I am completely new to DHooks.

Psyk0tik 04-23-2022 01:57

Re: [TF2] Blocking load_itempreset / forcing tf_respawn_on_loadoutchanges 0 on client
 
Quote:

Originally Posted by throwaway12812391 (Post 2777593)
Is it possible to change
PHP Code:

if ( !PointInRespawnRoomthisWorldSpaceCenter() ) ) 

to
PHP Code:

if ( !PointInRespawnRoomthisWorldSpaceCenter(), true ) ) 

in CTFPlayer::CheckInstantLoadoutRespawn with a detour to prevent usage in enemy func_respawnroom? I am completely new to DHooks.

It sounds like you want to patch the function call, specifically one of the params passed to it.

What you can do is detour CTFPlayer::CheckInstantLoadoutRespawn and then patch the function call in pre-hook and restore the original bytes in post-hook. That's only if you want to do it per-player.

If you just want to patch that function call for the server's whole lifespan, then you won't need to detour anything. In that case, you would just need the address of CTFPlayer::CheckInstantLoadoutRespawn and the offset of the "mov" instruction that passes the bool to the PointInRespawnRoom function call.

throwaway12812391 04-23-2022 17:04

Re: [TF2] Blocking load_itempreset / forcing tf_respawn_on_loadoutchanges 0 on client
 
Fixed by the June 21 2022 update.

Quote:

Originally Posted by Psyk0tik (Post 2777610)
If you just want to patch that function call for the server's whole lifespan, then you won't need to detour anything. In that case, you would just need the address of CTFPlayer::CheckInstantLoadoutRespawn and the offset of the "mov" instruction that passes the bool to the PointInRespawnRoom function call.

https://img001.prntscr.com/file/img0...fEO3vitwuw.png

Got it working with SourceScramble. My server is on Linux so I did not include Windows signatures. Added @nosoop's findings.
Code:

"Games"
{
    "tf"
    {
        "MemPatches"
        {
            "CTFPlayer::CheckInstantLoadoutRespawn()::SameTeamOnly"
            {
                "signature" "CTFPlayer::CheckInstantLoadoutRespawn()"

                "windows"
                {
                    "offset" "19h"
                    "verify" "\x6A\x00"
                    "patch"  "\x6A\x01"
                }

                "linux"
                {
                    "offset" "33h"
                    "verify" "\xC7\x44\x24\x08"
                    "patch"  "\xC7\x44\x24\x08\x01\x00\x00\x00"
                }
            }
        }

        "Signatures"
        {
            "CTFPlayer::CheckInstantLoadoutRespawn()"
            {
                "library" "server"
                "windows" "\x57\x8B\xF9\x8B\x07\x8B\x80\x04\x01\x00\x00\xFF\xD0\x84\xC0\x0F\x84\x2A\x2A\x2A\x2A\x8B\x07"
                "linux"  "@_ZN9CTFPlayer26CheckInstantLoadoutRespawnEv"
            }
        }
    }
}


rowedahelicon 04-27-2022 09:22

Re: [TF2] Blocking load_itempreset / forcing tf_respawn_on_loadoutchanges 0 on client
 
I don't have anything setup to do memory patching rn but I did investigate this a bit and the information above is correct, I was able to write out a messy patch for it here. https://github.com/rowedahelicon/TF2...ut-Respawn-Fix

There is a better way to do this and I'm sure someone will but if you still want *something* for now, here you go

nosoop 04-27-2022 11:30

Re: [TF2] Blocking load_itempreset / forcing tf_respawn_on_loadoutchanges 0 on client
 
Quote:

Originally Posted by throwaway12812391 (Post 2777691)
Got it using SourceScramble. My server is on Linux so I did not do Windows signatures.

Minor correction in case others are planning on using this - the patch should be \xC7\x44\x24\x08\x01\x00\x00\x00.

On Windows, CTFPlayer::CheckInstantLoadoutRespawn has a unique signature of \x57\x8B\xF9\x8B\x07\x8B\x80\x04\x01\x00\x00\xFF\xD0\x84\xC0\x0F\x84\x2A\x2A\x2A\x2A\x8B\x07 as of build 7182415, and the offset 19h can be verified as \x6A\x00 and patched to \x6A\x01 to force the parameter to true.


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

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