29.12.2014, 12:56
(
Last edited by Flori; 31/12/2014 at 09:03 AM.
)
Duelsystem
Hey guys,
i made a Duelsystem which i want to share now with everyone.
Features:
- Easy /duel [id], /accept and /cancel commands.
- /duellist command to see all running duels.
- /endduel command if you want to end the duel.
- /duelbet [id] [amount] command for duelbets.
- The duelmap made by myself some time ago.
- You can chose two duelweapons.
- You can chose the duelrounds.
- A final result.
- /duelhelp command
- /toggleduel command to enable/disable the duelinvitations
Information:
As there are many duelsystems with many parameters, i decided to make a duelsystem which is easy to handle. In my duelsystem you just need to type /duel [id]. When you type it, it will open a dialog with the first duelweapon to chose. Then a dialog with the second duelweapon, then the duelrounds.
When you have chosen the weapons and rounds the duelrequest has been sent. Then the opponent just need to type /accept or /cancel. When he don't respond, the request will be automatically denied after 30 seconds.
Commands: 8
- /duel [id]
- /accept
- /cancel
- /endduel
- /duellist
- /duelbet [id] [amount]
- /duelhelp
- /toggleduel (for admins to enable/disable the duelinvitations)
Screenshots:
You use /duel [id]
The request has been accepted
You receive a duelrequest
When you /accept the request
When the duel ends
I placed a bet(Normally the two duelers can't bet on their own duels. Just for the picture. )
My duelbet was wrong. When your bet is correct it will doubles the amount.
The /duelhelp command
The /duellist comamnd
The /endduel command
All pictures: http://imgur.com/a/S9KAw
Bugs/Issues?
When you find bugs please write me a message so i can fix them.
Any questions?
Download/Pastebin:
http://pastebin.com/Ack1ecL8
Tips/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 Code:
enum PlayerInfo
{
Duelkills,//Just add those two into your enum, just an example.
Dueldeaths// "
}
new pInfo[MAX_PLAYERS][PlayerInfo];
pawn Code:
pInfo[killerid][Duelkills]++;
pInfo[playerid][Dueldeaths]++;
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.)
Code:
1 ---- ratioplayer1 ---------------- = Betquote (player1) 1 --- ratioplayer2
pawn Code:
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);
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 Code:
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;
Thank you for reading.