08.07.2009, 10:42
Hello Everyone!
I have this code:
Something wrong with it, because it isn't selects only 1 player. Whats wrong with it? Please Help me!
I have this code:
pawn Код:
public lotto()
{
new rand;
rand = random(GetMaxPlayers());
if(IsPlayerConnected(rand)) goto nyertes;
if(!IsPlayerConnected(rand)) goto nincsnyertes;
for (new i = 0; i < MAX_PLAYERS; i++)
{
//===
nyertes:
new string[256];
new WinnerID;
new WinnerName[MAX_PLAYER_NAME];
WinnerID = i;
GetPlayerName(i, WinnerName, sizeof(WinnerName));
format(string,sizeof(string),"%s (%i) Has Won The Lottery! Jackpot: $%i . Congratulations!",WinnerName,WinnerID,jackpot);
SendClientMessageToAll(COLOR_GREEN,string);
new string3[256];
format(string3,sizeof(string3),"~w~won the ~g~lottery~w~!~n~~g~$%i",jackpot);
GameTextForPlayer(i,string3,4000,3);
GivePlayerMoney(i, jackpot);
oscore = GetPlayerScore(i);
SetPlayerScore(i, oscore +5);
ResetJackpot();
//===
nincsnyertes:
new string2[256];
format(string2,sizeof(string2),"Nobody Has Won The Lottery Today! Jackpot: $%i .",jackpot);
SendClientMessageToAll(COLOR_GREEN,string2);
//===
}
return 1;
}