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 i = 0; i < array2DSize; i++)
totalProbability += array2D[i][PROB_ITEM_CHANCE]
new Float:stopAt = random_float(0.00001, totalProbability)
new Float:currentProbability = 0.0
for(new i = 0; i < array2DSize; i++)
{
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[][], array2DSize, enumToCheck)
I tested several ways, but it didn't work, bugged the sum of 'float' and other things
__________________