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

Checking float value


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
lostprophetpunk
Member
Join Date: Oct 2012
Old 01-17-2014 , 10:15   Checking float value
Reply With Quote #1

Heya there,

I have been wrapping my head around model scale etc today. However I am somewhat confused as to how to check a float variable.

Such as if I define it as:

new Float:rtest = 3.0;

How would I check that? As I grab the float value from the Prop_Data of an entity.
lostprophetpunk is offline
GsiX
gee, six eggs
Join Date: Aug 2012
Location: Land Below The Wind
Old 01-17-2014 , 11:02   Re: Checking float value
Reply With Quote #2

PrintToChatAll();
PrintToChat();

This should give human readable visual..
__________________
If i happen to insulted you unintentionally,
it was me and Google Translate who did it.
GsiX is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 01-17-2014 , 11:41   Re: Checking float value
Reply With Quote #3

Use a Format function (including the two GsiX mentioned) and the %f (aka floating point) format specifier.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
lostprophetpunk
Member
Join Date: Oct 2012
Old 01-17-2014 , 12:45   Re: Checking float value
Reply With Quote #4

Sorry if I wasn't clear.

But I am wanting to do something along the lines of...

Get a float from entity -> check to see if it's a certain value > act upon it being a certain value

So for instance I could do something if the float returned was 3.0
lostprophetpunk is offline
floube
SourceMod Donor
Join Date: Jan 2013
Location: Austria
Old 01-17-2014 , 13:07   Re: Checking float value
Reply With Quote #5

PHP Code:
new Float:test 3.0;

public 
NameHere() {
    if (
test == 3.0) {
        
// Do something
    
}

That's pretty much it.
__________________
floube is offline
GsiX
gee, six eggs
Join Date: Aug 2012
Location: Land Below The Wind
Old 01-17-2014 , 13:44   Re: Checking float value
Reply With Quote #6

PHP Code:
DoSomethingFloat:MyValueFloat:ValueToCompare )
{
    if( 
MyValue == ValueToCompare )
    {
        
// do the something
        
PrintToChatAll"Resault: %0.4f | %.4f"MyValueValueToCompare );
        
PrintToChatAll"===== My value is equal =====" );
    }
    else if( 
MyValue ValueToCompare )
    {
        
PrintToChatAll"Value Biggg" );
    }
    else if( 
MyValue ValueToCompare )
    {
        
PrintToChatAll"Value small" );
    }
    else
    {
        
PrintToChatAll"I m done guessing if there is any else statement here.." );
    }

Really is, your question is too common..
Our best answer is common in return..
__________________
If i happen to insulted you unintentionally,
it was me and Google Translate who did it.

Last edited by GsiX; 01-17-2014 at 13:45.
GsiX is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 01-17-2014 , 14:23   Re: Checking float value
Reply With Quote #7

Quote:
Originally Posted by floube View Post
PHP Code:
new Float:test 3.0;

public 
NameHere() {
    if (
test == 3.0) {
        
// Do something
    
}

That's pretty much it.
As long as you haven't been doing math operations to get that number, that's fine. Otherwise, you may run into issues with floating point rounding.
__________________
Not currently working on SourceMod plugin development.
Powerlord 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 07:31.


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