14.05.2018, 14:50
First, have some global variables.
Set that value to -1 Under OnPlayerConnect to you know, reset the variable.
then, inside /bet command, set PlayerBet[playerid] to the a playerid he put the bet on.
after that when a player finishes the race, make it automatically by entering the CP or something or manually by using, /setwinner for admins.
Then, using a loop, just check what player had win.
Well, thats the rough idea of how to do it.. I hope you get the idea.. if some problem comes, you can ask again.
PHP код:
new PlayerBet[MAX_PLAYERS];
new RaceWinner;
PHP код:
PlayerBet[playerid] = -1;
after that when a player finishes the race, make it automatically by entering the CP or something or manually by using, /setwinner for admins.
Then, using a loop, just check what player had win.
PHP код:
new pCount;
foreach(new i : Player)
{
if(PlayerBet[i] >= 0)
pcount++;
}
for(new i = 0;i<pCount;i++)
{
if(PlayerBet[i] == RaceWinner)
{
SCM(i, -1, "You won the bet!");
GivePlayerMoney(i,5000); //You can give em money or something.
}
else if(PlayerBet[i] == -1) continue; //People who didnt placed bet.
else SCM(i, -1, "Sorry you lost the bet.");
PlayerBet[i] = -1; //We gotta reset the variable, making it ready for next race, right!!
}