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

Solved Amxx 1.8.3 - random()


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 12-15-2017 , 13:25   Amxx 1.8.3 - random()
Reply With Quote #1

Hello, I find a bug in the random() native. It's returning a completely absurd number, about 50000 times bigger!

Last edited by CrazY.; 12-15-2017 at 14:15.
CrazY. is offline
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 12-15-2017 , 13:33   Re: Amxx 1.8.3 - random()
Reply With Quote #2

Code to reproduce?
__________________
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 12-15-2017 , 13:42   Re: Amxx 1.8.3 - random()
Reply With Quote #3

Code:
new Array:g_hArraySounds = ArrayCreate(64, 1);

Code:
ArrayGetString(g_hArraySounds, random(ArraySize(g_hArraySounds) - 1), szSound, charsmax(szSound));

Last edited by CrazY.; 12-15-2017 at 13:43.
CrazY. is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 12-15-2017 , 13:50   Re: Amxx 1.8.3 - random()
Reply With Quote #4

And what does this return? Better provide a full working code. Also, -1 is not needed here unless you want to ignore the last array entry on purpose.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 12-15-2017 , 14:09   Re: Amxx 1.8.3 - random()
Reply With Quote #5

My bad, the problem was in the -1 that I added.

Last edited by CrazY.; 12-15-2017 at 14:15.
CrazY. is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 12-15-2017 , 14:44   Re: Amxx 1.8.3 - random()
Reply With Quote #6

I don't see how that could be the problem. The -1 just made it ignore the last array entry when choosing a random one.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 12-15-2017 , 15:31   Re: Amxx 1.8.3 - random()
Reply With Quote #7

It's because there was only 1 item stored in the array.

Last edited by CrazY.; 12-15-2017 at 15:32.
CrazY. is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 12-15-2017 , 16:21   Re: Amxx 1.8.3 - random()
Reply With Quote #8

Ah, I see.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
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 15:49.


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