Raised This Month: $ Target: $400
 0% 

Solved pass 'enum' as parameter


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-24-2022 , 18:47   Re: pass 'enum' as parameter
Reply With Quote #10

My original suggestion works perfectly for me:

PHP Code:
enum myEnum {NAME[32], Float:CHANCE};
new 
myArray[][myEnum] = 
{
    {
"item1"10.1},
    {
"item2"20.1},
    {
"item3"30.1},
    {
"item4"40.1},
}


public 
cmdTest()
{
    
server_print("sum:  %f"myFunction(myArraysizeof myArrayCHANCE))
}

stock Float:myFunction(array[][], size, const index)
{
    new 
Float:fProb 0.0
    
for( new 0sizei++ )
    {
        
fProb += Float:array[i][index]
    }
    return 
fProb

Output is:

Code:
sum:  100.400001
Which is correct. Without the "Float:" where I said to put it, I get

Code:
sum:  4409498112.000000
__________________
fysiks 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