Raised This Month: $ Target: $400
 0% 

Solved pass 'enum' as parameter


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
wilian159
Member
Join Date: Dec 2013
Old 07-24-2022 , 17:00   Re: pass 'enum' as parameter
Reply With Quote #3

Quote:
Originally Posted by fysiks View Post
My guess is that it will no longer know that it's a floating point value by not using PROB_ITEM_CHANCE strictly. Try applying the Float tag to array2D[][] where you're summing the values.

Also, when you say you tried something that doesn't work, you should provide that version of the code also so we can see what you tried and maybe fix it. It's hard to be sure what you actually tried when you describe it in words.
well, I want to know if there is a way to pass the 'enum' parameter in the stock,


PHP Code:
probItems(xProbItemssizeof(xProbItems), PROB_ITEM_CHANCE
PHP Code:
stock probItems(const array2D[][], array2DSizechance)
{
    new 
find = -1
    
new Float:totalProbability 0.0

    
for(new 0array2DSizei++)
        
totalProbability += array2D[i][chance]

    new 
Float:stopAt random_float(0.00001totalProbability)
    new 
Float:currentProbability 0.0

    
for(new 0array2DSizei++)
    {
        
currentProbability += array2D[i][chance]

        if(
currentProbability >= stopAt)
            
find i

        
if(find != -1)
            break
    }

    return (
find != -1) ? find : -1

because I tried some ways and it didn't work, so I want to know if there's a 'right' way
__________________
wilian159 is offline
 



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:40.


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