- Joined
- Aug 14, 2009
- Messages
- 2,304
- Reaction score
- 1,189
what version of client being used?
Added chat, debug user
You must be registered to see links
Loading char info from db
You must be registered to see links
Added debug packet names
You must be registered to see links
Added DB dump, fixed some types
You must be registered to see links
Latest GC DC.
I was looking at your code and a few things came up to me.So because savetherobots has not much time I'll try to help him with this.
My fork:
You must be registered to see links
Figured the Chat structure out:
Shop structure:
Anybody knows if this decryption method works with current client of drift city?
I'm no expert of DC servers but I do know a few things that might help you out.Even though it shows that the server is running I can't connect (Login)
Servers stays offline , DB exists > db info correct > etc... any help?
I'm no expert of DC servers but I do know a few things that might help you out.
If you're trying to login on the same machine you're running the server, try to login with the IP of 127.0.0.1 or localhost.
If you're trying to login from a different machine, use the correct IP and open the right ports (or set it to DMZ host) on the host machine.
If both machines are connected to the same router, try login to the LAN IP of the machine within the network (e.g. 192.xxx.xxx.xxx/10.0.0.xx).
using System;
using Rice.Server.Structures;
using System.Data.Common;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Rice.Server.Core;
namespace Rice.Server.Packets.Game
{
public static class Shop
{
[RicePacket(405, RiceServer.ServerType.Game)]
public static void BuyItem(RicePacket packet)
{
// 0 = Item ID
// 1 = Dont have any Idea
// 2 = Quantity
int itemID = packet.Reader.ReadInt16();
int unknown = packet.Reader.ReadInt16();
int quantity = packet.Reader.ReadInt16();
int price = 400;
Log.WriteLine ("{0} {1} {2}", itemID, unknown, quantity);
// 0 = Item ID
// 1 = Dont have any idea
// 2 = Qauntity
//Price Table With Item ID
if (itemID == 0)
price = 250;
else if (itemID == 5)
price = 400;
else if (itemID == 10)
price = 1050;
else if (itemID == 15)
price = 2000;
else if (itemID == 20)
price = 3250;
else if (itemID == 25)
price = 250;
else if (itemID == 30)
price = 400;
else if (itemID == 35)
price = 1050;
else if (itemID == 40)
price = 2000;
else if (itemID == 45)
price = 3250;
else if (itemID == 50)
price = 250;
else if (itemID == 55)
price = 400;
else if (itemID == 60)
price = 1050;
else if (itemID == 65)
price = 2000;
else if (itemID == 70)
price = 3250;
else if (itemID == 75)
price = 250;
else if (itemID == 80)
price = 400;
else if (itemID == 85)
price = 1050;
else if (itemID == 90)
price = 2000;
else if (itemID == 95)
price = 3250;
else if (itemID == 1445)
price = 5000 * quantity;
else if (itemID == 1488)
price = 50 * quantity;
else if (itemID == 1502)
price = 200 * quantity;
else if (itemID == 1503)
price = 1000 * quantity;
else if (itemID == 1504)
price = 30000 * quantity;
else if (itemID == 1516)
price = 5000 * quantity;
else if (itemID == 1554)
price = 100 * quantity;
else if (itemID == 1561)
price = 1000 * quantity;
else if (itemID == 1568)
price = 500 * quantity;
else if (itemID == 1569)
price = 1000 * quantity;
else if (itemID == 1570)
price = 2000 * quantity;
else if (itemID == 1665)
price = 1000 * quantity;
else if (itemID == 1666)
price = 1000 * quantity;
else if (itemID == 1667)
price = 1000 * quantity;
else if (itemID == 1818)
price = 3000 * quantity;
else if (itemID == 1874)
price = 49000 * quantity;
else if (itemID == 1875)
price = 63000 * quantity;
else if (itemID == 1876)
price = 98000 * quantity;
else if (itemID == 1877)
price = 196000 * quantity;
else if (itemID == 2546)
price = 4000 * quantity;
else if (itemID == 2547)
price = 6000 * quantity;
else if (itemID == 2548)
price = 7000 * quantity;
else if (itemID == 1979)
price = 1200 * quantity;
else if (itemID == 1980)
price = 700 * quantity;
else if (itemID == 1981)
price = 2000 * quantity;
else if (itemID == 1982)
price = 100 * quantity;
else if (itemID == 2032)
price = 1000 * quantity;
else if (itemID == 1989)
price = 10000 * quantity;
else if (itemID == 2013)
price = 15000 * quantity;
else if (itemID == 2014)
price = 15000 * quantity;
else if (itemID == 2015)
price = 15000 * quantity;
else if (itemID == 2034)
price = 10000 * quantity;
else if (itemID == 2068)
price = 5000 * quantity;
else if (itemID == 2069)
price = 7000 * quantity;
else if (itemID == 2070)
price = 10000 * quantity;
else if (itemID == 2700)
price = 10000 * quantity;
else if (itemID == 2708)
price = 10000 * quantity;
else if (itemID == 2709)
price = 10000 * quantity;
else if (itemID == 2003)
price = 10000 * quantity;
else if (itemID == 2004)
price = 12000 * quantity;
else if (itemID == 2005)
price = 15000 * quantity;
else if (itemID == 2031)
price = 12000 * quantity;
else if (itemID == 2036)
price = 20000 * quantity;
else if (itemID == 2025)
price = 30000 * quantity;
var ack = new RicePacket(406);
ack.Writer.Write(itemID);
ack.Writer.Write(quantity);
ack.Writer.Write(price);
packet.Sender.Send(ack);
packet.Sender.Error ("This Item Should be in your Inventory but...");
}
}
}
using Rice.Server.Structures;
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Rice.Game
{
public class Character
{
public User User;
public ulong UID;
public ulong CID;
public string Name;
public long Mito;
public int Avatar;
public int Level;
public int City;
public int CurrentCarID;
public int GarageLevel;
public int InventoryLevel;
public long TID;
private Character()
{
}
public CharInfo GetInfo()
{
return new CharInfo
{
Avatar = (ushort)Avatar,
Name = Name,
CID = CID,
City = City,
CurrentCarID = CurrentCarID,
ExpInfo = new ExpInfo // load this
{
BaseExp = 0,
CurExp = 0,
NextExp = 0
},
HancoinGarage = GarageLevel,
HancoinInven = InventoryLevel,
Level = (ushort)Level,
TeamId = TID,
TeamName = "Staff", // load this
MitoMoney = Mito
};
}
public static Character Retrieve(string charname)
{
DbConnection dbconn = Database.GetConnection();
DbCommand command = dbconn.CreateTextCommand("SELECT * FROM Characters WHERE Name = @char");
command.AddParameter("@char", charname);
Character character = null;
using (DbDataReader reader = command.ExecuteReader())
{
if (reader.Read())
{
character = new Character();
character.CID = Convert.ToUInt64(reader["CID"]);
character.UID = Convert.ToUInt64(reader["UID"]);
character.Name = reader["Name"] as string;
character.Mito = Convert.ToInt64(reader["Mito"]);
character.Avatar = Convert.ToInt32(reader["Avatar"]);
character.Level = Convert.ToInt32(reader["Level"]);
character.City = Convert.ToInt32(reader["City"]);
character.CurrentCarID = Convert.ToInt32(reader["CurrentCarID"]);
character.InventoryLevel = Convert.ToInt32(reader["InventoryLevel"]);
character.GarageLevel = Convert.ToInt32(reader["GarageLevel"]);
character.TID = Convert.ToInt64(reader["TID"]);
}
}
return character;
}
public static List<Character> Retrieve(ulong uid)
{
DbConnection dbconn = Database.GetConnection();
DbCommand command = dbconn.CreateTextCommand("SELECT * FROM Characters WHERE UID = @uid");
command.AddParameter("@uid", uid);
List<Character> chars = new List<Character>();
using (DbDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
var character = new Character();
character.CID = Convert.ToUInt64(reader["CID"]);
character.UID = Convert.ToUInt64(reader["UID"]);
character.Name = reader["Name"] as string;
character.Mito = Convert.ToInt64(reader["Mito"]);
character.Avatar = Convert.ToInt32(reader["Avatar"]);
character.Level = Convert.ToInt32(reader["Level"]);
character.City = Convert.ToInt32(reader["City"]);
character.CurrentCarID = Convert.ToInt32(reader["CurrentCarID"]);
character.InventoryLevel = Convert.ToInt32(reader["InventoryLevel"]);
character.GarageLevel = Convert.ToInt32(reader["GarageLevel"]);
character.TID = Convert.ToInt64(reader["TID"]);
chars.Add(character);
}
}
return chars;
}
}
}
EDIT: Made a price table on the shop structure i know its a bunch of ifs and else ifs but its just a test code!
Shop.cs (thx to GigaToni who made the original structure)
and it worked
Added the Inventory Level on database (HancoinInven)
Character.cs (/Game/Character.cs)
and worked pretty well
I'll keep this updated guys
UPDATE: i've not posted new things because i dont know anything about drift city packing method so i cant get the packets structures to keep this development
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Rice.Server.Core;
namespace Rice.Server.Packets.Lobby
{
public static class User
{
[RicePacket(60, RiceServer.ServerType.Lobby)]
public static void UserInfo(RicePacket packet)
{
Log.WriteLine("UserInfo request.");
var settings = new RicePacket(30);
settings.Writer.Write(Static.GameSettings);
packet.Sender.Send(settings);
packet.Sender.Player.Characters = Rice.Game.Character.Retrieve(packet.Sender.Player.User.UID);
var ack = new RicePacket(61);
ack.Writer.Write(0); // Permissions
ack.Writer.Write(packet.Sender.Player.Characters.Count); // Character Count
ack.Writer.WriteUnicodeStatic(packet.Sender.Player.User.Name, 18); // Username
ack.Writer.Write((long)0);
ack.Writer.Write((long)0);
ack.Writer.Write((long)0);
ack.Writer.Write(0);
foreach (var character in packet.Sender.Player.Characters)
{
ack.Writer.WriteUnicodeStatic(character.Name, 21); // Name
ack.Writer.Write(character.CID); // ID
ack.Writer.Write(character.Avatar); // Avatar
ack.Writer.Write(character.Level); // Level
ack.Writer.Write(1);
ack.Writer.Write(0x50);
ack.Writer.Write(0);
ack.Writer.Write(int.MaxValue / 2); // Creation Date
ack.Writer.Write(character.TID); // Crew ID
ack.Writer.Write(0L); // Crew Image
ack.Writer.WriteUnicodeStatic("Staff", 12); // Crew Name
ack.Writer.Write((short)0);
ack.Writer.Write((short)-1);
ack.Writer.Write((short)0);
}
packet.Sender.Send(ack);
Log.WriteLine("Sent character list.");
}
[RicePacket(80, RiceServer.ServerType.Lobby)]
public static void CheckCharacterName(RicePacket packet)
{
string characterName = packet.Reader.ReadUnicode();
Log.WriteLine("VerifyCharName: {0}", characterName);
// TODO: Verify
var ack = new RicePacket(81);
ack.Writer.WriteUnicodeStatic(characterName, 21);
ack.Writer.Write(1); // Availability. 1 = Available, 0 = Unavailable.
packet.Sender.Send(ack);
}
[RicePacket(82, RiceServer.ServerType.Lobby)]
public static void CreateCharacter(RicePacket packet)
{
string characterName = packet.Reader.ReadUnicode();
/*
string UIDCreate = packet.Reader.ReadUnicode();
DbConnection dbconn_c = Database.GetConnection();
DbCommand crechar = dbconn_c.CreateCommand();
crechar.CommandText = @"Insert into characters (UID, Name) values ('" + UIDCreate + "', '" + characterName + "')";
*/
Log.WriteLine("Create Character Success Name: {0}", characterName);
// TODO: Verify, Handle
}
[RicePacket(50, RiceServer.ServerType.Lobby)]
public static void DeleteCharacter(RicePacket packet)
{
string characterName = packet.Reader.ReadUnicode();
DbConnection dbconn_d = Database.GetConnection();
DbCommand delchar = dbconn_d.CreateCommand();
delchar.CommandText = @"Delete from characters Where Name =
'" + characterName + " ' ";
delchar.ExecuteNonQuery();
Log.WriteLine("Delete Character Success Name: {0}", characterName);
// TODO: Verify
var ack = new RicePacket(84);
ack.Writer.WriteUnicodeStatic(characterName, 21);
packet.Sender.Send(ack);
}
}
}