19.01.2016, 12:56
A bit shorter:
"random" returns values from 0 to value-1 (checking if "random" was below 0 is useless), so with the code above it can return values from 0 to 99, and we check if the valid value is from 0 to 9 (this would be 10%).
PHP код:
new PlayerLuck[playerid]; // <------- Variable that player's luck stored in.
if(random(100) < PlayerLuck[playerid])
//> Success (random gives a value from 0 to 9)
else
//> Fail (random gives a value from 10 to 99)