Guide/Release: Conquer Server (CoFuture) Using MySql!

03/31/2008 15:38 Kiyono#646
Quote:
Originally Posted by tanelipe View Post
I'm curious, Do you guys even bother to look what the type of Packet is?
Like the above SpawnMob Packet; Instead of trying to make it from scratch, look what Type it is; Tell me if you find the answer; (Hint : Has something to do with character spawning :rolleyes:)


Look for the packet 0x3F9 for example : It has alot subtypes (10+?) It would be incredibly messy to code these each on their own, but instead you just change the values...(and subtype ofcourse)

P.S This is more like for the future referrence.

@nearmylimits : Download .NET FrameWork 2 or higher;
i have not done anything yet i posted when i was at school
03/31/2008 19:54 g_elf#647
Quote:
Originally Posted by tanelipe View Post
I'm curious, Do you guys even bother to look what the type of Packet is?
Like the above SpawnMob Packet; Instead of trying to make it from scratch, look what Type it is; Tell me if you find the answer; (Hint : Has something to do with character spawning :rolleyes:)


Look for the packet 0x3F9 for example : It has alot subtypes (10+?) It would be incredibly messy to code these each on their own, but instead you just change the values...(and subtype ofcourse)

P.S This is more like for the future referrence.

@nearmylimits : Download .NET FrameWork 2 or higher;
i know jack about packets im learning from what i see, and ur damn right, the mob packet e quite alike te char spawn packet.

so how can i know how the packet is made and how can i "translate it"? and how can i know how many subtypes it has?

tks for the tips :D
03/31/2008 20:39 tanelipe#648
I don't think there is any proper way of knowing how many SubTypes some of the packets have, unless ofcourse you get hands on original CO source, you just come across them while logging packets from wherever you log your packets from. :P

Packets and how they are made....uhm; It's hard to explain.

