31.12.2014, 16:01
there is no reason to use floats here, leave the comma away and compare integer values which is faster
I use a random value of 10001 to get 0 - 10000 which represents the 100% with two fractional digits
I use a random value of 10001 to get 0 - 10000 which represents the 100% with two fractional digits
pawn Код:
public TestePCT(playerid) {
new rand = random(10001); // 0 - 10000
if(rand <= 10)
return SendClientMessage(playerid, -1, "0.00 - 0.10");
if(rand <= 190)
return SendClientMessage(playerid, -1, "0.11 - 1.90");
if(rand <= 300)
return SendClientMessage(playerid, -1, "1.91 - 3.00");
if(rand <= 500)
return SendClientMessage(playerid, -1, "3.01 - 5.00");
if(rand <= 1000)
return SendClientMessage(playerid, -1, "5.01 - 10.00");
if(rand <= 1500)
return SendClientMessage(playerid, -1, "10.01 - 15.00");
if(rand <= 2500)
return SendClientMessage(playerid, -1, "15.01 - 25.00");
if(rand <= 4000)
return SendClientMessage(playerid, -1, "25.01 - 40.00");
return SendClientMessage(playerid, -1, "40.01 - 100.00");
}