Register for your free account! | Forgot your password?

You last visited: Today at 20:04

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[Release]PkTournament

Discussion on [Release]PkTournament within the CO2 PServer Guides & Releases forum part of the CO2 Private Server category.

Reply
 
Old   #1
 
Arcо's Avatar
 
elite*gold: 0
Join Date: Oct 2009
Posts: 8,765
Received Thanks: 5,291
[Release]PkTournament

Well hunterman01 and Saint coded this, but it didn't work at all
So I did a complete recode and it works great.
Here it is.
First make a new class file (cs file) and name it PKTournament.cs and place it in the Features folder.
Copy all this in there:
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.IO;
using NewestCOServer.Game;

namespace NewestCOServer.Features
{
    public enum PKTournamentStage
    {
        None,
        Inviting,
        Countdown,
        Fighting,
        Over
    }
    public static class PKTournament
    {
        public static ushort Map;
        public static ushort X, Y;
        public static PKTournamentStage Stage = PKTournamentStage.None;

        public static void StartTournament(Character Started)
        {
            if (Started.MyClient.GM)
            {
                Stage = PKTournamentStage.Inviting;
                Map = 1005;
                X = 51;
                Y = 71;
                BeginTournament();
            }
        }
        private static void Broadcast(string msg)
        {
            foreach (Character Char in World.H_Chars.Values)
            {
                Char.MyClient.AddSend(Packets.ChatMessage(0, "[GM]", "All", msg, 2011, 0));
                Char.MyClient.EndSend();
            }
        }
        private static void AwardWinner(Character Winner)
        {
            Broadcast(Winner.Name + " has won the tournament!");
            foreach (Character Char in World.H_Chars.Values)
            {
                try
                {
                    Char.StatEff.Add(StatusEffectEn.WeeklyPKChampion);
                    Char.Top = 10;
                    Char.CPs += 2000;
                    // Edit the prize here
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
        }
        public static void WaitForWinner()
        {
            PKTournament.Stage = PKTournamentStage.Fighting;
            uint Tick = (uint)Environment.TickCount;
            Character Winner = null;
            while (true)
            {
                Winner = null;
                int InMapDead = 0;
                int InMapAlive = 0;
                Thread.Sleep(500);
                foreach (Character Char in World.H_Chars.Values)
                {
                    if (Char.Loc.Map == 1005)
                    {
                        InMapAlive++;
                    }
                    else if (Char.CurHP == 0)
                    {
                        InMapDead++;
                        InMapAlive--;
                    }
                    if (InMapAlive == 1)
                    {
                        Winner = Char;
                        {
                            Char.Teleport(1002, 438, 382);
                            AwardWinner(Winner);
                            Stage = PKTournamentStage.Over;
                        }
                    }
                    else
                    {
                        if (Tick + (60 * 1000) < (uint)Environment.TickCount)
                        {
                            Broadcast("30 seconds left until tournament is over.");
                        }
                        else if (Tick + (90 * 1000) < (uint)Environment.TickCount)
                        {
                            Broadcast("Tournament is over, no winner is found because more than one player is left.");
                            if (Char.Loc.Map == Map)
                            {
                                Char.Teleport(1002, 400, 400);
                            }
                            Stage = PKTournamentStage.Over;
                            break;
                        }
                    }
                    }
                }
            }
        
        public static void BeginTournament()
        {
            new Thread(delegate()
            {
                foreach (Character Char in World.H_Chars.Values)
                {
                    Char.MyClient.DialogNPC = 666111;
                    PacketHandling.NPCDialog.Handle(Char.MyClient, null, 666111, 0);
                    Char.MyClient.EndSend();
                }
                Stage = PKTournamentStage.Inviting;
                Thread.Sleep(5 * 1000);
                Broadcast("10 seconds until fight.");
                Stage = PKTournamentStage.Countdown;
                Thread.Sleep(4 * 1000);
                Broadcast("5 seconds until fight.");
                Thread.Sleep(3 * 1000);
                for (int i = 3; i >= 1; i--)
                {
                    Broadcast(i.ToString());
                    Thread.Sleep(1000);
                }
                Stage = PKTournamentStage.Fighting;
                Broadcast("Fight!");
                WaitForWinner();
            }).Start();
        }
    }
}
And here's the npc for it:
Code:
                            #region JoinPKTDialog
                            case 666111:
                                if (Control == 0)
                                {
                                    GC.AddSend(Packets.NPCSay("Would you like to join the PK tournament in the PKArena? You have 20 seconds to join."));
                                    GC.AddSend(Packets.NPCLink("Sure, I'm a beast anyways.", 1));
                                    GC.AddSend(Packets.NPCLink("What're the rules?", 2));
                                    GC.AddSend(Packets.NPCSetFace(30));
                                    GC.AddSend(Packets.NPCFinish());
                                }
                                else if (Control == 1)
                                {
                                    if (Features.PKTournament.Stage == Features.PKTournamentStage.Inviting)
                                    {
                                        GC.AddSend(Packets.NPCSay("Goodluck, " + GC.MyChar.Name + "."));
                                        GC.AddSend(Packets.NPCLink("Thanks", 255));
                                        GC.AddSend(Packets.NPCSetFace(30));
                                        GC.AddSend(Packets.NPCFinish());
                                        GC.MyChar.Teleport(1005, 51, 71);
                                        GC.MyChar.CurHP = 1;
                                    }
                                    else if (Features.PKTournament.Stage == Features.PKTournamentStage.Fighting)
                                    {
                                        GC.AddSend(Packets.NPCSay("You're too late, " + GC.MyChar.Name + "!"));
                                        GC.AddSend(Packets.NPCLink("Darn", 255));
                                        GC.AddSend(Packets.NPCSetFace(30));
                                        GC.AddSend(Packets.NPCFinish());
                                    }
                                    else
                                    {
                                        GC.AddSend(Packets.NPCSay("No PK tournament is going on at this time."));
                                        GC.AddSend(Packets.NPCLink("Darn", 255));
                                        GC.AddSend(Packets.NPCSetFace(30));
                                        GC.AddSend(Packets.NPCFinish());
                                    }
                                }
                                else if (Control == 2)
                                {

                                    GC.AddSend(Packets.NPCSay("The PK tournament is started by a GM, on any map he wants."));
                                    GC.AddSend(Packets.NPCSay("Everyone fights with only 1 HP."));
                                    GC.AddSend(Packets.NPCSay("The last man that isn't a GM standing will 'win' the tournament."));
                                    GC.AddSend(Packets.NPCLink("I want to join!", 1));
                                    GC.AddSend(Packets.NPCLink("No thanks.", 255));
                                    GC.AddSend(Packets.NPCSetFace(30));
                                    GC.AddSend(Packets.NPCFinish());
                                }
                                break;
                            #endregion
This is a PKTournament is called using the method
Code:
                            Features.PKTournament.BeginTournament();
What happens is once the method is called the NPC box will appear over everybody's screen that is online.
So they don't need to talk to the npc themselves.
Well hope you'll like it.
Arcо is offline  
Thanks
31 Users
Old 02/03/2010, 05:55   #2
 
NukingFuts's Avatar
 
elite*gold: 0
Join Date: May 2009
Posts: 480
Received Thanks: 111
haha nice work mate
NukingFuts is offline  
Old 02/03/2010, 05:55   #3
 
Arcо's Avatar
 
elite*gold: 0
Join Date: Oct 2009
Posts: 8,765
Received Thanks: 5,291
Quote:
Originally Posted by neber120 View Post
haha nice work mate
Thanks alot:]
I try:]
Arcо is offline  
Thanks
3 Users
Old 02/03/2010, 06:04   #4
 
