Raised This Month: $ Target: $400
 0% 

Why wont this calculate the k/d ratio?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bilal Pro
Senior Member
Join Date: Mar 2012
Location: Holland
Old 04-22-2012 , 11:36   Why wont this calculate the k/d ratio?
Reply With Quote #1

Hello people,

Im using natives to get frags/deaths Why wont this calculate the k/d ratio

PHP Code:
formatex(szTextcharsmax(szText), "K/D Ratio: \r%.2f"jb_get_user_frags(id) / jb_get_user_death(id)) 
__________________
  • Point System with rank titles for sale [X] [100% private]
  • VIP Menu for sale [X] [100% private]
  • HnS shop more features for sale [X] [100% private]
Contact: Bilalzaandam1234, on steam if you are interested.
Bilal Pro is offline
claudiuhks
Yam Inside®™℠
Join Date: Jan 2010
Location: Living Randomly
Old 04-22-2012 , 11:51   Re: Why wont this calculate the k/d ratio?
Reply With Quote #2

It's unable to divide with zero.
If there are deaths, KPD will be equal with the result of division between kills and deaths.
Else, if there are no deaths, KPD will be equal with kills because it's now allowed to divide with zero.

PHP Code:
static FloatfKPDiKillsiDeaths;
iKills GetKillsiPlayer ), iDeaths GetDeathsiPlayer );
fKPD iDeaths floatiKills ) / floatiDeaths ) : floatiKills );

/*
  if( iDeaths > 0 ) fKPD = float( iKills ) / float( iDeaths );
  else if( iDeaths == 0 ) fKPD = float( iKills );
*/

client_printiPlayerprint_chat"KPD %0.2f"fKPD );

// Example output: KPD 1.74 
__________________

Last edited by claudiuhks; 04-22-2012 at 12:02.
claudiuhks is offline
Send a message via MSN to claudiuhks Send a message via Yahoo to claudiuhks Send a message via Skype™ to claudiuhks
Bilal Pro
Senior Member
Join Date: Mar 2012
Location: Holland
Old 04-22-2012 , 11:55   Re: Why wont this calculate the k/d ratio?
Reply With Quote #3

I didn't understand that
__________________
  • Point System with rank titles for sale [X] [100% private]
  • VIP Menu for sale [X] [100% private]
  • HnS shop more features for sale [X] [100% private]
Contact: Bilalzaandam1234, on steam if you are interested.
Bilal Pro is offline
Old 04-22-2012, 12:01
BadJoke
This message has been deleted by asherkin. Reason: Spam.
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-22-2012 , 15:13   Re: Why wont this calculate the k/d ratio?
Reply With Quote #4

Quote:
Originally Posted by Bilal Pro View Post
I didn't understand that
Well, your first mistake was trying to divide two integers (called integer division) which does not work like it would on a calculator. You have to make them floating point values before you can divide them.

Also, as he mentioned, you have to check for the case where you would be dividing by zero which is not allowed.
__________________
fysiks is offline
Bilal Pro
Senior Member
Join Date: Mar 2012
Location: Holland
Old 04-23-2012 , 10:36   Re: Why wont this calculate the k/d ratio?
Reply With Quote #5

Solved
__________________
  • Point System with rank titles for sale [X] [100% private]
  • VIP Menu for sale [X] [100% private]
  • HnS shop more features for sale [X] [100% private]
Contact: Bilalzaandam1234, on steam if you are interested.
Bilal Pro 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:45.


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