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

Dividing the numbers in sourcemod


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Touch
Member
Join Date: Apr 2010
Location: Ukraine
Old 08-31-2010 , 06:45   Dividing the numbers in sourcemod
Reply With Quote #1

Hello
I need to calculate the ratio player.
But there are problems with the script.
If I did not kill anybody or himself is not dead, then the script in console an error.
But if, as I had killed himself died a few times, then my ratio = 0.00000.

PHP Code:
new userkills GetClientFrags(client);
new 
userdeaths GetClientDeaths(client);
new 
Float:ratio;
ratio userkills userdeaths
Why is my ratio 0.0000?

Thx!
Touch is offline
Send a message via Skype™ to Touch
Lord Canistra
Senior Member
Join Date: Mar 2009
Location: Tallinn, Estonia
Old 08-31-2010 , 07:10   Re: Dividing the numbers in sourcemod
Reply With Quote #2

Frags & deaths are integer, not float.
Try
PHP Code:
ratio = (float)(userkills) / (float)(userdeaths
__________________
Lord Canistra is offline
miniman
Senior Member
Join Date: Aug 2009
Location: Israel
Old 08-31-2010 , 07:10   Re: Dividing the numbers in sourcemod
Reply With Quote #3

Quote:
Originally Posted by Touch View Post
Hello
I need to calculate the ratio player.
But there are problems with the script.
If I did not kill anybody or himself is not dead, then the script in console an error.
But if, as I had killed himself died a few times, then my ratio = 0.00000.

PHP Code:
new userkills GetClientFrags(client);
new 
userdeaths GetClientDeaths(client);
new 
Float:ratio;
ratio userkills userdeaths
Why is my ratio 0.0000?

Thx!
PHP Code:
new Float:userkills=float(GetClientFrags(client));
new 
Float:userdeaths float(GetClientDeaths(client));
new 
Float:ratio;
ratio userkills userdeaths
oh someone posted before me ^
miniman is offline
Touch
Member
Join Date: Apr 2010
Location: Ukraine
Old 08-31-2010 , 07:20   Re: Dividing the numbers in sourcemod
Reply With Quote #4

Thanks!
If kills 2 and deaths 1, ratio = 2.000000
Why 2.000000 instead of 2.0?
Touch is offline
Send a message via Skype™ to Touch
Master53
Veteran Member
Join Date: Dec 2009
Old 08-31-2010 , 08:22   Re: Dividing the numbers in sourcemod
Reply With Quote #5

Quote:
Originally Posted by Touch View Post
Thanks!
If kills 2 and deaths 1, ratio = 2.000000
Why 2.000000 instead of 2.0?

PHP Code:
RoundToNearest(Float:ratio); 
__________________
Master(d)



Master53 is offline
raydan
Senior Member
Join Date: Aug 2006
Old 08-31-2010 , 08:25   Re: Dividing the numbers in sourcemod
Reply With Quote #6

Quote:
Originally Posted by Touch View Post
Hello
I need to calculate the ratio player.
But there are problems with the script.
If I did not kill anybody or himself is not dead, then the script in console an error.
But if, as I had killed himself died a few times, then my ratio = 0.00000.

PHP Code:
new userkills GetClientFrags(client);
new 
userdeaths GetClientDeaths(client);
new 
Float:ratio;
ratio userkills userdeaths
Why is my ratio 0.0000?

Thx!
if userdeaths is 0, your script will
raydan is offline
Touch
Member
Join Date: Apr 2010
Location: Ukraine
Old 08-31-2010 , 08:31   Re: Dividing the numbers in sourcemod
Reply With Quote #7

Quote:
Originally Posted by Master53 View Post
PHP Code:
RoundToNearest(Float:ratio); 
sorry...
all the same - 0.000000
What to do?
Touch is offline
Send a message via Skype™ to Touch
Touch
Member
Join Date: Apr 2010
Location: Ukraine
Old 08-31-2010 , 08:41   Re: Dividing the numbers in sourcemod
Reply With Quote #8

all float = 0.00000
userdeaths = 0.00000, userkills = 0.00000
help me

Last edited by Touch; 08-31-2010 at 08:45.
Touch is offline
Send a message via Skype™ to Touch
Master53
Veteran Member
Join Date: Dec 2009
Old 08-31-2010 , 08:50   Re: Dividing the numbers in sourcemod
Reply With Quote #9

Quote:
Originally Posted by Touch View Post
all float = 0.00000
userdeaths = 0.00000, userkills = 0.00000
help me
you could try

Code:
RoundToCeil

 	 	Syntax: native RoundToCeil(Float:value); 

Usage:  value			Input value to be rounded.Notes: Rounds a float to the next highest integer value.		  		 		

Return: Rounded value.
__________________
Master(d)



Master53 is offline
Touch
Member
Join Date: Apr 2010
Location: Ukraine
Old 08-31-2010 , 08:52   Re: Dividing the numbers in sourcemod
Reply With Quote #10

no result... 0.000000
Touch is offline
Send a message via Skype™ to Touch
Reply


Thread Tools
Display Modes

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 03:16.


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