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

Giving a function a random number as default param


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xerox8521
Senior Member
Join Date: Sep 2011
Old 02-17-2014 , 07:34   Giving a function a random number as default param
Reply With Quote #1

Hi, so i have a function which should have an optional float value now my question is. Is there any way to make a random default value for it ?

so instead:

PHP Code:
stock Function(clientbool:toggleFloat:value=0.0)
{
    
//stuff here

like this. This however gives an error
PHP Code:
stock Function(clientbool:toogleFloat:value GetRandomFloat(0,1))
{
   
// stuff here


Last edited by xerox8521; 02-17-2014 at 07:34.
xerox8521 is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 02-17-2014 , 07:36   Re: Giving a function a random number as default param
Reply With Quote #2

Use an arbitrary value like -1.0

Then...
If(arg = -1.0)
arg = GetRandomFloat(0.0, 1.0);
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.
friagram is offline
xerox8521
Senior Member
Join Date: Sep 2011
Old 02-17-2014 , 07:39   Re: Giving a function a random number as default param
Reply With Quote #3

Ya should have come in mind. Thanks!
xerox8521 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:30.


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