AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   how to know what speed the player is moving (https://forums.alliedmods.net/showthread.php?t=54264)

Voi 04-21-2007 07:11

how to know what speed the player is moving
 
the best if in prethink function

regalis 04-21-2007 09:00

Re: how to know what speed the player is moving
 
Code:

#include <amxmodx>
#include <fakemeta>

public plugin_init()
{
    register_forward(FM_PlayerPreThink, "fm_playerthink", 1)
}

public fm_playerthink(id)
{
    if(!is_user_alive(id)) return FMRES_IGNORED
    new speed = get_currentspeed(id)
}


// stock for getting the current player speed
stock Float:get_currentspeed(id)
{
    static Float:vel[3]
    pev(id,pev_velocity, vel)
    return vector_length(vel)
}

Hope that helps you!?

greetz regalis

PS: for further information look at my speedUP - plugin (http://forums.alliedmods.net/showthread.php?t=53603)

Nican 04-21-2007 10:09

Re: how to know what speed the player is moving
 
uh...
just a few changes:
PHP Code:

#include <amxmodx>
#include <fakemeta>

public plugin_init()
{
    
register_forward(FM_PlayerPreThink"fm_playerthink"1)
}

public 
fm_playerthink(id)
{
    if(!
is_user_alive(id)) return FMRES_IGNORED
    
new Float:speed get_currentspeed(id)
    
    
//what ever
    
\
    return 
FMRES_IGNORED
}


// stock for getting the current player speed
stock Float:get_currentspeed(id
{
    static 
Float:vel[3]
    
pev(id,pev_velocityvel)
    return 
vector_length(vel)



[ --<-@ ] Black Rose 04-21-2007 10:30

Re: how to know what speed the player is moving
 
Quote:

Originally Posted by Voi (Post 467879)
the best if in prethink function

It all depends on what you need it for.

Voi 04-21-2007 11:02

Re: how to know what speed the player is moving
 
thx u all!

i need it for new recoil menagement(CS Reality mod)

and it use the prethink function, i will add it now


edit:

it works! i just need to rewrite recoil menagement


All times are GMT -4. The time now is 06:44.

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