Thread: [Solved] pass 'enum' as parameter
View Single Post
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