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

Solved pass 'enum' as parameter


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
wilian159
Member
Join Date: Dec 2013
Old 07-24-2022 , 16:42   pass 'enum' as parameter
Reply With Quote #1

I have that:

PHP Code:
enum _:xEnumProbItems PROB_ITEM_NAME[32], Float:PROB_ITEM_CHANCE }

new const 
xProbItems[][xEnumProbItems] =
{
    { 
"Chinelo"58.5 },
    { 
"Oculos"61.7 },
    { 
"Bazooka"0.01 },
    { 
"Rifle"0.1 },
    { 
"Pistola"2.5 },

and that

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

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

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

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

        if(
currentProbability >= stopAt)
            
find i

        
if(find != -1)
            break
    }

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

notice in the 'stock' that I use the 'enum: PROB_ITEM_CHANCE', but I don't want to use it this way, I want to pass the column 'chance' as a parameter in the stock, more or less like this

PHP Code:
probItems(const array2D[][], array2DSizeenumToCheck
I tested several ways, but it didn't work, bugged the sum of 'float' and other things
__________________

Last edited by wilian159; 07-24-2022 at 19:18.
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 02:16.


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