30.03.2012, 18:59
Hello, i've made a lottery script which isn't working correctly, I need it to loop through all the players who have entered the lottery draw, here's my codes;
pawn Код:
CMD:buyticket(playerid, params[])
{
if(LotteryIsOn == 1) {
new string[128];
PlayerLotteryNumber[playerid] = random(1000)+5555;
format(string, sizeof(string), "LOTTERY: Your number is %d, the lottery draw is in 1 minute. Good luck.", PlayerLotteryNumber[playerid]);
SendClientMessage(playerid, COLOR_WHITE, string);
EnterLotto[playerid] = 1;
}
else {
SendClientMessage(playerid, COLOR_WHITE, "INFO: The lottery isn't on.");
}
return 1;
}
pawn Код:
forward LottoDraw();
public LottoDraw() {
foreach(Player, i) {
if(EnterLotto[i] != 0) {
new LottoWinner1 = random(PlayerLotteryNumber[i]);
if(LottoWinner[i] == LottoWinner1) {
new string[128];
format(string, sizeof(string), "LOTTERY: The lottery winner is %s(%d) with the ticket %d, they have won a total of $150!", Name(i), i, PlayerLotteryNumber[i]);
SendClientMessageToAll(COLOR_WHITE, string);
LotteryIsOn = 0;
EnterLotto[i] = 0;
}
else {
SendClientMessageToAll(COLOR_WHITE, "INFO: There was no winner.");
}
}
else {
SendClientMessageToAll(COLOR_WHITE, "INFO: The lottery was canceled due to nobody entering.");
}
}
return 1;
}