The bytes from 0..1 (First two of the byte[] Array, (in C#)) are the size of Packet
1..2 are the Packet Type; Like for example the character spawn packet 0x3F6

Those first 4 bytes are always at same place; But the rest of them don't follow any pattern (Unless they're same PType of course)

Lets take the AuthResponse packet for example (Smallest packet perhaps? xD)

20 00 F1 04 XX XX XX XX YY YY YY YY II II II II II II II II II II II II II II II II PP PP RR RR

XX = KeyTwo
YY = KeyOne
II = IP
PP = GamePort
RR = Reserved

Excuse me for that gay format, but those values change in the packet, they're not preset :D

0..1 : Size
2..3 : Type (0x41F in this case)
4..7 : KeyTwo
8..11 : KeyOne
12..27 : The GameIP (Not always this long, reserved for xxx.xxx.xxx.xxx ip's)
28..29 : GamePort
30..31 : Nothing; It's just 00 00

Now! Let's make that to a something we can send!
Code:
// This style is mostly used in COEmu based things, unless using streams
public static byte[] AuthResponse(string IP, uint KeyOne, uint KeyTwo, ushort GamePort)
{
  byte[] Packet = new byte[0x20]; // 0x20 in hex, 32 in dec
  Packet[0] = (byte)(Packet.Length & 0xFF);
  Packet[1] = (byte)((Packet.Length >> 8) & 0xFF);
  Packet[2] = (byte)(0x41F & 0xFF);
  Packet[3] = (byte)((0x41F >> 8) & 0xFF);
  Packet[4] = (byte)(KeyTwo & 0xFF);
  Packet[5] = (byte)((KeyTwo >> 8) & 0xFF);
  Packet[6] = (byte)((KeyTwo >> 16) & 0xFF);
  Packet[7] = (byte)((KeyTwo >> 24) & 0xFF);
  Packet[8] = (byte)(KeyOne & 0xFF);
  Packet[9] = (byte)((KeyOne >> 8) & 0xFF);
  Packet[10] = (byte)((KeyOne >> 16) & 0xFF);
  Packet[11] = (byte)((KeyOne >> 24) & 0xFF);
  for(byte i = 0; i < IP.Length; i++)
   Packet[12 + i] = (byte)IP[i];
  Packet[28] = (byte)(GamePort & 0xFF);
  Packet[29] = (byte)((GamePort >> 8) & 0xFF);
  // 30..31 Don't have to be declared since they're alwayss 00
  return Packet; 
}
P.S If you copy this; It won't probably work for your server version;
P.P.S There might be _some_ errors, wrote it here; Didn't have compiler open :D
03/31/2008 21:08 g_elf#649
@tanelipe:

tks for the explanation, now im starting to understand something.

so i have to get the packets and compare them to find what changes and when right?

does any1 have a packet snnifer or something like that?

Edit: i just decripted the packet i posted before and guess what ... its the char packet, same id
Type(1014); == PacketData[2] = 0xf6; PacketData[3] = 0x03; == 0x3f6 == 1014

so spawning a mob its like spawning a char? only changes the mech? hum
04/01/2008 01:58 nearmylimits#650
I get this error when ever someone trys to log in, help please.

[Only registered and activated users can see links. Click Here To Register...]
04/01/2008 03:43 g_elf#651
Quote:
Originally Posted by nearmylimits View Post
I get this error when ever someone trys to log in, help please.

[Only registered and activated users can see links. Click Here To Register...]
try cheking the port nš in the server.dat and in the server DB are the sameand probably should be 9958.
04/01/2008 11:11 Kiyono#652
well not really a problem but just anoying when i login i get the 317 error even though i fixed it long ago any idea on how to remove the message?caus ei don't it to look at errors
04/01/2008 11:30 tanelipe#653
@Djago160 : Look for Korvac's post @ page 40; There should be all the information needed to fix that error.

@Djago160 : I'd suggest you to keep those error messages popping to console, much easier to debug source of problem. :P But if you really wan't to have all those removed, look for :
Code:
try
{

}
catch(Exception e) // Can be something else than 'e' also
{
  Console.WriteLine(e.toString());
}
And remove the Console.WriteLine part.
04/01/2008 13:42 Kiyono#654
Quote:
Originally Posted by tanelipe View Post
@Djago160 : Look for Korvac's post @ page 40; There should be all the information needed to fix that error.

@Djago160 : I'd suggest you to keep those error messages popping to console, much easier to debug source of problem. :P But if you really wan't to have all those removed, look for :
Code:
try
{

}
catch(Exception e) // Can be something else than 'e' also
{
  Console.WriteLine(e.toString());
}
And remove the Console.WriteLine part.
well if it's better to leave them there i will
04/01/2008 13:51 tanelipe#655
IMO it's better to have it so it'll output anything that cause errors. I'm not sure but C# might do this actually by default (output exceptions) but if you catch it with that try {} catch {} statement, You can do various things, ex :

e.Message (shows the error message),

e.Source (shows the application/object that causes error)

and you can can also add your own lines inside the catch { }

Code:
int StrToInt(string tConvert) {
  int RtnValue = 0;
  try { 
    RtnValue = Convert.ToInt32(tConvert);
  } 
  catch {
    Console.WriteLine("Could not convert string {0} to Integer..returning 0", tConvert);
    RtnValue = 0;
  }
  return RtnValue;
}

and so on... :P
04/01/2008 17:56 Kiyono#656
well i was bored so i fixed the @scroll command

Code:
 else if (Splitter[0] == "@scroll")
                    {
                        if (Splitter[1] == "tc")
                        {
                            int x = 438; int y = 377;
                            Client.Char.CurrentLoc = new Location(x, y);
                            Client.Char.Map = Map.Maps.TwinCity;
                            Client.SendData(CPacket.GeneralData(Client.Char.CharID, 1002, 438, 377, DataType.ChangeMap));
                            Spawn.Remove(Client);
                            Client.SendData(CPacket.CharInfo(Client.Char));
                            Client.Char.Map = (Map.Maps)Convert.ToInt32(Splitter[1]);
                            Client.Char.CurrentLoc = new Location(Convert.ToInt32(Splitter[2]), Convert.ToInt32(Splitter[3]));
                            Spawn.UpdateLocal(Client, CPacket.SpawnChar(Client.Char));
                        }
                        else if (Splitter[1] == "am")
                        {
                            int x = 566; int y = 565;
                            Client.Char.CurrentLoc = new Location(x, y);
                            Client.Char.Map = Map.Maps.ApeMoutain;
                            Client.SendData(CPacket.GeneralData(Client.Char.CharID, 1002, 438, 377, DataType.ChangeMap));
                            Spawn.Remove(Client);
                            Client.SendData(CPacket.CharInfo(Client.Char));
                            Client.Char.Map = (Map.Maps)Convert.ToInt32(Splitter[1]);
                            Client.Char.CurrentLoc = new Location(Convert.ToInt32(Splitter[2]), Convert.ToInt32(Splitter[3]));
                            Spawn.UpdateLocal(Client, CPacket.SpawnChar(Client.Char));
                        }
                        else if (Splitter[1] == "ma")
                        {
                            int x = 211; int y = 196;
                            Client.Char.CurrentLoc = new Location(x, y);
                            Client.Char.Map = Map.Maps.Market;
                            Client.SendData(CPacket.GeneralData(Client.Char.CharID, 1002, 438, 377, DataType.ChangeMap));
                            Spawn.Remove(Client);
                            Client.SendData(CPacket.CharInfo(Client.Char));
                            Client.Char.Map = (Map.Maps)Convert.ToInt32(Splitter[1]);
                            Client.Char.CurrentLoc = new Location(Convert.ToInt32(Splitter[2]), Convert.ToInt32(Splitter[3]));
                            Spawn.UpdateLocal(Client, CPacket.SpawnChar(Client.Char));
                        }
                        else if (Splitter[1] == "bi")
                        {
                            int x = 723; int y = 573;
                            Client.Char.CurrentLoc = new Location(x, y);
                            Client.Char.Map = Map.Maps.BirdIsland;
                            Client.SendData(CPacket.GeneralData(Client.Char.CharID, 1002, 438, 377, DataType.ChangeMap));
                            Spawn.Remove(Client);
                            Client.SendData(CPacket.CharInfo(Client.Char));
                            Client.Char.Map = (Map.Maps)Convert.ToInt32(Splitter[1]);
                            Client.Char.CurrentLoc = new Location(Convert.ToInt32(Splitter[2]), Convert.ToInt32(Splitter[3]));
                            Spawn.UpdateLocal(Client, CPacket.SpawnChar(Client.Char));
                        }
                        else if (Splitter[1] == "dc")
                        {
                            int x = 496; int y = 649;
                            Client.Char.CurrentLoc = new Location(x, y);
                            Client.Char.Map = Map.Maps.DesertCity;
                            Client.SendData(CPacket.GeneralData(Client.Char.CharID, 1002, 438, 377, DataType.ChangeMap));
                            Spawn.Remove(Client);
                            Client.SendData(CPacket.CharInfo(Client.Char));
                            Client.Char.Map = (Map.Maps)Convert.ToInt32(Splitter[1]);
                            Client.Char.CurrentLoc = new Location(Convert.ToInt32(Splitter[2]), Convert.ToInt32(Splitter[3]));
                            Spawn.UpdateLocal(Client, CPacket.SpawnChar(Client.Char));
                        }
                        else if (Splitter[1] == "pc")
                        {
                            int x = 232; int y = 260;
                            Client.Char.CurrentLoc = new Location(x, y);
                            Client.Char.Map = Map.Maps.PhoenixCastle;
                            Client.SendData(CPacket.GeneralData(Client.Char.CharID, 1002, 438, 377, DataType.ChangeMap));
                            Spawn.Remove(Client);
                            Client.SendData(CPacket.CharInfo(Client.Char));
                            Client.Char.Map = (Map.Maps)Convert.ToInt32(Splitter[1]);
                            Client.Char.CurrentLoc = new Location(Convert.ToInt32(Splitter[2]), Convert.ToInt32(Splitter[3]));
                            Spawn.UpdateLocal(Client, CPacket.SpawnChar(Client.Char));
                        }
Note: if you scroll you will be teleported to TC first then your destination
04/01/2008 20:28 g_elf#657
ok mob packet done, only spawns the mobs the rest has to done in the mob classes

its the char packet altered

public byte[] SpawnMob(int ID, int Mech, int mob_x, int mob_y, string Name, int HP, int LVL, int POS, string Status, int ANIM)
{
if (HP < 0)
HP = 0;
if (POS < 0)
POS = 0;
int MobStatus = Convert.ToInt32(Status, 16);
Length((65 + Name.Length));
Type(1014);
Long(ID);
Long(Mech);
Long(MobStatus); // shield, stigma, alive, dead, dead and desapear
Long(0);
Long(0);
Long(0);
Long(0);
Long(0);
Long(0);
Long(0);
Long(0);
Short(HP);
Short(LVL);
Short(mob_x);
Short(mob_y);
Short(0);
//Short(330);
//ByteInt(74);
//ByteInt(1);
ByteInt(POS);
ByteInt(ANIM); // animation 100-normal 150-peck
Short(0);
ByteInt(1);
ByteInt(Name.Length);
for (int x = 0; x < Name.Length; x++)
{
Byte(Convert.ToByte(Name[x]));
}
return getBytes();
}

it spawns the mobs with name
if u want them to walk, atk, have hp bar u have to "class it"

tks all that explained me how packets work
04/02/2008 00:08 katanahack#658
Quote:
Open "Server" folder then Open the "CoFuture" Project File then open Database.cs and press "ctrl+g" and go to line "39" change "Database Username" to your databases username then on line "40" change "Database Password" to your databases password" and then on line "44" change "Database Name" to "conquer_server" unless you changed the database name. then go to Build --> Build Solution (Solution should build successfully!)
So when you say Database Username, do you mean our phpMyAdmin username and password???
(YES)

[EDIT]
I open Database.cs with Microsoft Visual Basic 2008 Express Edition, but there is no Build->Build Solution... how do I get this?

[EDIT-2]
Kay I got it working, You need Visual C#, and open CoFuture.csproj with it. =D
04/02/2008 03:11 Korvacs#659
@Djago160:

Quote:
Client.SendData(CPacket.GeneralData(Client.Char.Ch arID, 1002, 438, 377, DataType.ChangeMap));
replace all of the lines similar to the one above with this in your scroll command to stop the tc teleporting bit

Quote:
Client.SendData(CPacket.GeneralData(Client.Char.Ch arID, Client.Char.Map, x, y, DataType.ChangeMap));
04/02/2008 05:10 katanahack#660
I have Qonquer v. 9999, I have run the server Connection is Successful.
But when I open Qonquer and try to connect to the server, it says error dude to matinence. Obviously there isn't any matinence, so how do I connect to the Server?