Bet System
#1

Hi guys

Can anyone help to make a bet system means when gamomode starts player has 1 minute to put bet(like /bet id money) on someone, By putting bet his money will double if the person won the race(Ist Position) on which the player putted bet else if disconnected then msg will be (Player disconnected on which you putted bet) or if player not wins the race then msg will be you lost your bet.

Sorry for my bad english,
I hope i will recieve my answer quickly.

Thank You.
Reply
#2

First, have some global variables.
PHP код:
 new PlayerBet[MAX_PLAYERS];
new 
RaceWinner
Set that value to -1 Under OnPlayerConnect to you know, reset the variable.
PHP код:
 PlayerBet[playerid] = -1
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.
PHP код:
new pCount;
foreach(new 
Player)
{
      if(
PlayerBet[i] >= 0)
           
pcount++;
}

for(new 
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!!

Well, thats the rough idea of how to do it.. I hope you get the idea.. if some problem comes, you can ask again.
Reply
#3

Thank you i did it.

You will rep'd.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)