AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   how do you set faster speed? (https://forums.alliedmods.net/showthread.php?t=223833)

proffs 08-17-2013 15:01

how do you set faster speed?
 
How can you make that only Ts can run faster?

akcaliberg 08-17-2013 15:51

Re: how do you set faster speed?
 
if you know how you can set all players' speed, you can do that with the exact same way. This time you will need to check players' team with if statement.

Firippu 08-17-2013 15:52

Re: how do you set faster speed?
 
Quote:

Originally Posted by proffs (Post 2015609)
How can you make that only Ts can run faster?

Always? No special condition? Best method is probably hooking player spawn with ham, then check if the player's team is Terrorist with cs_get_user_team(), if so then set a new and higher maximum speed with set_user_maxspeed().

Normal maximum speed is 250.

example
PHP Code:

#define MAX_SPEED 300.0

RegisterHam(Ham_Spawn,"player","fwdPlayerSpawn",1)

public 
fwdPlayerSpawn(id) {
    if(
cs_get_user_team(id)==CS_TEAM_T) {
        
set_user_maxspeed(id,MAX_SPEED)
    }



proffs 08-17-2013 16:38

Re: how do you set faster speed?
 
Alright.
So this should work only for Ts?

PHP Code:

else if (cs_get_user_team(id) == CS_TEAM_T)
        {
            
set_user_maxspeed(id400


And for reset
PHP Code:

set_user_maxspeed(id

?

ironskillz1 08-17-2013 16:55

Re: how do you set faster speed?
 
Set_user_maxspeed sets they speed for the current weapon
So i recomend to set speed in curweapon or ham deploy

Firippu 08-17-2013 17:06

Re: how do you set faster speed?
 
@ironskillz1, yes, i forgot about that. if you switch weapons, it'll reset your speed.

something similar to this will have to be added to the code:
PHP Code:

register_event("CurWeapon","speedb","be","1=1")

public 
speedb(id) {
    if(
cs_get_user_team(id)==CS_TEAM_T) {
        
set_user_maxspeed(id,MAX_SPEED)
    }



ConnorMcLeod 08-18-2013 05:50

Re: how do you set faster speed?
 
-Set maxspeed at spawn is an incorrect method as maxspeed is changed and few occasions such as : weapon change, [un]zoom, [en/dis]able shield, plant bomb, ...

Hook CurWeapon or weapon deploy is not reliable enough since it won't catch all maxspeed changes.


Here is correct way :

First, make sure that you are running update hamsandwich version, you can DL it there : https://forums.alliedmods.net/showpo...9&postcount=34
( If DL link has been removed, it means that the module has been integrated in default amxmodx package, may be for amxx 1.8.3)


Then use this code :

PHP Code:

#include < amxmodx >
#include < fakemeta >
#include < hamsandwich >

#pragma semicolon 1

#define PLUGIN "Constant 400 MaxSpeed"
#define VERSION "0.0.1"

#define cm(%0)    ( sizeof(%0) - 1 )

public plugin_init()
{
    
register_pluginPLUGINVERSION"ConnorMcLeod" );

    
RegisterHam(Ham_CS_Player_ResetMaxSpeed"player""OnCBasePlayer_ResetMaxSpeed_P"true);
    
register_forward(FM_SetClientMaxspeed"OnSetClientMaxspeed_P"true);
}

public 
OnCBasePlayer_ResetMaxSpeed_Pid )
{
    if( 
is_user_alive(id) )
    {
        new 
Float:flMaxSpeed;
        
pev(idpev_maxspeedflMaxSpeed);
        if( 
flMaxSpeed 1.0 // maxspeed is 1.0 at freezetime
        
{
            
set_pev(idpev_maxspeed400.0);
        }
    }
}

// this is only (or mainly ?) used on bomb planting and bomb defusing to block player from moving with SetClientMaxspeed(id, 1.0)
public OnSetClientMaxspeed_P(idFloat:flMaxSpeed)
{
    if( 
flMaxSpeed != 1.0 && is_user_alive(id) ) // should never happen considerating previous comment.
    
{
        
set_pev(idpev_maxspeed400.0);
    }



proffs 08-18-2013 06:11

Re: how do you set faster speed?
 
Quote:

Originally Posted by ConnorMcLeod (Post 2016020)
-Set maxspeed at spawn is an incorrect method as maxspeed is changed and few occasions such as : weapon change, [un]zoom, [en/dis]able shield, plant bomb, ...

Hook CurWeapon or weapon deploy is not reliable enough since it won't catch all maxspeed changes.


Here is correct way :

First, make sure that you are running update hamsandwich version, you can DL it there : https://forums.alliedmods.net/showpo...9&postcount=34
( If DL link has been removed, it means that the module has been integrated in default amxmodx package, may be for amxx 1.8.3)


Then use this code :

PHP Code:

#include < amxmodx >
#include < fakemeta >
#include < hamsandwich >

#pragma semicolon 1

#define PLUGIN "Constant 400 MaxSpeed"
#define VERSION "0.0.1"

#define cm(%0)    ( sizeof(%0) - 1 )

public plugin_init()
{
    
register_pluginPLUGINVERSION"ConnorMcLeod" );

    
RegisterHam(Ham_CS_Player_ResetMaxSpeed"player""OnCBasePlayer_ResetMaxSpeed_P"true);
    
register_forward(FM_SetClientMaxspeed"OnSetClientMaxspeed_P"true);
}

public 
OnCBasePlayer_ResetMaxSpeed_Pid )
{
    if( 
is_user_alive(id) )
    {
        new 
Float:flMaxSpeed;
        
pev(idpev_maxspeedflMaxSpeed);
        if( 
flMaxSpeed 1.0 // maxspeed is 1.0 at freezetime
        
{
            
set_pev(idpev_maxspeed400.0);
        }
    }
}

// this is only (or mainly ?) used on bomb planting and bomb defusing to block player from moving with SetClientMaxspeed(id, 1.0)
public OnSetClientMaxspeed_P(idFloat:flMaxSpeed)
{
    if( 
flMaxSpeed != 1.0 && is_user_alive(id) ) // should never happen considerating previous comment.
    
{
        
set_pev(idpev_maxspeed400.0);
    }



So i only need this:

PHP Code:

#include < fakemeta >
#include < hamsandwich >

#pragma semicolon 1 


PHP Code:

public OnSetClientMaxspeed_P(idFloat:flMaxSpeed)
{
    if( 
flMaxSpeed != 1.0 && is_user_alive(id) ) // should never happen considerating previous comment.
    
{
        
set_pev(idpev_maxspeed400.0);
    }


PHP Code:

register_forward(FM_SetClientMaxspeed"OnSetClientMaxspeed_P"true); 


ConnorMcLeod 08-18-2013 06:26

Re: how do you set faster speed?
 
Are you stupid or are you pulling my leg ?

proffs 08-18-2013 06:31

Re: how do you set faster speed?
 
Quote:

Originally Posted by ConnorMcLeod (Post 2016055)
Are you stupid or are you pulling my leg ?

I will use it for another plugin.
Well i only need that right?


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

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