Raised This Month: $ Target: $400
 0% 

pev(id, pev_velocity, velocity) | I'm confused


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 12-15-2011 , 13:11   pev(id, pev_velocity, velocity) | I'm confused
Reply With Quote #1

Hi

This is my little code.

PHP Code:
 
think
(id)
{
 
    
// just for testing
    
static Float:vel[3];
    
pev(idpev_velocityvel);
    
client_print(idprint_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(idpev_velocityvVelocity);
 
 
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?

Last edited by .Dare Devil.; 12-15-2011 at 13:12.
.Dare Devil. is offline
 



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 12:11.


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