Raised This Month: $51 Target: $400
 12% 

Correctly Getting Clients Speed?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SM9
Veteran Member
Join Date: Sep 2013
Location: United Kingdom
Old 09-10-2013 , 14:09   Correctly Getting Clients Speed?
Reply With Quote #1

Hello, I have been trying to make a stock to get clients speed correctly. The reason for this is because I need to set a boolean on the player based on his speed.

The following is throwing mismatches:

PHP Code:
stock GetClientSpeed(client)
{
    new 
CurSpeed GetEntPropFloat(clientProp_Data"m_flLaggedMovementValue");
    
    return 
floatCurSpeed;

Any ideas?

Cheers
SM9 is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 09-10-2013 , 14:33   Re: Correctly Getting Clients Speed?
Reply With Quote #2

I haven't verified that it works, but I have a feeling this is what you meant to write.
PHP Code:
stock Float:GetClientSpeed(client)
{
    new 
Float:CurSpeed GetEntPropFloat(clientProp_Data"m_flLaggedMovementValue");
    
    return 
CurSpeed;

__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
SM9
Veteran Member
Join Date: Sep 2013
Location: United Kingdom
Old 09-10-2013 , 14:41   Re: Correctly Getting Clients Speed?
Reply With Quote #3

Quote:
Originally Posted by Powerlord View Post
I haven't verified that it works, but I have a feeling this is what you meant to write.
PHP Code:
stock Float:GetClientSpeed(client)
{
    new 
Float:CurSpeed GetEntPropFloat(clientProp_Data"m_flLaggedMovementValue");
    
    return 
CurSpeed;

Hmm thats returning a derpy number

Speed: 1069134379
SM9 is offline
thetwistedpanda
Good Little Panda
Join Date: Sep 2008
Old 09-10-2013 , 14:46   Re: Correctly Getting Clients Speed?
Reply With Quote #4

You're likely trying to display it as an integer vs an actual float.
__________________
thetwistedpanda is offline
SM9
Veteran Member
Join Date: Sep 2013
Location: United Kingdom
Old 09-10-2013 , 14:48   Re: Correctly Getting Clients Speed?
Reply With Quote #5

Here is the code

PHP Code:
    new Float:RandSpeedMin 1.0;
    new 
Float:RandSpeedMax 1.6;
    new 
Float:RandSpeedHalf RandSpeedMin RandSpeedMax 2;
    new 
Float:RandSpeed GetRandomFloat(RandSpeedMinRandSpeedMax);
    
    new 
RandMinHealthNormal 100;
    new 
RandMaxHealthNormal zrr_lives 50 RandMinHealthNormal;
    new 
HpReductionMax RandMaxHealthNormal 25;
    new 
HpReductionMin RandMinHealthNormal 20;
    new 
RandHealthNormal GetRandomInt(RandMinHealthNormalRandMaxHealthNormal);
    new 
RandHealthFast GetRandomInt(RandMinHealthNormal HpReductionMinRandMaxHealthNormal HpReductionMax);
    
    
SetEntPropFloat(clientProp_Data"m_flLaggedMovementValue"FloatRandSpeed);
    
    new 
Float:CurSpeed GetClientSpeed(client);
    
    
PrintToChatAll("Speed: %d"Float:CurSpeed);
    
    
    if(
CurSpeed <= RandSpeedHalf)
    {
        
StandardZombie[client] = true;
        
FastZombie[client] = false
        
    }
    else if (
CurSpeed RandSpeedHalf)
    {
        
FastZombie[client] = true;
        
StandardZombie[client] = false;
    } 
SM9 is offline
thetwistedpanda
Good Little Panda
Join Date: Sep 2008
Old 09-10-2013 , 14:49   Re: Correctly Getting Clients Speed?
Reply With Quote #6

PrintToChatAll("Speed: %d", Float:CurSpeed);

You're trying to display it as an integer. It's also already a Float, you do not need to re-tag it as Float:
__________________

Last edited by thetwistedpanda; 09-10-2013 at 14:49.
thetwistedpanda is offline
SM9
Veteran Member
Join Date: Sep 2013
Location: United Kingdom
Old 09-10-2013 , 14:52   Re: Correctly Getting Clients Speed?
Reply With Quote #7

Quote:
Originally Posted by thetwistedpanda View Post
PrintToChatAll("Speed: %d", Float:CurSpeed);

You're trying to display it as an integer. It's also already a Float, you do not need to re-tag it as Float:
I am trying to display it for testing purposes only, But what I actually need is to compare it to the random speed that has just got set on the client to determine if he is a fast zombie or normal.

Cheers
SM9 is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 09-10-2013 , 14:56   Re: Correctly Getting Clients Speed?
Reply With Quote #8

Quote:
Originally Posted by xCoderx View Post
I am trying to display it for testing purposes only, But what I actually need is to compare it to the random speed that has just got set on the client to determine if he is a fast zombie or normal.

Cheers
Use %f instead of %d, or use RoundFloat on it first.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 09-10-2013 at 14:56.
Powerlord is offline
thetwistedpanda
Good Little Panda
Join Date: Sep 2008
Old 09-10-2013 , 14:56   Re: Correctly Getting Clients Speed?
Reply With Quote #9

http://wiki.alliedmods.net/Format_Cl...Mod_Scripting)
__________________

Last edited by thetwistedpanda; 09-10-2013 at 14:56.
thetwistedpanda is offline
SM9
Veteran Member
Join Date: Sep 2013
Location: United Kingdom
Old 09-10-2013 , 15:09   Re: Correctly Getting Clients Speed?
Reply With Quote #10

So how would I make CurSpeed like 1.x Instead of 1.xxxxx, I am really new to coding and have tried to use RoundFloat and RoundToNearestFloat but still no luck.

Cheers
SM9 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 22:05.


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