elite*gold: 0
Join Date: Jun 2009
Posts: 29
Received Thanks: 10
i dont get it. how do we start the tourny? do we have to add a command or theres another way to do that?
.RainBow. is offline  
Old 02/03/2010, 06:11   #5
 
Arcо's Avatar
 
elite*gold: 0
Join Date: Oct 2009
Posts: 8,765
Received Thanks: 5,291
I stated the method where the tournament is started.
But here's the command I used.
PHP Code:
                        if (Cmd[0] == "/pkt")
                            
Features.PKTournament.BeginTournament(); 
Arcо is offline  
Thanks
7 Users
Old 02/03/2010, 06:12   #6
 
elite*gold: 0
Join Date: Jun 2009
Posts: 29
Received Thanks: 10
Quote:
Originally Posted by .Arco View Post
I stated the method where the tournament is started.
But here's the command I used.
PHP Code:
                        if (Cmd[0] == "/pkt")
                            
Features.PKTournament.BeginTournament(); 
oh i feel stupid now. x) btw thanks. great release as usually
.RainBow. is offline  
Old 02/03/2010, 06:13   #7
 
Arcо's Avatar
 
elite*gold: 0
Join Date: Oct 2009
Posts: 8,765
Received Thanks: 5,291
Thanks
Glad I can help.
Arcо is offline  
Thanks
3 Users
Old 02/03/2010, 07:15   #8
 
