Discussion on [Release] Extremely basic (but working/bugless) C# Source within the CO2 PServer Guides & Releases forum part of the CO2 Private Server category.
Infamous are you aware of the Screen.Reload bug. For some reason it doesn't always seem to load all the Characters weirdly enough or remove them once their disconnected, lol.
It affects the Team Dismissing once the team leader logs off or if a Team Member disconnects he is removed from the team. Because once the Team Member connects to the game again and the Team Leader re-invites the Player it's thinking it's the old Client that was previously connected. Therefore still thinking that the old Client is in a Team... lol Sorry if i've confused you.
Change Direction Implementation.
1) In Data Packet.cs add a new public const ushort
Code:
ChangeDirection = 79,
2) In PacketProcessor.cs, under public static void Process, add to case 1010:
Code:
case DataPacket.ChangeDirection:
ChangeDirection(Client, cPacket);
break;
3) In PacketProcessor.cs, in public class PacketProcessor. Add the follow code.
Code:
public static void ChangeDirection(GameClient Client, DataPacket Packet)
{
ushort Direction = (ushort)(Packet.wParam3);
ushort Client_X = (ushort)(Packet.wParam1);
ushort Client_Y = (ushort)(Packet.wParam2);
if (Enum.IsDefined(typeof(ConquerAngle), (ConquerAngle)Direction))
{
if (Client.Entity.X == Client_X && Client.Entity.Y == Client_Y)
{
Client.Entity.Facing = (ConquerAngle)Direction;
Packet.UID = Client.Entity.UID;
Client.SendScreen(Packet, false);
}
}
else
Client.Socket.Disconnect(); // INVALID_DIRECTION (No Such Facing Direction)
}
Action Implementation.
1) In Data Packet.cs add a new public const ushort
Code:
ChangeAction = 81,
2) In PacketProcessor.cs, under public static void Process, add to case 1010:
Code:
case DataPacket.ChangeAction:
ChangeAction(Client, cPacket);
break;
3) In PacketProcessor.cs, in public class PacketProcessor. Add the follow code.
Rev3 *should* be out by tonight if Ranny's team implementation goes smoothly.
Note to Ranny:
The "Entity" variable's type is also "Entity". I intended to use this class a shared class between both players and monsters (or at least, this is what I do on my main server seeing both monsters, and players share the same spawn packet). Anything that only players have i.e. teams, pkmodes, etc. should be kept strictly in the GameClient class.
public static uint IPAddressToLong(string IPAddr)
{
System.Net.IPAddress oIP = System.Net.IPAddress.Parse(IPAddr);
byte[] byteIP = oIP.GetAddressBytes();
uint ip = (uint)byteIP[0] << 24;
ip += (uint)byteIP[1] << 16;
ip += (uint)byteIP[2] << 8;
ip += (uint)byteIP[3];
return ip;
}
public static bool CheckIP(string IP)
{
uint ClientIPNew = IPAddressToLong(IP);
foreach (KeyValuePair<uint, IBanCountryIP> pBannedIP in Kernel.CountryBanIP)
{
if (ClientIPNew >= pBannedIP.Value.IP_Range1 && ClientIPNew <= pBannedIP.Value.IP_Range2)
return false;
}
return true;
}
2) In Program.cs find the public static void AuthConnect and replace it with"
Code:
public static void AuthConnect(HybridWinsockClient Sender, object param)
{
if (CheckIP(Sender.Connection.RemoteEndPoint.ToString().Split(':')[0]) && Kernel.CountryBanIP.Count > 0)
Sender.Wrapper = new AuthClient(Sender);
else
Sender.Connection.Disconnect(false);
}
3) In Database.cs add
Code:
public static void LoadBannedCountryCodes()
{
string[] CountryIP = File.ReadAllLines(DatabasePath + @"\Misc\BannedCountry.ini");
if (CountryIP.Length > 0)
{
for (int i = 0; i < CountryIP.Length; i++)
{
string[] CountryIPRange = CountryIP[i].Split(' ');
if (CountryIPRange.Length == 2)
{
IBanCountryIP IP = new BanCountryIP();
IP.ID = (uint)i;
IP.IP_Range1 = Program.IPAddressToLong(CountryIPRange[0]);
IP.IP_Range2 = Program.IPAddressToLong(CountryIPRange[1]);
Kernel.CountryBanIP.Add(IP.ID, IP);
}
}
Console.WriteLine("Banned Countries has Loaded");
}
}
4) in Program.cs find Database.LoadDatabase(); and bellow it add:
Code:
Database.LoadBannedCountryCodes();
5) In Kernel.cs add:
Code:
public static Dictionary<uint, IBanCountryIP> CountryBanIP = new Dictionary<uint, IBanCountryIP>();
6) In the Interfaces Folder create a new class file called "IBanCountryIP.cs". Open IBanCountryIP.cs. Replace the code in the file with:
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConquerServer_Basic
{
public interface IBanCountryIP
{
uint ID { get; set; }
uint IP_Range1 { get; set; }
uint IP_Range2 { get; set; }
}
public class BanCountryIP : IBanCountryIP
{
private uint _ID;
private uint _IP_Range1;
private uint _IP_Range2;
public uint ID { get { return this._ID; } set { this._ID = value; } }
public uint IP_Range1 { get { return this._IP_Range1; } set { this._IP_Range1 = value; } }
public uint IP_Range2 { get { return this._IP_Range2; } set { this._IP_Range2 = value; } }
}
}
7 Download the file I've included in this post and extract it into Database/Misc.
8 Lastly you can find all the Countries IP's which you wish to block from connecting to your server on the following site. Simply choose you country, copy all the IP ranges and viola!
private static void SaveInventory(GameClient Client)
{
IniFile wrtr = new IniFile(DatabasePath + @"\Inventory\" + Client.Username + ".ini");
// I use a foreach loop because the Inventory
// variables length can change at any time technically
// seeing as it's in sync with the dictionary, but not
// neccicarly with the function calling it
// this is rare -- but I've had it happen.
sbyte i = 0;
foreach (IConquerItem Item in Client.Inventory)
{
wrtr.Write("Inventory", "Item[" + i.ToString() + "]", Item.ToString());
}
wrtr.Write("Inventory", "Count", i.ToString());
}
Problem : variable "i" will stay as 0 since nothing is added to it.
Fix : add "i++" inside the foreach loop
Code:
private static void SaveInventory(GameClient Client)
{
IniFile wrtr = new IniFile(DatabasePath + @"\Inventory\" + Client.Username + ".ini");
// I use a foreach loop because the Inventory
// variables length can change at any time technically
// seeing as it's in sync with the dictionary, but not
// neccicarly with the function calling it
// this is rare -- but I've had it happen.
sbyte i = 0;
foreach (IConquerItem Item in Client.Inventory)
{
wrtr.Write("Inventory", "Item[" + i.ToString() + "]", Item.ToString());
i++;
}
wrtr.Write("Inventory", "Count", i.ToString());
}
[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:
{
[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