SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts

Reply
 
Thread Tools Display Modes
Old 29/12/2014, 01:56 PM   #1
Flori
Huge Clucker
 
Flori's Avatar
 
Join Date: Sep 2014
Location: Germany
Posts: 352
Reputation: 26
Default Duelsystem[zcmd]

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.

Last edited by Flori; 31/12/2014 at 10:03 AM.
Flori is offline   Reply With Quote
Old 29/12/2014, 01:58 PM   #2
SpikY_
High-roller
 
SpikY_'s Avatar
 
Join Date: Jul 2014
Posts: 1,247
Reputation: 128
Default Re: Duelsystem[zcmd]

Nice release
__________________
-
SpikY_ is offline   Reply With Quote
Old 29/12/2014, 01:59 PM   #3
Younes44
Gangsta
 
Younes44's Avatar
 
Join Date: Oct 2013
Posts: 764
Reputation: 78
Default Re: Duelsystem[zcmd]

Good Job dude..
+Rep
__________________
Left SA:MP, and not avalaible anymore!!
Thanks samp for awesome moments, i enjoy!! Goodbye!
ModernFreeroam: www.mf-samp.com , IP:94.23.255.30:7777
CounterTerroristUnit: www.ctu.w4f.eu , IP:87.98.243.201:6969
xSF: www.xsfserver.com , IP: 87.98.243.201:6969
Exm: www.exmserv.me , IP: exmserv.me:7777
Underground Stunting: www.ustunting.com , IP:145.239.3.225:7777

Thanks everyone,for the awesome moments,
Regards, COD Ghosts owner.
Younes44 ,YOuNeS_Dz ,WarZ ,Bryan_ , Kaneki
Younes44 is offline   Reply With Quote
Old 29/12/2014, 02:15 PM   #4
Pitter
Little Clucker
 
Join Date: Dec 2014
Posts: 34
Reputation: 7
Default Re: Duelsystem[zcmd]

Nice.
Pitter is offline   Reply With Quote
Old 29/12/2014, 02:24 PM   #5
VincenzoDrift
Little Clucker
 
VincenzoDrift's Avatar
 
Join Date: Jun 2014
Posts: 47
Reputation: 3
Default Re: Duelsystem[zcmd]

Nice
__________________
Sorry for my bad english
VincenzoDrift is offline   Reply With Quote
Old 29/12/2014, 02:25 PM   #6
Ryz
Huge Clucker
 
Ryz's Avatar
 
Join Date: Feb 2014
Posts: 481
Reputation: 29
Default Re: Duelsystem[zcmd]

EDIT: nice
__________________
***
Ryz is offline   Reply With Quote
Old 29/12/2014, 02:28 PM   #7
Pottus
High-roller
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 4,899
Reputation: 1321
Default Re: Duelsystem[zcmd]

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);
Pottus is offline   Reply With Quote
Old 29/12/2014, 02:30 PM   #8
Flori
Huge Clucker
 
Flori's Avatar
 
Join Date: Sep 2014
Location: Germany
Posts: 352
Reputation: 26
Default AW: Re: Duelsystem[zcmd]

Thank you guys.

Quote:
Originally Posted by Pottus View Post
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.

Last edited by Flori; 03/01/2015 at 01:40 PM.
Flori is offline   Reply With Quote
Old 29/12/2014, 04:07 PM   #9
Arastair
Gangsta
 
Join Date: Jun 2014
Posts: 783
Reputation: 49
Default Re: Duelsystem[zcmd]

Nice realease jo
Arastair is offline   Reply With Quote
Old 29/12/2014, 04:08 PM   #10
Bingo
High-roller
 
Bingo's Avatar
 
Join Date: Jul 2012
Location: United Arab Emirates.
Posts: 1,690
Reputation: 235
Default Re: Duelsystem[zcmd]

Great.

+rep
Bingo is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Tutorial] STRCMP and ZCMD - how to change your commands to ZCMD Swyft Tutorials 12 14/01/2015 10:58 PM
Looking for a zcmd alternative, or the latest zcmd. [REP++] Hoborific Scripting Help 4 09/05/2013 04:53 PM
Help Need in ZCMD Tuntun Scripting Help 5 10/10/2012 11:19 AM
Need Help ZCMD [C:\server\pawno\include\ZCMD.inc:85] TheB0ss123 Scripting Help 0 28/06/2012 04:35 AM
DuelSystem spd_sahil Scripting Help 1 21/10/2011 03:39 PM


All times are GMT. The time now is 05:11 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.