04.04.2014, 17:34
Ok, not really sure how well I'll explain this but I'll give it a shot XD
So first, a variable called "winner" is set as -1.
Then this for loop is searching every players variables to see if they have won the lotto.
So when the loop finds a player that HAS a winning ticket, it will set 'winner' as the player's ID.
So if I'm ID 5 and I won the lotto, 'winner' will be set as 5.
In this case, 'winner' is the same as your 'playerid'.
So the code you had was:
But because 'winner' is the real ID of the player that won the lotto, we need to replace playerid with 'winner'
So first, a variable called "winner" is set as -1.
Then this for loop is searching every players variables to see if they have won the lotto.
pawn Код:
new winner = -1; //Winners ID variable
for(new i; i<MAX_PLAYERS; i++) //checks through all players
{
if(!IsPlayerConnected(i)) continue; //Players not connected
if(GetPVarInt(i, "LottoNumber") == Lnum) winner = i; //If the players number is the winning number
SetPVarInt(i, "LottoNumber", 0); //Resets the number
}
So if I'm ID 5 and I won the lotto, 'winner' will be set as 5.
In this case, 'winner' is the same as your 'playerid'.
So the code you had was:
pawn Код:
SetPlayerScore(playerid, GetPlayerScore(playerid) + 5);
pawn Код:
SetPlayerScore(winner, GetPlayerScore(playerid) + 5);

