Hi
This is my little code.
PHP Code:
think(id)
{
// just for testing
static Float:vel[3];
pev(id, pev_velocity, vel);
client_print(id, print_chat, "[SPEED: %i %i %i]", vel[0], vel[1], vel[2])
if(fm_get_ent_speed(id) < 50)
{
g_nextthink = 5.0
}
else if(fm_get_ent_speed(id) < 100)
{
g_nextthink = 4.0
}
else if(fm_get_ent_speed(id) < 200)
{
g_nextthink = 4.0
}
else if(fm_get_ent_speed(id) < 300)
{
g_nextthink = 2.0
}
else if(fm_get_ent_speed(id) < 400)
{
g_nextthink = 1.0
}
}
stock Float:fm_get_ent_speed(id)
{
if(!pev_valid(id))
return 0.0;
static Float:vVelocity[3];
pev(id, pev_velocity, vVelocity);
vVelocity[2] = 0.0;
return vector_length(vVelocity);
}
confusing place : how this working
PHP Code:
if(fm_get_ent_speed(id) < 50)
{
g_nextthink = 5.0
}
else if(fm_get_ent_speed(id) < 100)
{
g_nextthink = 4.0
}
else if(fm_get_ent_speed(id) < 200)
{
g_nextthink = 4.0
}
else if(fm_get_ent_speed(id) < 300)
{
g_nextthink = 2.0
}
else if(fm_get_ent_speed(id) < 400)
{
g_nextthink = 1.0
}
This code part is working fine.
When i slow, then think value will be small and when i are fast then think value will be high.
but
client_print show me a this
[SPEED: 102032010... 10302.... 0]
and when i jump
[SPEED: x x 1021322....]
the value that i have checked here
if(fm_get_ent_speed(id) < 400) < - ( this is how i check player speed, as i know the normal speed is 240, duck 120 , walk 160 or 180 )
is wrong but in game it work like i want, like i calculated in code.
it must work like this
PHP Code:
if(fm_get_ent_speed(id) < 50)
{
g_nextthink = 5.0
}
else if(fm_get_ent_speed(id) < 100)
{
g_nextthink = 4.0
}
else if(fm_get_ent_speed(id) < 200)
{
g_nextthink = 4.0
}
else if(fm_get_ent_speed(id) < 300)
{
g_nextthink = 2.0
}
else if(fm_get_ent_speed(id) < 400)
{
g_nextthink = 1.0
}
else // this will be chosen
{
g_nextthink = 0.5
}
because value what client_print show is very high and not one of my checking list, i think client print show me a wrong numbers.
or how it work like it work?