- Joined
- Sep 8, 2007
- Messages
- 1,381
- Reaction score
- 39
Does this mean we can add sotry mode to GunZ ?
Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!
Join Today!A SVN in sourceforge is not a bad idea.
Does this mean we can add sotry mode to GunZ ?
lol, everything gets delayed by real life.
some advice : Abandon your life, it sucks. You will get alot more done.
OR get one of those jobs where you work at your own time and pace at your own home. Which means you can work on it any time you like.
Thanks for the update though.
Lol. Well we picked C# for a few reasons.
1) It's an open-source project, so this is made with the community in mind. A lot of people in the Gunz community seem to know or are learning C#. That's also why we were very thorough with the documentation, comments, etc.
2) Gunz servers don't seem to need very many resources at all, so the overhead from making it in a .NET language seems like it'd probably be negligible. I could be wrong, we'll see. But this is seeming like the case to me.
3) It's got a lot of stuff already built into the language, so it speeds up development time, in my opinion at least. I'm decent with C++ but not fluent enough to attempt something like this, nor do I have a big enough ego to try to code it without the proper experience in C++.
But thanks for the comment, I appreciate it.
Nova™;4919073 said:Two questions,
First,
How are you going to write the login packets ? Could you have like ijji, a login page on the website and code the login to a .dll.
Second,
Who are all thease teams ?
Team Lion, Team Zebra, I've never heard of them, you just all appeared. Are you old MAIET staff ?
Just I've never seen you around and when you come along you're like the best.
could u comment out most of the code so, that we can understand better (this doesnt go to phail772 -__-)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
namespace MatchServer
{
class Match
{
public static void MatchResponseLogin(Client pClient, Packet cPacket)
{
string username = null;
string password = null;
int version = 0;
int crc = 0;
int eCount = 0;
int eSize = 0;
if (!cPacket.Read(ref username) ||
!cPacket.Read(ref password) ||
!cPacket.Read(ref version) ||
!cPacket.Read(ref crc) ||
!cPacket.Read(ref eCount, ref eSize))
{
pClient.Log(LogType.Error, "User: {0}. Pass: {1}. Version: {2}. CRC: {3}. Count: {4}. Size: {5}", username, password, version, crc, eCount, eSize);
pClient.Disconnect();
}
Result result = Result.Accepted;
SqlConnection sql = new SqlConnection(Program.SQLString);
sql.Open();
SqlTransaction trans = sql.BeginTransaction(IsolationLevel.RepeatableRead);
SqlCommand cmd = new SqlCommand("EXEC [dbo].spGetLoginInfo @UserID", sql,trans);
cmd.Parameters.AddWithValue("@UserID", username);
SqlDataReader sqlData = cmd.ExecuteReader();
if (!sqlData.Read())
result = Result.WrongPassword;
else
{
pClient.AccountID = Convert.ToInt32(sqlData["AID"]);
SqlCommand sqlcmd = new SqlCommand("SELECT * FROM Account WHERE AID=@AID", sql,trans);
sqlcmd.Parameters.AddWithValue("@AID", pClient.AccountID);
SqlDataReader sDR = sqlcmd.ExecuteReader();
if (!sDR.Read())
result = Result.WrongPassword;
else
{
pClient.UGradeID = Convert.ToByte(sDR["UGradeID"]);
if (!password.Equals(sqlData["Password"]))
result = Result.WrongPassword;
else if (pClient.UGradeID == 253 || pClient.UGradeID == 105)
result = Result.Banned;
else
pClient.UGradeID = Convert.ToByte(sDR["UGradeID"]);
}
}
Packet packet = new Packet(OpCode.MatchResponseLogin, PacketEncryption.Encrypted, pClient.PacketCount);
packet.Write((int)result);
packet.Write("Viral Server");
packet.Write((byte)1);
packet.Write(username);
packet.Write(pClient.UGradeID);
packet.Write((byte)0);
packet.Write(pClient.ClientID);
packet.Write(1, 20);
packet.WriteSkip(20);
pClient.Send(packet);
pClient.Register(OpCode.MatchRequestCharList, MatchResponseAccountCharList);
}
public static void MatchResponseAccountCharList(Client pClient, Packet pPacket)
{
Int32 eSize, eCount;
eSize = eCount = 0;
byte[] rand = new byte[20];
if (!pPacket.Read(ref eSize, ref eCount) ||
!pPacket.Read(ref rand, 0, 20))
{
pClient.Disconnect();
}
Packet cPacket = new Packet(OpCode.MatchResponseCharList, PacketEncryption.Encrypted, pClient.PacketCount);
using (SqlConnection sql = new SqlConnection(Program.SQLString))
{
sql.Open();
SqlTransaction trans = sql.BeginTransaction(IsolationLevel.RepeatableRead);
SqlCommand cmd = new SqlCommand("SELECT COUNT(*) AS count FROM Character WHERE AID=@AID", sql,trans);
cmd.Parameters.AddWithValue("@AID", pClient.AccountID);
cPacket.Write(34, Convert.ToInt32(cmd.ExecuteScalar()));
cmd = new SqlCommand("SELECT TOP 4 Name,Level FROM Character WHERE AID=@AID ORDER BY Name ASC", sql,trans);
cmd.Parameters.AddWithValue("@AID", pClient.AccountID);
SqlDataReader sdR = cmd.ExecuteReader();
byte index = 0;
while (sdR.Read())
{
cPacket.Write(Convert.ToString("Name"),32);
cPacket.Write(index++);
cPacket.Write(Convert.ToByte("Level"));
}
}
pClient.Send(cPacket);
}
}
}
Code:using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using System.Data.SqlClient; namespace MatchServer { class Match { public static void MatchResponseLogin(Client pClient, Packet cPacket) { string username = null; string password = null; int version = 0; int crc = 0; int eCount = 0; int eSize = 0; if (!cPacket.Read(ref username) || !cPacket.Read(ref password) || !cPacket.Read(ref version) || !cPacket.Read(ref crc) || !cPacket.Read(ref eCount, ref eSize)) { pClient.Log(LogType.Error, "User: {0}. Pass: {1}. Version: {2}. CRC: {3}. Count: {4}. Size: {5}", username, password, version, crc, eCount, eSize); pClient.Disconnect(); } Result result = Result.Accepted; SqlConnection sql = new SqlConnection(Program.SQLString); sql.Open(); SqlTransaction trans = sql.BeginTransaction(IsolationLevel.RepeatableRead); SqlCommand cmd = new SqlCommand("EXEC [dbo].spGetLoginInfo @UserID", sql,trans); cmd.Parameters.AddWithValue("@UserID", username); SqlDataReader sqlData = cmd.ExecuteReader(); if (!sqlData.Read()) result = Result.WrongPassword; else { pClient.AccountID = Convert.ToInt32(sqlData["AID"]); SqlCommand sqlcmd = new SqlCommand("SELECT * FROM Account WHERE AID=@AID", sql,trans); sqlcmd.Parameters.AddWithValue("@AID", pClient.AccountID); SqlDataReader sDR = sqlcmd.ExecuteReader(); if (!sDR.Read()) result = Result.WrongPassword; else { pClient.UGradeID = Convert.ToByte(sDR["UGradeID"]); if (!password.Equals(sqlData["Password"])) result = Result.WrongPassword; else if (pClient.UGradeID == 253 || pClient.UGradeID == 105) result = Result.Banned; else pClient.UGradeID = Convert.ToByte(sDR["UGradeID"]); } } Packet packet = new Packet(OpCode.MatchResponseLogin, PacketEncryption.Encrypted, pClient.PacketCount); packet.Write((int)result); packet.Write("Viral Server"); packet.Write((byte)1); packet.Write(username); packet.Write(pClient.UGradeID); packet.Write((byte)0); packet.Write(pClient.ClientID); packet.Write(1, 20); packet.WriteSkip(20); pClient.Send(packet); pClient.Register(OpCode.MatchRequestCharList, MatchResponseAccountCharList); } public static void MatchResponseAccountCharList(Client pClient, Packet pPacket) { Int32 eSize, eCount; eSize = eCount = 0; byte[] rand = new byte[20]; if (!pPacket.Read(ref eSize, ref eCount) || !pPacket.Read(ref rand, 0, 20)) { pClient.Disconnect(); } Packet cPacket = new Packet(OpCode.MatchResponseCharList, PacketEncryption.Encrypted, pClient.PacketCount); using (SqlConnection sql = new SqlConnection(Program.SQLString)) { sql.Open(); SqlTransaction trans = sql.BeginTransaction(IsolationLevel.RepeatableRead); SqlCommand cmd = new SqlCommand("SELECT COUNT(*) AS count FROM Character WHERE AID=@AID", sql,trans); cmd.Parameters.AddWithValue("@AID", pClient.AccountID); cPacket.Write(34, Convert.ToInt32(cmd.ExecuteScalar())); cmd = new SqlCommand("SELECT TOP 4 Name,Level FROM Character WHERE AID=@AID ORDER BY Name ASC", sql,trans); cmd.Parameters.AddWithValue("@AID", pClient.AccountID); SqlDataReader sdR = cmd.ExecuteReader(); byte index = 0; while (sdR.Read()) { cPacket.Write(Convert.ToString("Name"),32); cPacket.Write(index++); cPacket.Write(Convert.ToByte("Level")); } } pClient.Send(cPacket); } } }
Mine that I did in half an hour last night.
Code:using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using System.Data.SqlClient; namespace MatchServer { class Match { public static void MatchResponseLogin(Client pClient, Packet cPacket) { string username = null; string password = null; int version = 0; int crc = 0; int eCount = 0; int eSize = 0; if (!cPacket.Read(ref username) || !cPacket.Read(ref password) || !cPacket.Read(ref version) || !cPacket.Read(ref crc) || !cPacket.Read(ref eCount, ref eSize)) { pClient.Log(LogType.Error, "User: {0}. Pass: {1}. Version: {2}. CRC: {3}. Count: {4}. Size: {5}", username, password, version, crc, eCount, eSize); pClient.Disconnect(); } Result result = Result.Accepted; SqlConnection sql = new SqlConnection(Program.SQLString); sql.Open(); SqlTransaction trans = sql.BeginTransaction(IsolationLevel.RepeatableRead); SqlCommand cmd = new SqlCommand("EXEC [dbo].spGetLoginInfo @UserID", sql,trans); cmd.Parameters.AddWithValue("@UserID", username); SqlDataReader sqlData = cmd.ExecuteReader(); if (!sqlData.Read()) result = Result.WrongPassword; else { pClient.AccountID = Convert.ToInt32(sqlData["AID"]); SqlCommand sqlcmd = new SqlCommand("SELECT * FROM Account WHERE AID=@AID", sql,trans); sqlcmd.Parameters.AddWithValue("@AID", pClient.AccountID); SqlDataReader sDR = sqlcmd.ExecuteReader(); if (!sDR.Read()) result = Result.WrongPassword; else { pClient.UGradeID = Convert.ToByte(sDR["UGradeID"]); if (!password.Equals(sqlData["Password"])) result = Result.WrongPassword; else if (pClient.UGradeID == 253 || pClient.UGradeID == 105) result = Result.Banned; else pClient.UGradeID = Convert.ToByte(sDR["UGradeID"]); } } Packet packet = new Packet(OpCode.MatchResponseLogin, PacketEncryption.Encrypted, pClient.PacketCount); packet.Write((int)result); packet.Write("Viral Server"); packet.Write((byte)1); packet.Write(username); packet.Write(pClient.UGradeID); packet.Write((byte)0); packet.Write(pClient.ClientID); packet.Write(1, 20); packet.WriteSkip(20); pClient.Send(packet); pClient.Register(OpCode.MatchRequestCharList, MatchResponseAccountCharList); } public static void MatchResponseAccountCharList(Client pClient, Packet pPacket) { Int32 eSize, eCount; eSize = eCount = 0; byte[] rand = new byte[20]; if (!pPacket.Read(ref eSize, ref eCount) || !pPacket.Read(ref rand, 0, 20)) { pClient.Disconnect(); } Packet cPacket = new Packet(OpCode.MatchResponseCharList, PacketEncryption.Encrypted, pClient.PacketCount); using (SqlConnection sql = new SqlConnection(Program.SQLString)) { sql.Open(); SqlTransaction trans = sql.BeginTransaction(IsolationLevel.RepeatableRead); SqlCommand cmd = new SqlCommand("SELECT COUNT(*) AS count FROM Character WHERE AID=@AID", sql,trans); cmd.Parameters.AddWithValue("@AID", pClient.AccountID); cPacket.Write(34, Convert.ToInt32(cmd.ExecuteScalar())); cmd = new SqlCommand("SELECT TOP 4 Name,Level FROM Character WHERE AID=@AID ORDER BY Name ASC", sql,trans); cmd.Parameters.AddWithValue("@AID", pClient.AccountID); SqlDataReader sdR = cmd.ExecuteReader(); byte index = 0; while (sdR.Read()) { cPacket.Write(Convert.ToString("Name"),32); cPacket.Write(index++); cPacket.Write(Convert.ToByte("Level")); } } pClient.Send(cPacket); } } }
Mine that I did in half an hour last night.