16.05.2013, 19:22
I was testing my lotto system and found i can win even without selecting a lotto number, LOL. It says the winning number is "0" when i didn't selected ANY number. I bet it happens when a player hasn't bought lotto number, because im testing with a friend and we won both with number 0:
pawn Код:
public Estrazione()
{
numerofortunato = random(50);
new str[128];
static WinnerID[MAX_PLAYERS];
new Winners = 0;
for(new i=0; i != MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
if(Biglietto[i] == numerofortunato)
{
WinnerID[Winners++] = i;
vincita = VINCITABASE+random(VINCITAEXTRA);
GivePlayerMoney(i,vincita);
format(str, sizeof(str), "Won at ~r~lottery~w~! (~g~%d ~w~CSCash)!",vincita);
GameTextForPlayer(i,str,5000,4);
}
Biglietto[i] = 0;
}
if(Winners > 0)
{
new echo[128];
for(new i=0,playerid=WinnerID[0]; i < Winners; i++,playerid=WinnerID[i])
{
GetPlayerName(playerid,nome,MAX_PLAYER_NAME);
format(str,sizeof(str),"** [LOTTO]: {8CE46C}%s (%d){FFFFFF} won the lottery! {C14124}(%d CSCash){FFFFFF} - Winning number: {C14124}%d{FFFFFF}",nome,playerid,vincita,numerofortunato);
format(echo,sizeof(echo),"04,01** [LOTTO]: %s (%d) won the lottery! (%d CSCash) - Winning number: %d",nome,playerid,vincita,numerofortunato);
SCMTA(-1,str);
IRC_GroupSay(gGroupID, IRC_CHANNEL, echo);
IRC_GroupSay(gGroupID, IRC_ACHANNEL, echo);
}
SCMTA(-1, "** Another lotto draw in {8CE46C}5 minutes.");
}
else
{
format(str,sizeof(str),"** [LOTTO]: For this draw lucky ticket number was: {C14124}%d{FFFFFF} - Nobody won -",numerofortunato);
SCMTA(-1,str);
format(str,sizeof(str),"04,01** [LOTTO]: For this draw lucky ticket number was: %d - Nobody won -",numerofortunato);
IRC_GroupSay(gGroupID, IRC_CHANNEL, str);
IRC_GroupSay(gGroupID, IRC_ACHANNEL, str);
SCMTA(-1,"** Another lotto draw in {8CE46C}5 minutes.");
}
return 1;
}