Duelsystem[zcmd] -
Flori - 29.12.2014
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];
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 Code:
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.)
Code:
1
----
ratioplayer1
---------------- = Betquote (player1)
1
---
ratioplayer2
With a pawncode it looks like this:
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);
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 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;
That's it. With this piece of code you can make the duelbetsystem way better.
Thank you for reading.
Re: Duelsystem[zcmd] -
SpikY_ - 29.12.2014
Nice release
Re: Duelsystem[zcmd] -
Younes44 - 29.12.2014
Good Job dude..
+Rep
Re: Duelsystem[zcmd] -
Pitter - 29.12.2014
Nice.
Re: Duelsystem[zcmd] -
VincenzoDrift - 29.12.2014
Nice
Re: Duelsystem[zcmd] -
Ryz - 29.12.2014
EDIT: nice
Re: Duelsystem[zcmd] -
Pottus - 29.12.2014
You could really save a lot of lines here by creating common functions instead of using two lines for stuff like this.
pawn Code:
GivePlayerWeapon(PID,Duelweap1[PID],2000);
GivePlayerWeapon(playerid,Duelweap1[playerid],2000);
GivePlayerWeapon(PID,Duelweap2[PID],2000);
GivePlayerWeapon(playerid,Duelweap2[playerid],2000);
TogglePlayerControllable(PID,0);
TogglePlayerControllable(playerid,0);
SetPlayerArmour(PID,100);
SetPlayerHealth(PID,100);
SetPlayerArmour(playerid,100);
SetPlayerHealth(playerid,100);
AW: Re: Duelsystem[zcmd] -
Flori - 29.12.2014
Thank you guys.
Quote:
Originally Posted by Pottus
You could really save a lot of lines here by creating common functions instead of using two lines for stuff like this.
pawn Code:
GivePlayerWeapon(PID,Duelweap1[PID],2000); GivePlayerWeapon(playerid,Duelweap1[playerid],2000); GivePlayerWeapon(PID,Duelweap2[PID],2000); GivePlayerWeapon(playerid,Duelweap2[playerid],2000); TogglePlayerControllable(PID,0); TogglePlayerControllable(playerid,0); SetPlayerArmour(PID,100); SetPlayerHealth(PID,100); SetPlayerArmour(playerid,100); SetPlayerHealth(playerid,100);
|
True.
I will look for it later.
Edit: It's not really needed, but i took that tip serious and made it. Code has after it like 20 lines less.
Re: Duelsystem[zcmd] -
Arastair - 29.12.2014
Nice realease jo
Re: Duelsystem[zcmd] -
Bingo - 29.12.2014
Great.
+rep
Re: Duelsystem[zcmd] -
Battlezone - 29.12.2014
Very useful, +rep
AW: Duelsystem[zcmd] -
Flori - 29.12.2014
Thank you.
Re: Duelsystem[zcmd] -
AgusZ - 29.12.2014
Very Nice Bro +Rep
AW: Duelsystem[zcmd] -
Flori - 29.12.2014
Hehe, thx
Re: Duelsystem[zcmd] -
JeaSon - 29.12.2014
good job
AW: Duelsystem[zcmd] -
Flori - 30.12.2014
Ty.
AW: Duelsystem[zcmd] -
Flori - 30.12.2014
Updated
Look at site 1 for the updated version.
Re: Duelsystem[zcmd] -
MattyMatty - 31.12.2014
Thats my boy FloJo making badass filterscripts yo
!
good job man
AW: Duelsystem[zcmd] -
Flori - 31.12.2014
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.
Re: Duelsystem[zcmd] -
xRadical3 - 07.10.2017
Good Work!