WHITELIONX's Avatar
 
elite*gold: 0
Join Date: Apr 2006
Posts: 532
Received Thanks: 66
Rather than just saying thank you to him you should hit the thanks button for him Good work I am near finished with the stupid update system lol. Only issue I have now is that if your client is updated you MUST hit bypass >.<

Not such a big deal though for now the custom launcher is working and it updates etc etc just that people need to hit bypass to start the client I am sure I will probably figure it out maybe?
WHITELIONX is offline  
Old 02/03/2010, 07:25   #9
 
walmartboi's Avatar
 
elite*gold: 0
Join Date: Dec 2007
Posts: 378
Received Thanks: 163
Nice work! This will come in handy, haha.

+k
walmartboi is offline  
Old 02/03/2010, 08:53   #10
 
ramix's Avatar
 
elite*gold: 0
Join Date: Aug 2008
Posts: 272
Received Thanks: 61
give me erro in Char.Top = 10;

can u hlp me .arco
ramix is offline  
Old 02/03/2010, 10:31   #11
 
elite*gold: 0
Join Date: Sep 2008
Posts: 39
Received Thanks: 0
Hmm.. Did everything like You explained Arco, but the Tournament is still not starting >.<
Added the command in the Chat.cs. - Right?
And do i have to create An NPC?

regards
2087 is offline  
Old 02/03/2010, 13:35   #12
 
elite*gold: 0
Join Date: Nov 2009
Posts: 342
Received Thanks: 17
and iam top= 10

give me erro
|xabi| is offline  
Old 02/03/2010, 13:37   #13
 
Arcо's Avatar
 
elite*gold: 0
Join Date: Oct 2009
Posts: 8,765
Received Thanks: 5,291
Igave the NPC already, and top was just an example I used.
Arcо is offline  
Thanks
4 Users
Old 02/03/2010, 13:46   #14
 
elite*gold: 0
Join Date: Dec 2009
Posts: 36
Received Thanks: 1
Good work thanks

A bear and could put this tournament with PKArena button? Putting all the packets but i? : l
|_Beetle_| is offline  
Old 02/03/2010, 14:56   #15
 
elite*gold: 0
Join Date: Sep 2008
Posts: 39
Received Thanks: 0
Owel K, but still if i do everything like you.. There dont come an invention to Pktourney. So Not possible to do.
Got any fixes?
2087 is offline  
Reply


Similar Threads Similar Threads
PKTournament
02/12/2010 - CO2 Private Server - 25 Replies
Well I'm tweaking around with my released pktournament and here's the problem I'm coming across. public static void WaitForClass() { PKTournament.Stage = PKTournamentStage.Fighting; uint Tick = (uint)Environment.TickCount; Character Winner = null; while (true) { Winner = null; int InMapAlive = 0;
[Help] PkTournament
02/11/2010 - CO2 Private Server - 1 Replies
Ok, I got 2 problems. I got the command to start the tournament so... 1.) When I start the pktournament and get teleported there, when it starts, me any the players get teleported back and we all win. 2.) After i've done the tournament once and do it again, I type the command to start it, and I get teleported there, and as soon as I get there, it teleports me back. How can I fix these two problems?
[Release] Good PKTournament
01/10/2009 - CO2 PServer Guides & Releases - 11 Replies
#Deleted



All times are GMT +2. The time now is 20:04.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.