Raised This Month: $32 Target: $400
 8% 

Player Speed


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SaBBa
Member
Join Date: Dec 2012
Old 01-21-2021 , 13:05   Player Speed
Reply With Quote #1

In some cases player speed resets, like when player uses scope, I want to set speed again when player cancels scope, also, I have noticed that speed resets in other cases too (not sure exactly in which case).

To sum up, I want to set my speed when scope is canceled, also if you tell me other case, in which speed resets and how to fix that too, that would be really nice

PHP Code:

new gCurrentWeapon[33]
new 
speed[33]

public 
plugin_init()
{
    
register_event"CurWeapon" "fw_EvCurWeapon" "be" "1=1" )
}

public 
client_putinserver(id)
{
    
speed[id] = 1.5
    engfunc
(EngFunc_SetClientMaxspeedid250.0*speed[id])
}

public 
fw_EvCurWeapon(id)
{
    new 
weaponid read_data(2)
    if(
gCurrentWeapon[id] != weaponid) {
        
gCurrentWeapon[id] = weaponid
        engfunc
(EngFunc_SetClientMaxspeedid250.0*speed[id])
    }
    return 
PLUGIN_HANDLED

__________________
SaBBa is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 01-21-2021 , 13:18   Re: Player Speed
Reply With Quote #2

If you're using amxmodx 1.8.3 or later, you can use Ham_CS_Player_ResetMaxSpeed to "hook" the moment that the player's speed is reseted. In older versions, the zombie mode does something similar but using Ham_Item_PreFrame registered on "player" class, you can check that in cs_maxspeed_api that's included in zp50, although I'm not sure if it's called just once or once per frame as PreThink. You will have to do some tests to confirm this.
__________________









Last edited by CrazY.; 01-21-2021 at 13:25.
CrazY. is offline
SaBBa
Member
Join Date: Dec 2012
Old 01-21-2021 , 13:58   Re: Player Speed
Reply With Quote #3

Quote:
Originally Posted by CrazY. View Post
If you're using amxmodx 1.8.3 or later, you can use Ham_CS_Player_ResetMaxSpeed to "hook" the moment that the player's speed is reseted. In older versions, the zombie mode does something similar but using Ham_Item_PreFrame registered on "player" class, you can check that in cs_maxspeed_api that's included in zp50, although I'm not sure if it's called just once or once per frame as PreThink. You will have to do some tests to confirm this.
nope, unfortunately I am using 1.8.2, and my mod is not zp
__________________
SaBBa is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 01-21-2021 , 14:25   Re: Player Speed
Reply With Quote #4

You can use the second method in any mod you desire, I mentioned zombie plague just so you could find the source
__________________









Last edited by CrazY.; 01-21-2021 at 14:28.
CrazY. is offline
SaBBa
Member
Join Date: Dec 2012
Old 01-21-2021 , 17:11   Re: Player Speed
Reply With Quote #5

Quote:
Originally Posted by CrazY. View Post
You can use the second method in any mod you desire, I mentioned zombie plague just so you could find the source
Thanks for you help, I tried that way but didn't succeed, maybe because I am noob at pawn. But I have fixed it.

Changed this
PHP Code:
public fw_EvCurWeapon(id)
{
    new 
weaponid read_data(2)
    if(
gCurrentWeapon[id] != weaponid) {
        
gCurrentWeapon[id] = weaponid
        engfunc
(EngFunc_SetClientMaxspeedid250.0*speed[id])
    }
    return 
PLUGIN_HANDLED

to
PHP Code:
public fw_EvCurWeapon(id)
{
    if(
cs_get_user_zoom(id) != CS_SET_NO_ZOOM)
        return 
PLUGIN_CONTINUE

    engfunc
(EngFunc_SetClientMaxspeedid250.0*speed[id])
    return 
PLUGIN_CONTINUE

And I think that's it
__________________

Last edited by SaBBa; 01-21-2021 at 17:11.
SaBBa 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 23:14.


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