23.11.2011, 20:45
The random function requires a max value input of an integer.
An example of how your command might work. The random function evaluates the condition (9) meaning selective values of 0-9 which are actually 10 numbers. We then output the random selected number to the console. The if expression then checks if the value of rand is less than 7 (as the random selection begins at 0). If true it will output option 2, otherwise option is outputted.
Test command.
Код:
7/10 = 70% 3/10 = 30%.
pawn Код:
main()
{
new
rand = random(9)
;
printf("%d", rand);
if(rand < 7)
print("option 2");
else print("option 1");
}
pawn Код:
if (strcmp("/jump", cmdtext, true, 5) == 0)
{
new rand = random(9);
if(rand < 7) SendClientMessage(playerid, -1, "Option 2");
else SendClientMessage(playerid, -1, "Option 1");
return 1;
}