Register for your free account! | Forgot your password?

You last visited: Today at 03:44

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

Advertisement



[Release] cq_actions for COEMU v2

Discussion on [Release] cq_actions for COEMU v2 within the CO2 PServer Guides & Releases forum part of the CO2 Private Server category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Jul 2006
Posts: 60
Received Thanks: 170
[Release] cq_actions for COEMU v2

im coding a system to read the cq_nps, check the cq_task and load cq_actions

there is just some types working yet:

Npc Text,
Npc Link,
Npc Face,
Npc End,
Npc Char stats Check (not all coded),
Npc Teleport,
Npc Save old MapID, X, and Y when you are teleported


Now let's start

into GameServerProject find it: public static void LoadNpcs() in Database.cs

change to:

Code:
	public static void LoadNpcs()
		{
			MySqlCommand Cmd = new MySqlCommand("SELECT * FROM `cq_npc`", DatabaseConnection.NewConnection());
			MySqlDataReader DR = Cmd.ExecuteReader(CommandBehavior.CloseConnection);
			while(DR.Read())
			{
				Struct.NPC NPC = new Struct.NPC();
				NPC.Direction = Convert.ToInt32(DR["type"]);
				NPC.Flag = Convert.ToInt32(DR["sort"]);
				NPC.ID = Convert.ToInt32(DR["id"]);
				NPC.Map = Convert.ToInt32(DR["mapid"]);
				NPC.SubType = Convert.ToInt32(DR["lookface"]);
				NPC.Type = Convert.ToInt32(DR["id"]);
				NPC.X = Convert.ToInt32(DR["cellx"]);
				NPC.Y = Convert.ToInt32(DR["celly"]);
				if(!Nano.Npcs.ContainsKey(NPC.ID))
					Nano.Npcs.Add(NPC.ID, NPC);
			}
			Console.WriteLine("[GameServer] Loaded " + Nano.Npcs.Count + " npcs into the world.");
			DR.Close();
			Cmd.Dispose();
		}
now bellow of it add this voids:

