Quote:
Originally Posted by fysiks
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(xProbItems, sizeof(xProbItems), PROB_ITEM_CHANCE)
PHP Code:
stock probItems(const array2D[][], array2DSize, chance)
{
new find = -1
new Float:totalProbability = 0.0
for(new i = 0; i < array2DSize; i++)
totalProbability += array2D[i][chance]
new Float:stopAt = random_float(0.00001, totalProbability)
new Float:currentProbability = 0.0
for(new i = 0; i < array2DSize; i++)
{
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
__________________