Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2 > CO2 Private Server > CO2 PServer Guides & Releases
You last visited: Today at 11:10

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

Advertisement



[Release] Extremely basic (but working/bugless) C# Source

Discussion on [Release] Extremely basic (but working/bugless) C# Source within the CO2 PServer Guides & Releases forum part of the CO2 Private Server category.

Closed Thread
 
Old 01/22/2009, 01:10   #16
 
elite*gold: 0
Join Date: Jul 2005
Posts: 111
Received Thanks: 5
Quote:
Originally Posted by InfamousNoone View Post
Client.SendScreen(packet, false);

instead of looping through all them clients...
Thanks. I used the code in sendscreen but as you said would be easier to loop that way.
Also I just realized I need to add the character not online text if no player is online with that name.
ranny2 is offline  
Old 01/22/2009, 06:15   #17


 
KraHen's Avatar
 
elite*gold: 0
Join Date: Jul 2006
Posts: 2,216
Received Thanks: 793
A fast `lil question : At the packetprocessor.cs, the case number is the PacketType?
KraHen is offline  
Old 01/22/2009, 06:27   #18
 
punkmak2's Avatar
 
elite*gold: 0
Join Date: Jun 2005
Posts: 27
Received Thanks: 49
Quote:
Originally Posted by ElDeRnEcRo View Post
A fast `lil question : At the packetprocessor.cs, the case number is the PacketType?
sure is .
punkmak2 is offline  
Old 01/22/2009, 20:29   #19
 
InfamousNoone's Avatar
 
elite*gold: 20
Join Date: Jan 2008
Posts: 2,012
Received Thanks: 2,882
To make it so that you can see other players and the client doesn't crash when you see another player, go to IEntity.cs and ctrl+f for this:

Code:
PacketBuilder.WriteUInt16(101, this.SpawnPacket, 0);
Change 101, to 102. Small typo I made .
InfamousNoone is offline  
Thanks
3 Users
Old 01/23/2009, 07:33   #20
 
punkmak2's Avatar
 
elite*gold: 0
Join Date: Jun 2005
Posts: 27
Received Thanks: 49
Also when a player jumps into another characters screen it doesn't always update.


Implementing Item Usage Packet.

1) Create new Class file in folders Networking/Packets called "Item Usage Packet.cs"

2) Replace all the code in newly created file Item Usage Packet.cs with the code below.
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConquerServer_Basic
{
    public class ItemUsagePacket : IClassPacket
    {
        public const ushort
            BuyFromNPC = 1,
            SellToNPC = 2,
            DropItem = 3,
            EquipItem = 4,
            UnequipItem = 6,
            ViewWarehouse = 9,
            WarehouseDeposit = 10,
            WarehouseWithdraw = 11,
            DropMoney = 12,
            DragonBallUpgrade = 19,
            MeteorUpgrade = 20,
            Ping = 27;
        
        private byte[] Packet;

        public ItemUsagePacket(bool CreateInstance)
        {
            if (CreateInstance)
            {
                Packet = new byte[24];
                PacketBuilder.WriteUInt16(24, this.Packet, 0);
                PacketBuilder.WriteUInt16(1009, this.Packet, 2);
            }
        }

        public uint UID
        {
            get { return BitConverter.ToUInt32(Packet, 4); }
            set { PacketBuilder.WriteUInt32(value, Packet, 4); }
        }
        public uint ID
        {
            get { return BitConverter.ToUInt32(Packet, 8); }
            set { PacketBuilder.WriteUInt32(value, Packet, 8); }
        }
        public uint PacketType
        {
            get { return BitConverter.ToUInt32(Packet, 12); }
            set { PacketBuilder.WriteUInt32(value, Packet, 12); }
        }
        public uint Unknown
        {
            get { return BitConverter.ToUInt32(Packet, 16); }
            set { PacketBuilder.WriteUInt32(value, Packet, 16); }
        }

        public void Deserialize(byte[] Bytes)
        {
            Packet = Bytes;
        }
        public byte[] Serialize()
        {
            return this.Packet;
        }
    }
}




Ping Packet.
Item Usage packet is needed to make the ping Packet work.

1) In the file PacketProcessor.cs search for Process.

2)Add the following code into the Switch
Code:
case 1009:
                    {
                        ItemUsagePacket cPacket = new ItemUsagePacket(false);
                        cPacket.Deserialize(Packet);
                        switch (cPacket.PacketType)
                        {
                            case ItemUsagePacket.Ping:
                                Client.Send(Packet);
                                break;
                        }
                        break;
                    }




