Raised This Month: $ Target: $400
 0% 

Solved Forcing run forward (+forward)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Xalus
Veteran Member
Join Date: Dec 2009
Location: Belgium
Old 01-31-2018 , 08:10   Forcing run forward (+forward)
Reply With Quote #1

Hello,

For a fun-game I'm working on, I want to force 'run forward' on player.

I don't wanna play with 'velocity' forward, because either way player will fly,
or other functions like jump, crouch, climb ladders wont really work anymore.

so I'm searching a decent way to force a player to "have" +forward activated.
(Without slowhacking ofc)

Thanks in advance,
Xalus.
__________________
Retired.

Last edited by Xalus; 02-08-2018 at 21:06.
Xalus is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 01-31-2018 , 08:14   Re: Forcing run forward (+forward)
Reply With Quote #2

Alter player's pev_button to include IN_FORWARD on CmdStart or PlayerPreThink pre-hook.
__________________
klippy is offline
Xalus
Veteran Member
Join Date: Dec 2009
Location: Belgium
Old 01-31-2018 , 08:31   Re: Forcing run forward (+forward)
Reply With Quote #3

Thanks for your respond,
but after doing some tests..
Player just keeps standing still.

Code:
register_forward(FM_CmdStart, "fwd_CmdStart")

public fwd_CmdStart(client, uc_handle, seed)
{
	if(is_user_alive(client))
	//&& !g_boolSlither)
	{
		new bitButton
		bitButton = get_uc(uc_handle,UC_Buttons)

		if( !(bitButton & IN_FORWARD) )
		{
			set_uc(uc_handle, UC_Buttons, (bitButton | IN_FORWARD))
			//return FMRES_HANDLED
		}
	}
	//return FMRES_IGNORED
}
__________________
Retired.

Last edited by Xalus; 01-31-2018 at 08:32.
Xalus is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 01-31-2018 , 10:02   Re: Forcing run forward (+forward)
Reply With Quote #4

After some testing and then inspecting some engine code I just found out that you can't change usercmd with set_uc because a copy of it is passed to CmdStart. Look like you can't do much without Orpheu or Okapi.

Also to make them move in certain direction you are supposed to change UC_ForwardMove, UC_SideMove and UC_UpMove, not just set IN_FORWARD.
__________________

Last edited by klippy; 01-31-2018 at 10:02.
klippy is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 01-31-2018 , 11:19   Re: Forcing run forward (+forward)
Reply With Quote #5

Alright, here it is.
The thing is that the client is the one that issues movement, meaning that client prediction will always throw this off a bit. However, I made them think they are frozen so they can't create any movement, giving full control to the server. This felt good and precise even with ~50ms ping.
You'll have to provide Windows signatures yourself (or have someone else do it) if you want to run this on Windows. I run Linux and have no access to my Windows PC currently so I am unable to do it.

Useful informaton:
SV_ParseMove - https://github.com/dreamstalker/rehl...user.cpp#L1501
SV_RunCmd - https://github.com/dreamstalker/rehl..._user.cpp#L732

PHP Code:
#include <amxmodx>
#include <orpheu>
#include <orpheu_memory>
#include <fakemeta>

#pragma semicolon true


new gForceForward[MAX_PLAYERS 1];
new 
gParseMoveClientId;

public 
plugin_init()
{
    
register_plugin("Force +forward""1.0.0""KliPPy");

    
OrpheuRegisterHook(OrpheuGetFunction("SV_ParseMove"), "@SV_ParseMove"OrpheuHookPre);
    
OrpheuRegisterHook(OrpheuGetFunction("SV_RunCmd"), "@SV_RunCmd"OrpheuHookPre);

    
register_forward(FM_UpdateClientData"@UpdateClientData_Post"true);

    
register_clcmd("say force""@ClCmd_Force");
}

public 
client_connect(playerId)
{
    
gForceForward[playerID] = false;
}

static 
OrpheuHookReturn:@SV_ParseMove(pSenderClient)
{
    
gParseMoveClientId find_player("k"OrpheuMemoryGetAtAddress(pSenderClient"client_s::userid"));
    return 
OrpheuIgnored;
}

static 
OrpheuHookReturn:@SV_RunCmd(pUserCmdrandomSeed)
{
    if(!
is_user_alive(gParseMoveClientId) || !gForceForward[gParseMoveClientId])
        return 
OrpheuIgnored;

    new 
Float:maxspeed;
    
pev(gParseMoveClientIdpev_maxspeedmaxspeed);
    
set_uc(pUserCmdUC_Buttonsget_uc(pUserCmdUC_Buttons) | IN_FORWARD);
    
set_uc(pUserCmdUC_ForwardMovemaxspeed);
    
set_uc(pUserCmdUC_SideMove0.0);
    
set_uc(pUserCmdUC_UpMove0.0);

    return 
OrpheuIgnored;
}

static @
UpdateClientData_Post(playerIdsendWeaponsclientData)
{
    if(!
is_user_alive(playerId) || !gForceForward[playerId])
        return 
FMRES_IGNORED;

    
set_cd(clientDataCD_Flagsget_cd(clientDataCD_Flags) | FL_FROZEN);

    return 
FMRES_IGNORED;
}

static @
ClCmd_Force(playerId)
{
    
gForceForward[playerId] = !gForceForward[playerId];
    
client_print(playerIdprint_chat"Forcing +forward: %s"gForceForward[playerId] ? "YES" "NO");

configs/orpheu/functions/SV_ParseMove
Code:
{
    "name": "SV_ParseMove",
    "library": "engine",

    "arguments": [
        {
            "type" : "pointer",
            "info" : "client_t *"
        }
    ],
    
    "identifiers": [
        {
            "os" : "windows",
            "value" : "<signature>"
        },
        {
            "os" : "linux",
            "value" : "SV_ParseMove"
        }
    ]
}
configs/orpheu/functions/SV_RunCmd
Code:
{
    "name": "SV_RunCmd",
    "library": "engine",

    "arguments": [
        {
            "type" : "pointer",
            "info" : "usercmd_t *"
        },
        {
            "type": "int",
            "info": "random_seed"
        }
    ],
    
    "identifiers": [
        {
            "os" : "windows",
            "value" : "<signature>"
        },
        {
            "os" : "linux",
            "value" : "SV_RunCmd"
        }
    ]
}
configs/orpheu/memory/client_s__userid
Code:
[
    {
        "name": "client_s::userid",
        "type": "int",
        "memoryType": "data",
        "identifiers": [
            {
                "os": "windows",
                "value": 19364
            },
            {
                "os": "linux",
                "value": 19084
            }
        ]
    }
]
__________________

Last edited by klippy; 01-31-2018 at 11:24.
klippy is offline
Xalus
Veteran Member
Join Date: Dec 2009
Location: Belgium
Old 01-31-2018 , 15:13   Re: Forcing run forward (+forward)
Reply With Quote #6

Thanks,
but gonna try and look for a way without Orpheu,

Don't wanna upload such big module for one simple part of a plugin.
__________________
Retired.
Xalus is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 01-31-2018 , 15:35   Re: Forcing run forward (+forward)
Reply With Quote #7

The module is just one file, smaller than 1MB probably. And you just link to it if you publish your plugin.
__________________
klippy is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 01-31-2018 , 15:53   Re: Forcing run forward (+forward)
Reply With Quote #8

What amazes me is the reply "don't wanna use x for such a small thing". If you see you fail to do it without, and you fail again, and again then the thing it's not that simple, right? Orpheu is made for thins kind of things.
__________________

Last edited by HamletEagle; 01-31-2018 at 15:53.
HamletEagle is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 15:46.


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