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

Solved Random func.


Post New Thread Reply   
 
Thread Tools Display Modes
Natsheh
Veteran Member
Join Date: Sep 2012
Old 06-12-2017 , 13:46   Re: Random func.
Reply With Quote #11

PHP Code:
new iNum random_num(05000)
new 
sString[5];
num_to_str(iNumsStringcharsmax(sString))
if(
sString[0]) sString[strlen(sString)-1] = '0';
iNum str_to_num(sString
Last digit will be 0 if its 4937 it will be 4930.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 06-12-2017 at 13:48.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-12-2017 , 20:38   Re: Random func.
Reply With Quote #12

Just reduce your min and max by a factor of 10 and then multiply by 10. It's the same thing.
__________________
fysiks is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 06-13-2017 , 03:58   Re: Random func.
Reply With Quote #13

Quote:
Originally Posted by Natsheh View Post
PHP Code:
new iNum random_num(05000)
new 
sString[5];
num_to_str(iNumsStringcharsmax(sString))
if(
sString[0]) sString[strlen(sString)-1] = '0';
iNum str_to_num(sString
Last digit will be 0 if its 4937 it will be 4930.
That will work with numbers only above 10, how do you expect that to work on 9 ?
__________________
edon1337 is offline
DjSoftero
Veteran Member
Join Date: Nov 2014
Location: Lithuania
Old 06-13-2017 , 04:18   Re: Random func.
Reply With Quote #14

Quote:
Originally Posted by edon1337 View Post
That will work with numbers only above 10, how do you expect that to work on 9 ?
it becomes 0, as 9 is the last digit. don`t see a problem.
__________________
retired chump
DjSoftero is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 06-13-2017 , 06:11   Re: Random func.
Reply With Quote #15

I like how everyone is ignoring Fysiks' posts.
PHP Code:
Random10(ab)
{
    return (
random_num(ab) / 10) * 10;

klippy is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 06-13-2017 , 06:16   Re: Random func.
Reply With Quote #16

Quote:
Originally Posted by KliPPy View Post
I like how everyone is ignoring Fysiks' posts.
PHP Code:
Random10(ab)
{
    return (
random_num(ab) / 10) * 10;

You do realize thats this..

PHP Code:
 return (random_num(ab) / 10) * 10
Is the same as this..
PHP Code:
 return random_num(ab); 
Should be return random_num(0, 500)*10
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 06-13-2017 at 06:46.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 06-13-2017 , 06:49   Re: Random func.
Reply With Quote #17

It's not the same. Read about integer division.

Last edited by klippy; 06-13-2017 at 06:49.
klippy is offline
DjSoftero
Veteran Member
Join Date: Nov 2014
Location: Lithuania
Old 06-13-2017 , 09:18   Re: Random func.
Reply With Quote #18

Quote:
Originally Posted by Natsheh View Post
You do realize thats this..

PHP Code:
 return (random_num(ab) / 10) * 10
Is the same as this..
PHP Code:
 return random_num(ab); 
Should be return random_num(0, 500)*10
when you divide 9 by 10 it becomes 0
__________________
retired chump
DjSoftero is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 06-13-2017 , 09:20   Re: Random func.
Reply With Quote #19

Oh yes i forgot it cant be a floatbecause its not. Predefined as afloat silly me.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 06-13-2017 at 09:21.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
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 23:53.


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