Raised This Month: $51 Target: $400
 12% 

button detection


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
abckrieger
Senior Member
Join Date: Oct 2012
Location: Germany
Old 08-15-2013 , 22:26   button detection
Reply With Quote #1

hello,

is it possible to detect if a player pressing 2 buttons simultaneous?
abckrieger is offline
thetwistedpanda
Good Little Panda
Join Date: Sep 2008
Old 08-15-2013 , 22:31   Re: button detection
Reply With Quote #2

Depends on the button OnPlayerRunCmd / GetClientButtons.
__________________
thetwistedpanda is offline
abckrieger
Senior Member
Join Date: Oct 2012
Location: Germany
Old 08-15-2013 , 22:38   Re: button detection
Reply With Quote #3

i want to implement the prestrafe future of 1.6 in csgo.
in cs 1.6 you run faster if u press a & w/s or d & w/s simultaneous..

i want to detect this in the OnPlayerRunCmd method but in the moment i can only detect one button

Last edited by abckrieger; 08-15-2013 at 22:39.
abckrieger is offline
thetwistedpanda
Good Little Panda
Join Date: Sep 2008
Old 08-15-2013 , 22:39   Re: button detection
Reply With Quote #4

buttons & IN_MOVELEFT && buttons & IN_MOVERIGHT? You can detect two >.<.
__________________
thetwistedpanda is offline
abckrieger
Senior Member
Join Date: Oct 2012
Location: Germany
Old 08-15-2013 , 23:12   Re: button detection
Reply With Quote #5

ups ^.^

this is my first try..

Code:
           if ((GetEntityFlags(client) & FL_ONGROUND) &&  (((buttons & IN_FORWARD) && (buttons & IN_MOVERIGHT)) ||  ((buttons & IN_FORWARD) && (buttons & IN_MOVELEFT))))
                SetEntPropFloat(client, Prop_Data, "m_flMaxSpeed", 278.0);
            else    
                SetEntPropFloat(client, Prop_Data, "m_flMaxSpeed", 250.0);
m_flMaxSpeed seems not to work in csgo and m_flLaggedMovementValue is no option for a kreedz/climb plugin.

the velocity is not influenced by flLaggedMovementValue

a speedmeter runs while i am trying to find a solution

Code:
            decl Float:fVelocity[3];
            GetEntPropVector(client, Prop_Data, "m_vecVelocity", fVelocity);            
            new speed = RoundToFloor(SquareRoot(Pow(fVelocity[0],2.0)+Pow(fVelocity[1],2.0)+Pow(fVelocity[2],2.0)));
is there any other method to change the player speed?

Last edited by abckrieger; 08-15-2013 at 23:26.
abckrieger is offline
Glite
Senior Member
Join Date: Sep 2011
Location: Ukraine
Old 08-16-2013 , 08:11   Re: button detection
Reply With Quote #6

Try to look at:
Code:
m_flConstraintSpeedFactor
m_flConstraintRadius
m_flConstraintWidth
m_vecConstraintCenter
I found this code at hl2sdk-csgo:
PHP Code:
float CGameMovement::ComputeConstraintSpeedFactorvoid )
{
    
// If we have a constraint, slow down because of that too.
    
if ( !mv || mv->m_flConstraintRadius == 0.0f )
        return 
1.0f;

    
float flDistSq mv->GetAbsOrigin().DistToSqrmv->m_vecConstraintCenter );

    
float flOuterRadiusSq mv->m_flConstraintRadius mv->m_flConstraintRadius;
    
float flInnerRadiusSq mv->m_flConstraintRadius mv->m_flConstraintWidth;
    
flInnerRadiusSq *= flInnerRadiusSq;

    
// Only slow us down if we're inside the constraint ring
    
if ((flDistSq <= flInnerRadiusSq) || (flDistSq >= flOuterRadiusSq))
        return 
1.0f;

    
// Only slow us down if we're running away from the center
    
Vector vecDesired;
    
VectorMultiplym_vecForwardmv->m_flForwardMovevecDesired );
    
VectorMAvecDesiredmv->m_flSideMovem_vecRightvecDesired );
    
VectorMAvecDesiredmv->m_flUpMovem_vecUpvecDesired );

    
Vector vecDelta;
    
VectorSubtractmv->GetAbsOrigin(), mv->m_vecConstraintCentervecDelta );
    
VectorNormalizevecDelta );
    
VectorNormalizevecDesired );
    if (
DotProductvecDeltavecDesired ) < 0.0f)
        return 
1.0f;

    
float flFrac = (sqrt(flDistSq) - (mv->m_flConstraintRadius mv->m_flConstraintWidth)) / mv->m_flConstraintWidth;

    
float flSpeedFactor LerpflFrac1.0fmv->m_flConstraintSpeedFactor ); 
    return 
flSpeedFactor;

PHP Code:
// Slow down by the speed factor
float flSpeedFactor 1.0f;
if (
player->m_pSurfaceData)
{
    
flSpeedFactor player->m_pSurfaceData->game.maxSpeedFactor;
}

