[FilterScript] Duelsystem[zcmd]
#19

Hola, i added a little tutorial for the duelbet.

Little Tutorial(How to improve the duelbetsystem)

I thought about an improved duelbetsystem, but to make it we need a savingsystem, which isn't included in my filterscript, so i will explain now how to make it. The duelsystem should be added then into the gamemode.

First we need 2 new variables/constants in our enum. Like this:
pawn Код:
enum PlayerInfo
{
Duelkills,//Just add those two into your enum, just an example.
Dueldeaths// "
}
new pInfo[MAX_PLAYERS][PlayerInfo];
Now, when someone dies in a duel we higher the value of the duelkills/dueldeaths. This need to be added under OnPlayerDeath in if(Duelrounds[killerid] <=1) and if(Duelrounds[killerid] >1).

pawn Код:
pInfo[killerid][Duelkills]++;
pInfo[playerid][Dueldeaths]++;
So now we count the duelkills and dueldeaths of the players. Next step is to make something like "betquote".

Therefore i made this little formula: (It compares the ratio of player1 with the ratio of player2. The player with the better ratio will have a lower betquote.)

Код:
       1
      ----
  ratioplayer1
----------------   = Betquote (player1)
        1
       ---
  ratioplayer2
With a pawncode it looks like this:
pawn Код:
new Float: Quote1, Float: Quote2;
            Quote1 =floatdiv(floatdiv(pInfo[playerid][Dueldeaths],pInfo[playerid][Duelkills]),floatdiv(pInfo[PID][Dueldeaths],pInfo[PID][Duelkills]));
            Quote2 =floatdiv(floatdiv(pInfo[PID][Dueldeaths],pInfo[PID][Duelkills]),floatdiv(pInfo[playerid][Dueldeaths],pInfo[playerid][Duelkills]));
            format(string2,sizeof(string2),"DUEL: {FF00FF}Quote %s: %.2f Quote %s: %.2f.{F0F8FF} You can use now /duelbet [id] [amount] for this duel.",PlayerName(playerid),Quote1,PlayerName(PID),Quote2);
            SendClientMessageToAll(COLOR_AQUA,string2);
Now we add this piece of code under the /accept command and under the public DelayedDuelSpawn(playerid).

Last thing we need now is to really give (the money the player bet on the duel * the betquote) the won money to the player.


Therefore we need to go to the OnPlayerDeath callback and there we add the following code after we loop through the players which had a bet on the duel.(Under this: if(DuelbetPlayer[i] == killerid) )

pawn Код:
new string[128],Float:Quote,Winamount;
                    Quote =floatdiv(floatdiv(pInfo[killerid][Dueldeaths],pInfo[killerid][Duelkills]),floatdiv(pInfo[playerid][Dueldeaths],pInfo[playerid][Duelkills]));//That's the quote of the duelwinner.
                    format(string,sizeof(string),"* You won %f from your duelbet.",Duelbet[i]*Quote);//The amount the player bet * the quote of the duelwinner.
                    SendClientMessage(i,COLOR_AQUA,string);
                    Winamount = floatround(Duelbet[i] * Quote,floatround_round);//The winamount is the amount the player bet * the quote. We need to round this float to an integer to give the money later to the player.
                    GivePlayerMoney(i,Winamount);//Here we give the winamount to the player.
                    GivePlayerMoney(i,Duelbet[i]);//And here we give the amount back which was placed on that duel.
                    Duelbet[i] = 0;
That's it. With this piece of code you can make the duelbetsystem way better. Look at site 1 for the complete version.
Reply


Messages In This Thread
Duelsystem[zcmd] - by Flori - 29.12.2014, 12:56
Re: Duelsystem[zcmd] - by SpikY_ - 29.12.2014, 12:58
Re: Duelsystem[zcmd] - by Younes44 - 29.12.2014, 12:59
Re: Duelsystem[zcmd] - by Pitter - 29.12.2014, 13:15
Re: Duelsystem[zcmd] - by VincenzoDrift - 29.12.2014, 13:24
Re: Duelsystem[zcmd] - by Ryz - 29.12.2014, 13:25
Re: Duelsystem[zcmd] - by Pottus - 29.12.2014, 13:28
AW: Re: Duelsystem[zcmd] - by Flori - 29.12.2014, 13:30
Re: Duelsystem[zcmd] - by Arastair - 29.12.2014, 15:07
Re: Duelsystem[zcmd] - by Bingo - 29.12.2014, 15:08
Re: Duelsystem[zcmd] - by Battlezone - 29.12.2014, 15:34
AW: Duelsystem[zcmd] - by Flori - 29.12.2014, 16:41
Re: Duelsystem[zcmd] - by AgusZ - 29.12.2014, 16:55
AW: Duelsystem[zcmd] - by Flori - 29.12.2014, 18:02
Re: Duelsystem[zcmd] - by JeaSon - 29.12.2014, 18:07
AW: Duelsystem[zcmd] - by Flori - 30.12.2014, 07:34
AW: Duelsystem[zcmd] - by Flori - 30.12.2014, 09:18
Re: Duelsystem[zcmd] - by MattyMatty - 31.12.2014, 01:37
AW: Duelsystem[zcmd] - by Flori - 31.12.2014, 09:09
Re: Duelsystem[zcmd] - by Vizi10 - 07.10.2017, 13:33

Forum Jump:


Users browsing this thread: 4 Guest(s)