AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [ H3LP ] Block IN_BACK (https://forums.alliedmods.net/showthread.php?t=308484)

CrazY. 06-21-2018 16:37

[ H3LP ] Block IN_BACK
 
Hello, I'm trying to block the velocity that is applied when player press IN_BACK. I tried the following but doesn't work properly.

Code:
public CBasePlayer_PreThink(this) {     if (!is_user_alive(this))         return HC_CONTINUE;     static bitsButton;     bitsButton = get_entvar(this, var_button);     if (bitsButton & IN_BACK)         set_entvar(this, var_button, bitsButton & ~IN_BACK);     return HC_CONTINUE; }

Also I tried to disable maxspeed, but doesn't worked.

Code:
public CBasePlayer_ResetMaxSpeed_Post(this) {     if (!is_user_alive(this))         return;     set_entvar(this, var_maxspeed, 0.0); }

Natsheh 06-22-2018 03:41

Re: [ H3LP ] Block IN_BACK
 
You can do this, get user velocity, strip backward velocity, then set his velocity.

Kushfield 06-22-2018 09:38

Re: [ H3LP ] Block IN_BACK
 
Quote:

Originally Posted by Natsheh (Post 2598599)
You can do this, get user velocity, strip backward velocity, then set his velocity.

You can have backwards velocity without using IN_BACK as well, I think the goal here is to block just IN_BACK.

I've been looking for a way to do this as well, and finally ended up with this:
PHP Code:

public fwdRG_PM_Move()
{
    new 
ucmd get_pmove(pm_cmd);
    new 
Float:fwmove get_ucmd(ucmducmd_forwardmove);
    if(
fwmove 0)
    {
        
set_ucmd(ucmducmd_forwardmove0.0);
        
//set_ucmd(ucmd, ucmd_buttons, get_ucmd(ucmd, ucmd_buttons) & ~IN_BACK);
    
}


Blocking movement this way is somewhat laggy for the client though, since it starts moving instantly and then gets reset after the command reaches the server.

CrazY. 06-22-2018 09:41

Re: [ H3LP ] Block IN_BACK
 
Ok, thanks anyway, but I think be better doesn't use this way. The real problem is when I try to set velocity to "down", is applied a little velocity to backward too, then the player moves diagonally.

PurposeLessx 06-22-2018 10:21

Re: [ H3LP ] Block IN_BACK
 
Try this. It may works.

rg_reset_maxspeed(id)

CrazY. 06-22-2018 11:44

Re: [ H3LP ] Block IN_BACK
 
I tried this in the second way.

raizo11 06-23-2018 19:56

Re: [ H3LP ] Block IN_BACK
 
Code:

register_forward(FM_UpdateClientData, "Data", 1)

public Data(id, weapons, cd)
{
        set_cd(cd, CD_flNextAttack, 1.0)
         
        if((entity_get_int(id, EV_INT_button) & (IN_BACK )))
            set_cd(cd, CD_MaxSpeed, 1.0)
}



All times are GMT -4. The time now is 12:43.

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