// If we have a constraint, slow down because of that too.
float flConstraintSpeedFactor ComputeConstraintSpeedFactor();
if (
flConstraintSpeedFactor flSpeedFactor)
    
flSpeedFactor flConstraintSpeedFactor;

    
mv->m_flMaxSpeed *= flSpeedFactor
Check this props both in CS:S and CS:GO to see difference in player movement. Also i don't know, is this props are editable and i think that you must change them on PreThink.

Last edited by Glite; 08-16-2013 at 08:16.
Glite is offline
abckrieger
Senior Member
Join Date: Oct 2012
Location: Germany
Old 08-17-2013 , 07:45   Re: button detection
Reply With Quote #7

okay thx
abckrieger is offline
abckrieger
Senior Member
Join Date: Oct 2012
Location: Germany
Old 09-05-2013 , 10:23   Re: button detection
Reply With Quote #8

m_flConstraintSpeedFactor m_flConstraintRadius m_flConstraintWidth m_vecConstraintCenter
they have all no effect :/
if somebody has an other idea to increase the ground movement speed heeelp
(except m_flLaggedMovementValue)
thx

Last edited by abckrieger; 09-05-2013 at 10:24.
abckrieger is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 09-05-2013 , 12:00   Re: button detection
Reply With Quote #9

I dont think the client sends both keys.. Like it wont send forward and back, only the first key pressed, same with left and right, or any opposing keys.

As for your problem, why not just check like...
If IN_FORWARD & IN_MOVELEFT|IN_MOVERIGHT
new speed = GetVectorLength(velocity)

Then you will know how fast they are momving while pressing those keys... Do other tests like entity flags?

You can add vel in run cmd forward, but it is little bit laggy, as is anything that modifies movement, due to client side prediction.
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.

Last edited by friagram; 09-05-2013 at 12:01.
friagram is offline
abckrieger
Senior Member
Join Date: Oct 2012
Location: Germany
Old 09-06-2013 , 19:36   Re: button detection
Reply With Quote #10

thx. i have found a way to implement the prestrafe. but the movement is spongy on fast direction changes.

Code:
public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon, &subtype, &cmdnum, &tickcount, &seed, mouse[2])
{
...    
        
        //PRESTRAFE (without Pyrowalk cause it's too spongy..)
        if (g_bPreStrafe)
        {
            if ((GetEntityFlags(client) & FL_ONGROUND) && ((buttons & IN_MOVERIGHT) || (buttons & IN_MOVELEFT)))
            {
            
                new g_mouseAbs = mouse[0] - g_mouseDirOld[client];
                g_mouseAbs = abs(g_mouseAbs);
                if ((buttons & IN_MOVERIGHT && mouse[0] > 0 && g_mouseAbs < 15) || (buttons & IN_MOVELEFT && mouse[0] < 0 && g_mouseAbs < 15))
                {            
                    g_PrestrafeFrameCounter[client]++;
                    if (g_PrestrafeFrameCounter[client] < 45)
                        PreStrafeSetSpeed(client, 0.58);
                    else
                    {
                        PreStrafeSetSpeed(client, -0.48);
                        g_PrestrafeFrameCounter[client] = g_PrestrafeFrameCounter[client] - 2;
                    }
                }
                else
                    PreStrafeSetSpeed(client, -1.0);
            }
            else
            {
                PreStrafeSetSpeed(client, -0.5);
                g_PrestrafeFrameCounter[client] = 0;
            }
        }
        g_mouseDirOld[client] = mouse[0];
        
...
}

PreStrafeSetSpeed(client, Float:value)
{
    if (GetEntityFlags(client) & FL_ONGROUND)
    {
        //new value
        g_fPsMaxSpeed[client]= g_fPsMaxSpeed[client] + value;        

        //min (max knifespeed)
        if(g_fPsMaxSpeed[client] < 250.0)
            g_fPsMaxSpeed[client] = 250.0;
        
        //max
        if (g_fPsMaxSpeed[client] > 278.0)
            g_fPsMaxSpeed[client] = 278.0;
        
        //set new max
        SetEntPropFloat(client, Prop_Data, "m_flMaxspeed",g_fPsMaxSpeed[client]); 
        CalcCurrentSpeed(client); 
        if (value > 0) // teleporting < 0 not working 
            TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, g_fCurrentSpeed[client]);
    }
}

CalcCurrentSpeed(client)
{
    GetEntPropVector(client, Prop_Data, "m_vecVelocity", g_fCurrentSpeed[client]);
    g_fCurrentSpeedZ[client] = g_fCurrentSpeed[client][2];
    g_fCurrentSpeed[client][2] = 0.0;        
    NormalizeVector(g_fCurrentSpeed[client], g_fCurrentSpeed[client]);
    ScaleVector(g_fCurrentSpeed[client], g_fPsMaxSpeed[client]);
    g_fCurrentSpeed[client][2] = g_fCurrentSpeedZ[client];    
}
i think that code needs some optimization

Last edited by abckrieger; 09-06-2013 at 19:42.
abckrieger 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 10:26.


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