I'll post a guide on how to add Portal support to your server soon.
Just fixing some portal locations in the flat file database.
punkmak2 is offline  
Thanks
1 User
Old 01/24/2009, 01:23   #21
 
InfamousNoone's Avatar
 
elite*gold: 20
Join Date: Jan 2008
Posts: 2,012
Received Thanks: 2,882
#updated, special thanks to punk who let me be lazy and not have to make my own Item Usuage Packet

Added

* Jumping
* Walking
* Talking
* Commands
* Npcs (interaction)
* Fixed client closing bug(s)

And a few other things, check it out...
InfamousNoone is offline  
Old 01/24/2009, 08:42   #22
 
punkmak2's Avatar
 
elite*gold: 0
Join Date: Jun 2005
Posts: 27
Received Thanks: 49
Quote:
Originally Posted by HellCo View Post
I have 1 question, is there actually a sql file and config, when i open the server to test i can actually log on after adding codes, it says Database Loaded, i havent even given it a database to load to, so how is it loaded? O.o
Maybe it's using a flat file database. Google it .........
punkmak2 is offline  
Old 01/24/2009, 20:00   #23


 
KraHen's Avatar
 
elite*gold: 0
Join Date: Jul 2006
Posts: 2,216
Received Thanks: 793
What about a SVN? Just like CoEmu had it? It was easy to access and contribute (although I only catched it at the end so I can`t say much about it...)
KraHen is offline  
Old 01/25/2009, 18:40   #24
 
unknownone's Avatar
 
elite*gold: 20
Join Date: Jun 2005
Posts: 1,013
Received Thanks: 381
Quote:
Originally Posted by kinshi88 View Post
You don't need TortoiseSVN, or SVN, or any shit like that.

I don't know what the fuck you guys are smoking.
You're rather uninformed about revision control. I suggest you read up on it, its advantages, the different types, and try using some before you make rediculous comments like that.

Revision control could help this is so many ways. As it is now, it's just "another LOTF". Albeit, it's a better base to begin from in most ways, it has it's share of problems, and it doesn't do anything to solve the problems with LOTF based servers - because people will just make a mess of this too.

You talk about learning, but if you had any clue about the industry, you'd know revision control is a necessity. You'll never find a programming job if you can't use it.

I'm not saying, Inf and other people should do all the work and let people just grab it and run their own servers. However, we are all making servers for the same game, they all share the same protocol, cryptography and static(client-side) data. There's no reason to let people "try and figure this out themselves." They will never truly understand how to reverse engineer a protocol, file, encryption unless they do it themselves, from scratch. Having people do thier own things leads to several problems: People rename things and confuse others. There's no "coding practices" going on, and people are mixing together piles of different styles, bad code, unsafe code, not really knowing anything about the code they're using. Nobody is going to ever make a "working/bugless" server from this besides inf.

I could go on all day about why it's a good idea to use revision control for this, or anything else. If you want me to bore you, prepare yourself. I wouldn't reccomend SVN as a revision control system, but rather a distributed system like Git, Mercurial, Monotone etc. This way people can have their own "local" repositories on their computer, for which they can upload parts, or update parts, without modifying the whole central repository for every change they make.
unknownone is offline  
Old 01/25/2009, 18:54   #25
 
Ultimatum's Avatar
 
elite*gold: 0
Join Date: Feb 2008
Posts: 277
Received Thanks: 52
I agree with sparkie, when coemu had revision control it was easily shared with the community to work on ect, i think it was SVN though, im using Mercurial atm and when you have a team of say 3 people a revision controled system really helps. Go on google code, every single project as a revision controlled system. However its only best if you have multiple people working on the project, its not 'needed' but its helps.
Ultimatum is offline  
Old 01/25/2009, 18:57   #26
 
© Haydz's Avatar
 
elite*gold: 20
Join Date: Jan 2008
Posts: 1,042
Received Thanks: 252
I completely back sparkie with this... I currently have a repository up for my server source files and it couldnt be easier to manage and contribute to.
© Haydz is offline  
Old 01/25/2009, 19:07   #27


 
KraHen's Avatar
 
elite*gold: 0
Join Date: Jul 2006
Posts: 2,216
Received Thanks: 793
Isn`t GIT for unix-based OSs? I could be wrong tho.
KraHen is offline  
Old 01/25/2009, 19:38   #28
 
unknownone's Avatar
 
elite*gold: 20
Join Date: Jun 2005
Posts: 1,013
Received Thanks: 381
Git is open source, open spec. There's no "OS" that it's for. There are official (native) Windows builds of Git, built with Mingw using the MSYS environment. You probably won't find a shell-integration like TortoiseGIT, although I can imagine there's one in development. TortoiseHg for Mercurial is well developed and works well (on 32-bit Win), but has some problems on 64-bit Vista apparently.
unknownone is offline  
Old 01/25/2009, 20:11   #29


 
KraHen's Avatar
 
elite*gold: 0
Join Date: Jul 2006
Posts: 2,216
Received Thanks: 793
****, you`re awesome
KraHen is offline  
Old 01/26/2009, 03:34   #30
 
punkmak2's Avatar
 
elite*gold: 0
Join Date: Jun 2005
Posts: 27
Received Thanks: 49
Here we go.


Portals Implementation.

1) Create a new Class file in the folder Interfaces called "IPortals.cs"

2) Replace all the code in newly created file IPortals.cs with the code below.
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConquerServer_Basic
{
    public interface IPortal
    {
        ushort CurrentMapID { get; set; }
        ushort CurrentX { get; set; }
        ushort CurrentY { get; set; }
        ushort DestinationMapID { get; set; }
        ushort DestinationX { get; set; }
        ushort DestinationY { get; set; }
    }

    public class Portal : IPortal
    {
        private ushort _CurrentMapID;
        private ushort _CurrentX;
        private ushort _CurrentY;
        private ushort _DestinationMapID;
        private ushort _DestinationX;
        private ushort _DestinationY;

        public Portal()
        {
        }

        public Portal(ushort CurrentMapID, ushort CurrentX, ushort CurrentY, ushort DestinationMapID, ushort DestinationX, ushort DestinationY)
        {
            _CurrentMapID = CurrentMapID;
            _CurrentX = CurrentX;
            _CurrentY = CurrentY;
            _DestinationMapID = DestinationMapID;
            _DestinationX = DestinationX;
            _DestinationY = DestinationY;
        }

        public ushort CurrentMapID
        {
            get
            {
                return _CurrentMapID;
            }

            set
            {
                _CurrentMapID = value;
            }
        }
        public ushort CurrentX
        {
            get
            {
                return _CurrentX;
            }

            set
            {
                _CurrentX = value;
            }
        }
        public ushort CurrentY
        {
            get
            {
                return _CurrentY;
            }

            set
            {
                _CurrentY = value;
            }
        }
        public ushort DestinationMapID
        {
            get
            {
                return _DestinationMapID;
            }

            set
            {
                _DestinationMapID = value;
            }
        }
        public ushort DestinationX
        {
            get
            {
                return _DestinationX;
            }

            set
            {
                _DestinationX = value;
            }
        }
        public ushort DestinationY
        {
            get
            {
                return _DestinationY;
            }

            set
            {
                _DestinationY = value;
            }
        }
    }
}

3) In Database/Database.cs add the following code.
Code:
public static void LoadPortals()
        {
            string[] Portals = File.ReadAllLines(DatabasePath + @"\Misc\Portals.ini");
            for (int i = 0; i < Portals.Length; i++)
            {
                string[] Portal = Portals[i].Split(' ');

                IPortal portal = new Portal();
                portal.CurrentX = Convert.ToUInt16(Portal[0]);
                portal.CurrentY = Convert.ToUInt16(Portal[1]);
                portal.CurrentMapID = Convert.ToUInt16(Portal[2]);
                portal.DestinationX = Convert.ToUInt16(Portal[3]);
                portal.DestinationY = Convert.ToUInt16(Portal[4]);
                portal.DestinationMapID = Convert.ToUInt16(Portal[5]);

                if (!Kernel.Portals.ContainsKey(portal.CurrentX.ToString() + portal.CurrentY.ToString() + portal.CurrentMapID.ToString()))
                    Kernel.Portals.Add(portal.CurrentX.ToString() + portal.CurrentY.ToString() + portal.CurrentMapID.ToString(), portal);
                else
                    Console.WriteLine(portal.CurrentX.ToString() + " " + portal.CurrentY.ToString() + " " + portal.CurrentMapID.ToString());
            }
            Console.WriteLine("Portals Loaded");
        }
4) In Server Base Code/Kernel.cs add a new Dictionary to the Kernel class.
Code:
public static Dictionary<string, IPortal> Portals = new Dictionary<string, IPortal>();
5) In Program.cs, in the class Main() under Database.LoadDatabase(); add.
Code:
Database.LoadPortals();
6) In Networking/Packets/Data Packet.cs add a new const ushort.
Code:
Portal = 85,
7) In Networking/PacketProcessor.cs in the void Process, under the case 1010 add.
Code:
case DataPacket.Portal:
                                Portal(Client, cPacket);
                                break;
8) In Networking/PacketProcessor.cs add the following code to the PacketProcessor class.
Code:
public static void Portal(GameClient Client, DataPacket Packet)
        {
            ushort portal_X = (ushort)(Packet.dwParam & 0xFFFF);
            ushort portal_Y = (ushort)(Packet.dwParam >> 16);

            string portal_ID = portal_X.ToString() + portal_Y.ToString() + Client.Entity.MapID.ToString();

            if (Kernel.Portals.ContainsKey(portal_ID))
            {
                Console.WriteLine("Portal {0}, {1}, {2}", portal_X, portal_Y, Client.Entity.MapID);

                if (Kernel.GetDistance(portal_X, portal_Y, Client.Entity.X, Client.Entity.Y) <= 1)
                {
                    Packet.ID = DataPacket.SetLocation;
                    Packet.UID = Client.Entity.UID;
                    Packet.dwParam = Kernel.Portals[portal_ID].DestinationMapID;
                    Packet.wParam1 = Kernel.Portals[portal_ID].DestinationX;
                    Packet.wParam2 = Kernel.Portals[portal_ID].DestinationY;

                    Client.Entity.MapID = Kernel.Portals[portal_ID].DestinationMapID;
                    Client.Entity.X = Kernel.Portals[portal_ID].DestinationX;
                    Client.Entity.Y = Kernel.Portals[portal_ID].DestinationY;

                    Client.Send(Packet);

                    Client.Screen.Reload(true,
                    delegate(IBaseEntity Sender, IBaseEntity Caller)
                    {
                        if (Caller.EntityFlag == EntityFlag.Player &&
                            Sender.EntityFlag == EntityFlag.Player)
                        {
                            GameClient __Client = Caller.Owner as GameClient;
                            __Client.Send(Client.Entity.SpawnPacket);
                        }
                        return 0;
                    }
                );
                }
                else
                    Client.Socket.Disconnect(); // INVALID_PORTAL (No Such Portal)


            }
            else
            {
                Console.WriteLine("Invailed Portal {0}, {1}, {2}", portal_X, portal_Y, Client.Entity.MapID);
                Client.Socket.Disconnect(); // INVALID_PORTAL (No Such Portal)
            }
        }
9) Finally you'll need the portal database. Download the Portals.rar that I've included and place it into Database/Misc
Attached Files
File Type: rar Portals.rar (1.9 KB, 119 views)
punkmak2 is offline  
Thanks
19 Users
Closed Thread


Similar Threads Similar Threads
[Huge-Release] All-In-One Basic NPC Scripts For The 5165 Source!
02/19/2010 - CO2 PServer Guides & Releases - 30 Replies
Well I'm sorry that I spammed the whole forum full of my posts So pro4never and .Ryu gave me the idea of making this All-In-One thread about all my NPC's! THESE ARE UPDATED DAILY! NOTE: TO PEOPLE... SOME OF THE CODES ARE NOT MADE BY ME! I USUALLY JUST FIXED/UPDATED THE BASIC ONES! SORRY I'M LEARNING ON HOW TO CODE! 1. Birth-Island-NPC's(The NPC text is not from "REAL CONQUER" SORRY!...) #region BirthOldGeneralYang case 425: {
[FINAL RELEASE]HuB- Source (BASIC) (Original LOTF easier workable)
11/14/2009 - CO2 PServer Guides & Releases - 25 Replies
#REMOVED
[RELEASE] Basic LOTF Source
09/03/2009 - CO2 PServer Guides & Releases - 17 Replies
hey this is a basic lotf source edited based off shadowco, if you dont like it then dont post here... flames will be told on!!! :D i will tell on you to the mods if you flame What it has... - LuckyTime - Guard - 24/7 GW



All times are GMT +2. The time now is 11:10.


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.