Code:
 public static void GetNPCTask(int MyID, ClientSocket CSocket)
        {
            MySqlCommand Cmd = new MySqlCommand("SELECT * FROM `cq_npc` WHERE `id` = " + MyID + "", DatabaseConnection.NewConnection());
            MySqlDataReader DR = Cmd.ExecuteReader(CommandBehavior.CloseConnection);
            while (DR.Read())
            {
                int task0 = Convert.ToInt32(DR["task0"]);
                int task1 = Convert.ToInt32(DR["task1"]);
                int actions = 0;
                if (task0 != 0) { actions = task0; }
                else if (task1 != 0) { actions = task1; }

                if (actions != 0)
                {
                    GetTaskAction(task0, CSocket);
                }
            }
            DR.Close();
            Cmd.Dispose();
        }
        public static void LoadActions(int ActionID, ClientSocket CSocket)
        {
            MySqlCommand CMD = new MySqlCommand("SELECT * FROM `actions` WHERE `id` = " + ActionID + "", DatabaseConnection.NewConnection());
            MySqlDataReader DR = CMD.ExecuteReader(CommandBehavior.CloseConnection);
            while (DR.Read())
            {
                bool callfail = false;

                int id_next = Convert.ToInt32(DR["id_next"]);
                int id_fail = Convert.ToInt32(DR["id_nextfail"]);
                int type = Convert.ToInt32(DR["type"]);
                int data = Convert.ToInt32(DR["data"]);
                string param = Convert.ToString(DR["param"]);

                if (type == 101) //npc text
                {
                    param.Replace("%user_name", CSocket.Client.Name);

                    Handlers.Handler.Text(param, CSocket);
                }
                else if (type == 102) //npc link
                {
                    string[] spit = param.Split(' ');
                    int a = CSocket.Client.NpcTasks.Count +1;
                    int link = 0;

                    try { link = Convert.ToInt32(spit[1]); }
                    catch { }

                    CSocket.Client.NpcTasks.Add(a, link);
                    Handlers.Handler.Link(spit[0], a, CSocket);
                }
                else if (type == 103)//npc input
                {
                    string[] spit = param.Split(' ');
                    int a = CSocket.Client.NpcTasks.Count + 1;
                    int link = 0; int unk = 0;

                    try { link = Convert.ToInt32(spit[1]); unk = Convert.ToInt32(spit[0]); }
                    catch { }

                    CSocket.Client.NpcTasks.Add(a, link);
                    Handlers.Handler.Input(spit[2], link, CSocket);
                }
                else if (type == 104)//npc face
                {
                    string[] spit = param.Split(' ');
                    int face = 0;

                    try { face = Convert.ToInt32(spit[2]); }
                    catch { }

                    Handlers.Handler.Face(face, CSocket);
                }
                else if (type == 120)//npc end
                { Handlers.Handler.End(CSocket); }
                else if (type == 1001)//check user
                {
                    string[] spit = param.Split(' ');
                    string tocheck = spit[0];  string operatorr = spit[1]; string value = spit[2];

                    callfail = NpcActions.TQCheckUserStats(tocheck, operatorr, value, CSocket);
                }
                else if (type == 1003)//transport to map
                {
                     string[] spit = param.Split(' ');
                     Handlers.Handler.Teleport(int.Parse(spit[0]), int.Parse(spit[1]), int.Parse(spit[2]), 0, CSocket);
                }
                else if (type == 1004) //save map
                {
                    string[] spit = param.Split(' ');
                    CSocket.Client.RecordMap = int.Parse(spit[0]);
                    CSocket.Client.RecordX = int.Parse(spit[1]);
                    CSocket.Client.RecordY = int.Parse(spit[2]);
                    Database.SaveCharacter(CSocket.Client);
                }
                else if (type == 1006) //transport to recored map
                {
                    Handlers.Handler.Teleport(CSocket.Client.RecordMap, CSocket.Client.RecordX, CSocket.Client.RecordY, 0, CSocket);
                }
                if (id_next != 0 && callfail == false) { LoadActions(id_next, CSocket); }

                if (id_fail != 0 && callfail == true) { LoadActions(id_fail, CSocket); }

            }
            CMD.Dispose();
            DR.Close();
        }
        public static void GetTaskAction(int taskID, ClientSocket CSocket)
        {
            MySqlCommand CMD = new MySqlCommand("SELECT * FROM `task` WHERE `id` = " + taskID + "", DatabaseConnection.NewConnection());
            MySqlDataReader DR = CMD.ExecuteReader(CommandBehavior.CloseConnection);
            while (DR.Read())
            {
                int id_next = Convert.ToInt32(DR["id_next"]);
                LoadActions(id_next, CSocket);
            }
            CMD.Dispose();
            DR.Close();
        }
now go to handlers folder and open NpcTalk.cs and replace all the lines for this

