Bet System - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Bet System (
/showthread.php?tid=653838)
Bet System -
TadePoleMG - 14.05.2018
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.
Re: Bet System -
GTLS - 14.05.2018
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 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!!
}
Well, thats the rough idea of how to do it.. I hope you get the idea.. if some problem comes, you can ask again.
Re: Bet System -
TadePoleMG - 16.05.2018
Thank you
i did it.
You will rep'd.