Lotto - Random Player ID - Help!
#1

Hello Everyone!

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;
}
Something wrong with it, because it isn't selects only 1 player. Whats wrong with it? Please Help me!
Reply
#2

Please i really need help...
Reply
#3

You put the code in a loop and what happans if you put something is a loop, yes it gets called x times while a variable is changing
You just need to remove the loop and replace each "i" with "rand" and maybe get a better way to get the random player because this way doesnt include all players
Reply
#4

Quote:
Originally Posted by ♣ ⓐⓢⓢ
You put the code in a loop and what happans if you put something is a loop, yes it gets called x times while a variable is changing
You just need to remove the loop and replace each "i" with "rand" and maybe get a better way to get the random player because this way doesnt include all players
I love you! Thanks! :P
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)