Code:
/*
 * Created by SharpDevelop.
 * User: sams
 * Date: 3/18/2009
 * Time: 8:02 PM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using System.Collections;
using System.Collections.Generic;
using CoEmu_v2_GameServer.Connections;
using CoEmu_v2_GameServer.Entities;
using CoEmu_v2_GameServer.Structs;
using CoEmu_v2_GameServer.Packets;
using CoEmu_v2_GameServer.Calculations;
using Lua511;
using LuaInterface;

namespace CoEmu_v2_GameServer.Handlers
{
	/// <summary>
	/// Description of NpcTalk.
	/// </summary>
	public partial class Handler
	{
		public static void NpcTalk(ClientSocket CSocket, int ID, int LinkBack)
		{
			if(ID > 0)
				CSocket.Client.LastNPC = ID;
			switch(ID)
			{
				case 8://TC - WHS
					{
						CSocket.Send(ConquerPacket.General(CSocket.Client.ID, 4, 0, 0, 0, 0, Struct.DataType.Dialog));
						break;
					}
				case 10012://PC - WHS
					{
						CSocket.Send(ConquerPacket.General(CSocket.Client.ID, 4, 0, 0, 0, 0, Struct.DataType.Dialog));
						break;
					}
				case 10011://DC - WHS
					{
						CSocket.Send(ConquerPacket.General(CSocket.Client.ID, 4, 0, 0, 0, 0, Struct.DataType.Dialog));
						break;
					}
				case 10028://AM - WHS
					{
						CSocket.Send(ConquerPacket.General(CSocket.Client.ID, 4, 0, 0, 0, 0, Struct.DataType.Dialog));
						break;
					}
				case 10027://BI - WHS
					{
						CSocket.Send(ConquerPacket.General(CSocket.Client.ID, 4, 0, 0, 0, 0, Struct.DataType.Dialog));
						break;
					}
				case 44://MA - WHS
					{
						CSocket.Send(ConquerPacket.General(CSocket.Client.ID, 4, 0, 0, 0, 0, Struct.DataType.Dialog));
						break;
					}
					default:
					{
                        if (LinkBack == 0)
                        {
                            CSocket.Client.NpcTasks.Clear();
                            Database.Database.GetNPCTask(ID, CSocket);
                            break;
                        }
                        else
                        {
                            int task = 0;
                            foreach (DictionaryEntry DE in CSocket.Client.NpcTasks)
                            {
                                if (Convert.ToInt32(DE.Key) == LinkBack)
                                { task = Convert.ToInt32(DE.Value); }
                            }
                            Database.Database.GetTaskAction(task, CSocket);
                            break;
                        }
					}
			}
		}
		public static void Text(string value, ClientSocket CSocket)
		{
			CSocket.Send(ConquerPacket.NPCTalk(255, 1, value));
		}
		public static void Money(int value, ClientSocket CSocket)
		{
			CSocket.Client.Money += value;
			CSocket.Send(ConquerPacket.Status(CSocket, 2, CSocket.Client.Money, Struct.StatusTypes.InvMoney));
		}
		public static void CPs(int value, ClientSocket CSocket)
		{
			CSocket.Client.CPs += value;
			CSocket.Send(ConquerPacket.Status(CSocket, 2, CSocket.Client.CPs, Struct.StatusTypes.InvCPoints));
		}
		public static void Link(string value, int LinkBack, ClientSocket CSocket)
		{
			CSocket.Send(ConquerPacket.NPCTalk(LinkBack, 2, value));
		}
		public static void Input(string text, int LinkBack, ClientSocket CSocket)
		{
			CSocket.Send(ConquerPacket.NPCTalk(LinkBack, 3, text));
		}
        public static void Face(int Face, ClientSocket CSocket)
        {
            CSocket.Send(ConquerPacket.NPCTalk(2544, Face, 255, 4));
        }
		public static void End(ClientSocket CSocket)
		{
			CSocket.Send(ConquerPacket.NPCTalk(0, 0, 255, 100));
		}
	}
}
now go find it: public bool Dead = false; in Character.cs

and under of this code add:

Code:
public Hashtable NpcTasks = new Hashtable();//temp npctask loads

        public int RecordMap = 1002;
        public int RecordX = 438;
        public int RecordY = 377;
now, go to Database.cs again and find it: Client.Class = (Struct.ClassType)Convert.ToInt32(DR["Class"]);

bellow of it add

Client.RecordMap = Convert.ToInt32(DR["RecordMap"]);
Client.RecordX = Convert.ToInt32(DR["RecordX"]);
Client.RecordY = Convert.ToInt32(DR["RecordY"]);

and now find it: public static void SaveCharacter(Character Client)

and change for

Code:
public static void SaveCharacter(Character Client)
		{
            MySqlCommand Cmd = new MySqlCommand("UPDATE `characters` SET `Level` = " + Client.Level + ", `WHMoney` = " + Client.WHMoney + ", `PkPoints` = " + Client.PkPoints + ", `xCord` = " + Client.X + ", `yCord` = " + Client.Y + ", `Map` = " + (int)Client.Map + ", `HairStyle` = " + Client.Hair + ", `Class` = " + (int)Client.Class + ", `Exp` = " + Client.Exp + ", `Money` = " + Client.Money + ", `Str` = " + Client.Strength + ",`Vit` = " + Client.Vitality + ", `Spi` = " + Client.Spirit + ", `Dex` = " + Client.Dexterity + ", `StatPoints` = " + Client.StatPoints + ", `FirstLog` = " + 1 + ", `Reborn` = " + Client.Reborn + ", `HP` = " + Client.CurrentHP + ", `MP` = " + Client.CurrentMP + ", `RecordMap` = " + Client.RecordMap + ", `RecordX` = " + Client.RecordX + ", `RecordY` = " + Client.RecordY +" WHERE `CharID` = " + Client.ID, DatabaseConnection.NewConnection());
			Cmd.ExecuteNonQuery();
			Cmd.Connection.Close();
			Cmd.Connection.Dispose();
			Cmd.Dispose();
		}
now add in the project the NpcActions.cs (NpcActions.cs.rar)

and execute the batch of my sql (it will add table: actions, task, cq_npc, and update the character table (Junior_SQL.rar)

Credits goto:

Me (all code is mine work)
felipeboladao (for a little help) thx dude
magnon for the cq_actions very thx

More Updates coming soon when i get free time to code
and for who have a must english database and want help me/us to make it much perfect pm me
Attached Files
File Type: rar NpcActions.cs.rar (1,001 Bytes, 208 views)
File Type: rar Junior_SQL.rar (577.2 KB, 292 views)
master15 is offline  
Thanks
8 Users
Old 05/29/2009, 03:14   #2
 
Epic-Chaos's Avatar
 
elite*gold: 0
Join Date: May 2009
Posts: 113
Received Thanks: 30
good luck to ya
Epic-Chaos is offline  
Old 05/29/2009, 03:37   #3
 
hunterman01's Avatar
 
elite*gold: 20
Join Date: Dec 2006
Posts: 945
Received Thanks: 175
Actually looks really good
hunterman01 is offline  
Old 05/29/2009, 04:03   #4
 
elite*gold: 0
Join Date: Mar 2009
Posts: 56
Received Thanks: 31
Nevermind. Figured it out.
~*Dutchess*~ is offline  
Old 05/29/2009, 04:53   #5
 
elite*gold: 0
Join Date: Nov 2006
Posts: 81
Received Thanks: 25
Very cool!
Zimbolt is offline  
Old 05/29/2009, 07:48   #6
 
sawickas's Avatar
 
elite*gold: 0
Join Date: Sep 2008
Posts: 617
Received Thanks: 38
It work? Tested?
sawickas is offline  
Old 05/29/2009, 10:51   #7
 
elite*gold: 0
Join Date: Mar 2006
Posts: 71
Received Thanks: 0
Dont work to much errors in source
parkiet6 is offline  
Old 05/29/2009, 10:59   #8
 
IcedEarth's Avatar
 
elite*gold: 0
Join Date: Mar 2007
Posts: 146
Received Thanks: 17
lawl ? I just tried and it works just fine
IcedEarth is offline  
Old 05/29/2009, 11:05   #9
 
elite*gold: 0
Join Date: Mar 2006
Posts: 71
Received Thanks: 0
Quote:
Originally Posted by IcedEarth View Post
lawl ? I just tried and it works just fine
How did you fix it then becouse when I type this in my databas.cs it gives lots of errors

Code:
public static void GetNPCTask(int MyID, ClientSocket CSocket)
        {
            MySqlCommand Cmd = new MySqlCommand("SELECT * FROM `cq_npc` WHERE `id` = " + MyID + "", DatabaseConnection.NewConnection());
            MySqlDataReader DR = Cmd.ExecuteReader(CommandBehavior.CloseConnection);
            while (DR.Read())
            {
                int task0 = Convert.ToInt32(DR["task0"]);
                int task1 = Convert.ToInt32(DR["task1"]);
                int actions = 0;
                if (task0 != 0) { actions = task0; }
                else if (task1 != 0) { actions = task1; }

                if (actions != 0)
                {
                    GetTaskAction(task0, CSocket);
                }
            }
            DR.Close();
            Cmd.Dispose();
        }
        public static void LoadActions(int ActionID, ClientSocket CSocket)
        {
            MySqlCommand CMD = new MySqlCommand("SELECT * FROM `actions` WHERE `id` = " + ActionID + "", DatabaseConnection.NewConnection());
            MySqlDataReader DR = CMD.ExecuteReader(CommandBehavior.CloseConnection);
            while (DR.Read())
            {
                bool callfail = false;

                int id_next = Convert.ToInt32(DR["id_next"]);
                int id_fail = Convert.ToInt32(DR["id_nextfail"]);
                int type = Convert.ToInt32(DR["type"]);
                int data = Convert.ToInt32(DR["data"]);
                string param = Convert.ToString(DR["param"]);

                if (type == 101) //npc text
                {
                    param.Replace("%user_name", CSocket.Client.Name);

                    Handlers.Handler.Text(param, CSocket);
                }
                else if (type == 102) //npc link
                {
                    string[] spit = param.Split(' ');
                    int a = CSocket.Client.NpcTasks.Count +1;
                    int link = 0;

                    try { link = Convert.ToInt32(spit[1]); }
                    catch { }

                    CSocket.Client.NpcTasks.Add(a, link);
                    Handlers.Handler.Link(spit[0], a, CSocket);
                }
                else if (type == 103)//npc input
                {
                    string[] spit = param.Split(' ');
                    int a = CSocket.Client.NpcTasks.Count + 1;
                    int link = 0; int unk = 0;

                    try { link = Convert.ToInt32(spit[1]); unk = Convert.ToInt32(spit[0]); }
                    catch { }

                    CSocket.Client.NpcTasks.Add(a, link);
                    Handlers.Handler.Input(spit[2], link, CSocket);
                }
                else if (type == 104)//npc face
                {
                    string[] spit = param.Split(' ');
                    int face = 0;

                    try { face = Convert.ToInt32(spit[2]); }
                    catch { }

                    Handlers.Handler.Face(face, CSocket);
                }
                else if (type == 120)//npc end
                { Handlers.Handler.End(CSocket); }
                else if (type == 1001)//check user
                {
                    string[] spit = param.Split(' ');
                    string tocheck = spit[0];  string operatorr = spit[1]; string value = spit[2];

                    callfail = NpcActions.TQCheckUserStats(tocheck, operatorr, value, CSocket);
                }
                else if (type == 1003)//transport to map
                {
                     string[] spit = param.Split(' ');
                     Handlers.Handler.Teleport(int.Parse(spit[0]), int.Parse(spit[1]), int.Parse(spit[2]), 0, CSocket);
                }
                else if (type == 1004) //save map
                {
                    string[] spit = param.Split(' ');
                    CSocket.Client.RecordMap = int.Parse(spit[0]);
                    CSocket.Client.RecordX = int.Parse(spit[1]);
                    CSocket.Client.RecordY = int.Parse(spit[2]);
                    Database.SaveCharacter(CSocket.Client);
                }
                else if (type == 1006) //transport to recored map
                {
                    Handlers.Handler.Teleport(CSocket.Client.RecordMap, CSocket.Client.RecordX, CSocket.Client.RecordY, 0, CSocket);
                }
                if (id_next != 0 && callfail == false) { LoadActions(id_next, CSocket); }

                if (id_fail != 0 && callfail == true) { LoadActions(id_fail, CSocket); }

            }
            CMD.Dispose();
            DR.Close();
        }
        public static void GetTaskAction(int taskID, ClientSocket CSocket)
        {
            MySqlCommand CMD = new MySqlCommand("SELECT * FROM `task` WHERE `id` = " + taskID + "", DatabaseConnection.NewConnection());
            MySqlDataReader DR = CMD.ExecuteReader(CommandBehavior.CloseConnection);
            while (DR.Read())
            {
                int id_next = Convert.ToInt32(DR["id_next"]);
                LoadActions(id_next, CSocket);
            }
            CMD.Dispose();
            DR.Close();
        }
parkiet6 is offline  
Old 05/29/2009, 12:44   #10
 
Nirion's Avatar
 
elite*gold: 0
Join Date: Oct 2007
Posts: 99
Received Thanks: 33
Sorry for the noob question but what exactly does this do?
Nirion is offline  
Old 05/29/2009, 12:48   #11
 
BrokeN^WinG's Avatar
 
elite*gold: 0
Join Date: Jan 2009
Posts: 425
Received Thanks: 424
Works Fine Guys
BrokeN^WinG is offline  
Old 05/29/2009, 13:18   #12
 
elite*gold: 0
Join Date: Mar 2006
Posts: 71
Received Thanks: 0
Can you upload your source then we have the codes and non errors
parkiet6 is offline  
Old 05/29/2009, 13:48   #13
 
felipeboladao's Avatar
 
elite*gold: 0
Join Date: Jul 2007
Posts: 255
Received Thanks: 273
very nice.
felipeboladao is offline  
Old 05/29/2009, 14:30   #14
 
$HaDoW's Avatar
 
elite*gold: 0
Join Date: Sep 2007
Posts: 285
Received Thanks: 78
works but it has bugs and still lots of ranslate and codeing is waiting !
$HaDoW is offline  
Old 05/29/2009, 14:44   #15
 
felipeboladao's Avatar
 
elite*gold: 0
Join Date: Jul 2007
Posts: 255
Received Thanks: 273
Use The Aplications to idit Positions, actions e etc..
felipeboladao is offline  
Thanks
1 User
Reply


Similar Threads Similar Threads
[Release] Trading (CoEmu v2)
02/04/2012 - CO2 PServer Guides & Releases - 60 Replies
Yes yes I know, I haven't released anything for a long time. Well, thought I might as well release some basic stuff for CoEmu v2. So here's a Simple Trading code. Packet Processor: #region Trading case 1056: // Trading {
[HELP] PLEASE Coemu release 180
09/08/2010 - CO2 Private Server - 2 Replies
Hello everyone good morning everyone! Well folks I'm trying to use the Coemu but the recent release that came out good I downloaded the source code and compiled it, if I did not know but was sure: D lol but one detail appeared very npcs are with the dialogues as if I was not wrong. Can someone give me a Help please or copille me if I did something wrong! ss follows below! http://img822.imageshack.us/img822/9706/1942037.t h.jpg Uploaded with ImageShack.us
[Release] >>>> CoEmu.V3
11/09/2009 - CO2 PServer Guides & Releases - 20 Replies
i got a new CoEmu from a china site but i don't know how to setup it this is the link of the source 4shared.com - online file sharing and storage - download NewCoemu.rar pass: AhmedZero
[Release] Second Reborn (CoEmu v2)
09/07/2009 - CO2 PServer Guides & Releases - 17 Replies
Hello!! It can have some bugs yet because it's on development! but here we go!! Obs.: 1º: Don't flame.... 2º if you wanna help... feel free to post!! First at all you need to have the first rb maded by samehvan!! and them you can make this... now Lets begin!
[Release] JewelerSun NPC (CoEmu V2)
08/08/2009 - CO2 PServer Guides & Releases - 16 Replies
hi guys i just finished it it took from me like 20 minute its big code i dont know why if any one have it more simple tell me here is the code in NpcTalk.Cs before case 390: add that code #region JewelerSun case 3953: { if (LinkBack == 0)



All times are GMT +2. The time now is 03:44.


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.