Raised This Month: $32 Target: $400
 8% 

Dividing the numbers in sourcemod


Post New Thread Reply   
 
Thread Tools Display Modes
Death [GER]
Senior Member
Join Date: Mar 2010
Old 09-01-2010 , 09:29   Re: Dividing the numbers in sourcemod
Reply With Quote #21

!Deaths means if it doesnt have a value aka it is 0?

Where is an integer expected?

And i already said cant test because i am at work.

I also just wanted to tell the one posting before me that he was wrong and his script was.. shit.. and made a stock.
Death [GER] is offline
Monkeys
Veteran Member
Join Date: Jan 2010
Old 09-01-2010 , 09:43   Re: Dividing the numbers in sourcemod
Reply With Quote #22

Sorry, my mistake, early morning ;p

And it expects an integer return because you didn't specify anything else as a return value.
or:
stock Float:GetClientKillDeathRatio(Client)
__________________
Get a lid on that zombie,
he's never gonna be alri-i-ight.
Oooh get a lid on that zombie,
or he's gonna feed all night.
Monkeys is offline
dirka_dirka
Veteran Member
Join Date: Nov 2009
Old 09-01-2010 , 09:45   Re: Dividing the numbers in sourcemod
Reply With Quote #23

if !0 = true.. return 0
if !1 = false.. do the math

stock GetClientKillDeathRatio(Client)
.. ninjad
dirka_dirka is offline
FaTony
Veteran Member
Join Date: Aug 2008
Old 09-01-2010 , 09:51   Re: Dividing the numbers in sourcemod
Reply With Quote #24

Also these natives would throw an error if client is not in game. I'd rather return bool and pass ratio by reference. Or return -1.0 on error, but I prefer bool.
FaTony is offline
p3tsin
Senior Member
Join Date: Sep 2005
Location: Finland
Old 09-01-2010 , 15:30   Re: Dividing the numbers in sourcemod
Reply With Quote #25

Quote:
Originally Posted by FaTony View Post
Also these natives would throw an error if client is not in game. I'd rather return bool and pass ratio by reference. Or return -1.0 on error, but I prefer bool.
You'd be writing very bad code if you didn't know if the client was in-game or not before trying to get his kill ratio. Besides, if the execution isn't stopped in this function, it will be when you try to print the ratio to the client.
__________________
plop
p3tsin is offline
FaTony
Veteran Member
Join Date: Aug 2008
Old 09-02-2010 , 08:24   Re: Dividing the numbers in sourcemod
Reply With Quote #26

I prefer my functions to always validate all arguments passed to them. That really helps if you have 10k+ lines or writing code for other not-so-good-at-programming people.
FaTony 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 02:27.


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