|
You last visited: Today at 23:06
Advertisement
[Release] Flower System (5165)
Discussion on [Release] Flower System (5165) within the CO2 PServer Guides & Releases forum part of the CO2 Private Server category.
02/20/2010, 14:44
|
#1
|
elite*gold: 0
Join Date: Apr 2009
Posts: 782
Received Thanks: 458
|
[Release] Flower System (5165)
Heya!
Mostly complete... just figure a way to save it on your server....
ScreenShots:
So let's do it...
first go make a new structure for flowers and them use this:
Code:
using System;
using System.Collections.Generic;
using System.Text;
namespace NewestCOServer
{
public partial class Struct
{
public class Flowers
{
public int RedRoses;
public int RedRoses2day;
public int Lilies;
public int Lilies2day;
public int Orchads;
public int Orchads2day;
public int Tulips;
public int Tulips2day;
public int Ammount;
}
}
}
them add this at character.cs more or less at line 1711:
Code:
public Struct.Flowers Flowers = new Struct.Flowers;
and them add this packet to Packets.cs:
Code:
public static COPacket FlowerPacket(string flowers)
{
byte[] packet = new byte[21 + flowers.Length + 8];
COPacket p = new COPacket(packet);
p.WriteInt16((ushort)(21 + flowers.Length));
p.WriteInt16(1150);
p.WriteInt32(1);
p.Move(8);
p.WriteByte(1);
p.WriteString(flowers);
return p;
}
after it go to PacketHandler.cs and add this at main packet switch:
Code:
#region Flowers
case 1150:
{
#region Target
string ID = "";
for (byte x = 18; x < 25; x++)
{
ID += Convert.ToChar(Data[x]).ToString();
}
uint TargetID = uint.Parse(ID);
Character SaveChar = (Character)World.H_Chars[TargetID];
#endregion
#region Type
string Typing = "";
for (byte x = 25; x < 32; x++)
{
Typing += Convert.ToChar(Data[x]).ToString();
}
string[] SplitValue = Typing.Split(' ');
int Flowers = int.Parse(SplitValue[1]);
int Type = int.Parse(SplitValue[2]);
//GC.LocalMessage(2005, "Flowers : " + Flowers);
//GC.LocalMessage(2005, "Type : " + Type);
#endregion
if (GC.MyChar.Body == 2001 || GC.MyChar.Body == 2002)
{ GC.LocalMessage(2005, "You can't sent flowers!"); return; }
if (World.H_Chars.Contains(TargetID))
{
if (World.AllFlowers.ContainsKey(SaveChar.EntityID))
{
Struct.Flowers F = World.AllFlowers[SaveChar.EntityID];
switch (Type)
{
#region Red Roses
case 0:
{
#region Item
string It = "751";
if (Flowers == 1)
It += "001";
else if (Flowers == 3)
It += "003";
else if (Flowers == 9)
It += "009";
else if (Flowers == 99)
It += "099";
else if (Flowers == 999)
It += "999";
#endregion
//GC.LocalMessage(2005, "Item id : " + It);
GC.MyChar.RemoveItem(GC.MyChar.NextItem(uint.Parse(It)));
F.RedRoses += Flowers;
F.RedRoses2day += Flowers;
SaveChar.Flowers = World.AllFlowers[SaveChar.EntityID];
SaveChar.FlowerName = "Red Roses";
break;
}
#endregion
#region Lilies
case 1:
{
#region Item
string It = "752";
if (Flowers == 1)
It += "001";
else if (Flowers == 3)
It += "003";
else if (Flowers == 9)
It += "009";
else if (Flowers == 99)
It += "099";
else if (Flowers == 999)
It += "999";
#endregion
//GC.LocalMessage(2005, "Item id : " + It);
GC.MyChar.RemoveItem(GC.MyChar.NextItem(uint.Parse(It)));
F.Lilies += Flowers;
F.Lilies2day += Flowers;
SaveChar.Flowers = World.AllFlowers[SaveChar.EntityID];
SaveChar.FlowerName = "Lilies";
break;
}
#endregion
#region Orchids
case 2:
{
#region Item
string It = "753";
if (Flowers == 1)
It += "001";
else if (Flowers == 3)
It += "003";
else if (Flowers == 9)
It += "009";
else if (Flowers == 99)
It += "099";
else if (Flowers == 999)
It += "999";
#endregion
//GC.LocalMessage(2005, "Item id : " + It);
GC.MyChar.RemoveItem(GC.MyChar.NextItem(uint.Parse(It)));
F.Orchads += Flowers;
F.Orchads2day += Flowers;
SaveChar.Flowers = World.AllFlowers[SaveChar.EntityID];
SaveChar.FlowerName = "Orchids";
break;
}
#endregion
#region Tulips
case 3:
{
#region Item
string It = "754";
if (Flowers == 1)
It += "001";
else if (Flowers == 3)
It += "003";
else if (Flowers == 9)
It += "009";
else if (Flowers == 99)
It += "099";
else if (Flowers == 999)
It += "999";
#endregion
//GC.LocalMessage(2005, "Item id : " + It);
GC.MyChar.RemoveItem(GC.MyChar.NextItem(uint.Parse(It)));
F.Tulips += Flowers;
F.Tulips2day += Flowers;
SaveChar.Flowers = World.AllFlowers[SaveChar.EntityID];
SaveChar.FlowerName = "Tulips";
break;
}
#endregion
}
GC.Message(2011, "What a love! " + GC.MyChar.Name + " has sent " + Flowers.ToString() + " " + SaveChar.FlowerName + " to your loved " + SaveChar.Name + "...");
}
else
{
Struct.Flowers F = new Struct.Flowers();
switch (Type)
{
#region Red Roses
case 0:
{
#region Item
string It = "751";
if (Flowers == 1)
It += "001";
else if (Flowers == 3)
It += "003";
else if (Flowers == 9)
It += "009";
else if (Flowers == 99)
It += "099";
else if (Flowers == 999)
It += "999";
#endregion
//GC.LocalMessage(2005, "Item id : " + It);
GC.MyChar.RemoveItem(GC.MyChar.NextItem(uint.Parse(It)));
F.RedRoses += Flowers;
F.RedRoses2day += Flowers;
SaveChar.FlowerName = "Red Roses";
break;
}
#endregion
#region Lilies
case 1:
{
#region Item
string It = "752";
if (Flowers == 1)
It += "001";
else if (Flowers == 3)
It += "003";
else if (Flowers == 9)
It += "009";
else if (Flowers == 99)
It += "099";
else if (Flowers == 999)
It += "999";
#endregion
//GC.LocalMessage(2005, "Item id : " + It);
GC.MyChar.RemoveItem(GC.MyChar.NextItem(uint.Parse(It)));
F.Lilies += Flowers;
F.Lilies2day += Flowers;
SaveChar.FlowerName = "Lilies";
break;
}
#endregion
#region Orchids
case 2:
{
#region Item
string It = "753";
if (Flowers == 1)
It += "001";
else if (Flowers == 3)
It += "003";
else if (Flowers == 9)
It += "009";
else if (Flowers == 99)
It += "099";
else if (Flowers == 999)
It += "999";
#endregion
//GC.LocalMessage(2005, "Item id : " + It);
GC.MyChar.RemoveItem(GC.MyChar.NextItem(uint.Parse(It)));
F.Orchads += Flowers;
F.Orchads2day += Flowers;
SaveChar.FlowerName = "Orchids";
break;
}
#endregion
#region Tulips
case 3:
{
#region Item
string It = "754";
if (Flowers == 1)
It += "001";
else if (Flowers == 3)
It += "003";
else if (Flowers == 9)
It += "009";
else if (Flowers == 99)
It += "099";
else if (Flowers == 999)
It += "999";
#endregion
//GC.LocalMessage(2005, "Item id : " + It);
GC.MyChar.RemoveItem(GC.MyChar.NextItem(uint.Parse(It)));
F.Tulips += Flowers;
F.Tulips2day += Flowers;
SaveChar.FlowerName = "Tulips";
break;
}
#endregion
default:
Console.WriteLine("Unknown Flower type " + GC.MyChar.FlowerType);
break;
}
World.AllFlowers.Add(SaveChar.EntityID, F);
SaveChar.Flowers = World.AllFlowers[SaveChar.EntityID];
GC.Message(2011, "What a love! " + GC.MyChar.Name + " has sent " + Flowers.ToString() + " " + SaveChar.FlowerName + " to your loved " + SaveChar.Name + "...");
}
Database.SaveFlowerRank(SaveChar);
}
else
{
GC.LocalMessage(2005, "The target player isn't online right now.");
}
break;
}
case 1151:
{
int sub = Data[4];
switch (sub)
{
case 2://View
{
Struct.Flowers F = GC.MyChar.Flowers;
string ToSend = " " + F.RedRoses.ToString() + " " + F.RedRoses2day.ToString() + " " + F.Lilies.ToString() + " " + F.Lilies2day.ToString() + " ";
ToSend += F.Orchads.ToString() + " " + F.Orchads2day.ToString() + " " + F.Tulips.ToString() + " " + F.Tulips2day.ToString();
GC.AddSend(Packets.FlowerPacket(ToSend));
break;
}
default:
{
Console.WriteLine("Unknown 1151 Sub type : " + sub.ToString());
break;
}
}
break;
}
#endregion
now them add this at World.cs at the public class World:
Code:
public static Dictionary<uint, Struct.Flowers> AllFlowers = new Dictionary<uint, Struct.Flowers>();
and now this is the load/save for MySql version.....
Code:
public static void SaveFlowerRank(Game.Character C)
{
MySqlConnection Conn = GetConnection();
bool exist = false;
string Name = C.Name;
if (Name.Contains("[PM]"))
Name.Replace("[PM]", "");
try
{
lock (Conn)
{
MySqlCommand Cmd = new MySqlCommand("SELECT * FROM `cq_flowers` WHERE `charuid2` = '" + C.Name + "'", Conn);
MySqlDataReader DR = Cmd.ExecuteReader();
while (DR.Read())
{
exist = true;
}
DR.Close();
}
lock (Conn)
{
Struct.Flowers F = C.Flowers;
if (exist)
{
MySqlCommand Cmd = new MySqlCommand("UPDATE `cq_flowers` SET `redroses` = " + F.RedRoses + ", `redrosestoday` = " + F.RedRoses2day + ",`lilies` = " + F.Lilies + ",`liliestoday` = " + F.Lilies2day + ",`redrosestoday` = " + F.Tulips + ",`redrosestoday` = " + F.Tulips2day + ",`orchads` = " + F.Orchads + ",`orchadstoday` = " + F.Orchads2day + ", WHERE `charuid2` = \"" + Name + "\"", Conn);
Cmd.ExecuteNonQuery();
}
else
{
MySqlCommand Cmd = new MySqlCommand("INSERT INTO `cq_flowers` (redroses, redrosestoday, lilies, liliestoday, tulips, tulipstoday, orchads, orchadstoday, charuid, charuid2) VALUES (" + F.RedRoses + "," + F.RedRoses2day + "," + F.Lilies + "," + F.Lilies2day + "," + F.Tulips + "," + F.Tulips2day + "," + F.Orchads + "," + F.Orchads2day + "," + C.EntityID + ",'" + Name + "')", Conn);
Cmd.ExecuteNonQuery();
}
}
lock (Conn)
{
string Save = DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day;
MySqlCommand Cmd = new MySqlCommand("UPDATE `cq_saves` SET `save_flower` = " + Save + " WHERE `type` = 0", Conn);
Cmd.ExecuteNonQuery();
}
Conn.Close();
}
catch (Exception ex) { Console.WriteLine(ex.ToString()); Conn.Close(); return; }
}
any problem post here : D
EDIT: Mostly Complete... thanks for waiting in advance....
for save go to this topic:  CREDITS FOR saving flowers at flatfile source to : walmartboi
and For the ppl who think that has an error at the codes... just add this at the vcery top of PacketHandling.cs:
Code:
using NewestCOServer.Game;
cya
|
|
|
02/20/2010, 14:57
|
#2
|
elite*gold: 0
Join Date: Feb 2009
Posts: 262
Received Thanks: 161
|
Exemple FlowerSend
case 1150:
{
string ID = "";
for (byte x = 18; x < 25; x++)
{
ID += Convert.ToChar(Data[x]).ToString();
}
uint TargetID = uint.Parse(ID);
Character TC = (Character)Game.World.H_Chars[TargetID];
GC.LocalMessage(2005, "Sending flowers to " + TargetID.ToString() + ", wait for the answer.");
Game.Character Who = (Game.Character)World.H_Chars[TargetID];
// if (Game.World.H_Chars.Contains(TargetID))
{
string sendat = Who.Name;
GC.LocalMessage(2005, "Sending flower to " + sendat + ".");
Who.EntityID = TargetID;
//GC.AddSend(Packets.SendFlowerScreen(GC.MyChar.Enti tyID));
Who.MyClient.LocalMessage(2005, "You haven`t received any flowers today. Find someone to send you flowers!");
Who.MyClient.AddSend(Packets.GeneralData(GC.MyChar .EntityID, 0x4e0, 0, 0, 0x74));
// Who.MyClient.AddSend(Packets.ReceiveFlower(TC.Enti tyID, 0, 0, 0).Get);
}
for (byte i = 0; i < 12; i++)
Console.WriteLine(Data[i].ToString());
break;
}
|
|
|
02/20/2010, 15:01
|
#3
|
elite*gold: 0
Join Date: Apr 2009
Posts: 782
Received Thanks: 458
|
Who.MyClient.AddSend(Packets.GeneralData(GC.MyChar .EntityID, 0x4e0, 0, 0, 0x74));
this make it send just sended 0 and a window.... i already tryied what did u post but doesn't seens to work.... : /
|
|
|
02/20/2010, 15:54
|
#4
|
elite*gold: 0
Join Date: Feb 2009
Posts: 700
Received Thanks: 79
|
there we go again "its not complete" bro not to flame but at least finish it before releasing :P good job though. +k
|
|
|
02/20/2010, 15:55
|
#5
|
elite*gold: 0
Join Date: Feb 2010
Posts: 480
Received Thanks: 207
|
You shouldn't release something that is not complete!
|
|
|
02/20/2010, 16:05
|
#6
|
elite*gold: 0
Join Date: Apr 2008
Posts: 275
Received Thanks: 43
|
lol look what in the beggining of the thread, he needs help to finish this code.
|
|
|
02/20/2010, 16:32
|
#7
|
elite*gold: 0
Join Date: May 2009
Posts: 884
Received Thanks: 211
|
maybe felipeboladao's code might work? not tested and not sure tho..
Code:
public static COPacket Flower2(uint Id, uint Type, uint Rank, uint RoseType)
{
string Flowers = Id.ToString();
byte[] Packet = new byte[1151 + 21 + Flowers.Length];
COPacket P = new COPacket(Packet);
P.WriteInt32(Type);
P.WriteInt32(Rank);
P.WriteInt32(RoseType);
P.WriteInt32(1);
P.WriteString(Flowers);
P.WriteInt64(0);
return P;
}
public static COPacket FlowerPacket(string Flowers, bool CreateInstance)
{
byte[] Packet = new byte[1150 + 21 + Flowers.Length];
COPacket P = new COPacket(Packet);
if (CreateInstance)
{
P.WriteInt16(1);
P.WriteInt16(0);
P.WriteInt16(0);
P.WriteInt32(1);
P.WriteString(Flowers);
P.WriteInt16(0);
}
return P;
}
public static COPacket SendFlowerScreen(uint Id)
{
byte[] Packet = new byte[0x3f2 + 28];
COPacket P = new COPacket(Packet);
P.WriteInt64(0);
P.WriteInt32(Id);
P.WriteInt16((ushort)0x4e0);
P.WriteInt16(0);
P.WriteInt16(0);
P.WriteInt16(0);
P.WriteInt16(0);
P.WriteInt16(0x74);
P.WriteInt64(0);
return P;
}
case 1150:
{
uint TargetID = BitConverter.ToUInt32(Data, 4);
GC.LocalMessage(2005, "Sending flower to target " + TargetID + ".");
if (Game.World.H_Chars.Contains(TargetID))
{
Game.World.H_Chars.Contains(TargetID);
GC.AddSend(Packets.SendFlowerScreen(GC.MyChar.Enti tyID));
}
break;
}
case 1151:
{
Features.Struct.Flowers F = GC.MyChar.Flowers;
string ToSend = F.RedRoses.ToString() + " " + F.RedRoses2day.ToString() + " " + F.Lilies.ToString() + " " + F.Lilies2day.ToString() + " ";
ToSend += F.Orchads.ToString() + " " + F.Orchads2day.ToString() + " " + F.Tulips.ToString() + " " + F.Tulips2day.ToString();
GC.AddSend(Packets.FlowerPacket(ToSend, true));
break;
}
credits go to felipeboladao as this is not my code...I wanted to see if this can help somehow lol...
|
|
|
02/20/2010, 16:53
|
#8
|
elite*gold: 0
Join Date: Apr 2008
Posts: 275
Received Thanks: 43
|
Thanks for this, its very usefull in my server
|
|
|
02/20/2010, 17:20
|
#9
|
elite*gold: 0
Join Date: Apr 2009
Posts: 782
Received Thanks: 458
|
this code doesn't work... some packets are wrong and one of them just close the client : /
anyway thanks... if someone can help... post please : D
|
|
|
02/20/2010, 18:10
|
#10
|
elite*gold: 0
Join Date: Apr 2008
Posts: 1,152
Received Thanks: 321
|
Its A verry good start of, Good Job
|
|
|
02/20/2010, 18:51
|
#11
|
elite*gold: 0
Join Date: Oct 2009
Posts: 8,785
Received Thanks: 5,304
|
Quote:
Originally Posted by Decker_
You shouldn't release something that is not complete!
|
Look at it this way, maybe he didn't complete it but he released the partial code and someone else might be able to complete it. So your little statement is wrong.
|
|
|
02/20/2010, 19:49
|
#12
|
elite*gold: 0
Join Date: Apr 2009
Posts: 782
Received Thanks: 458
|
Arco... i'm working on it right now... but when i try to use the lilies , roses, orchilds or tulips.... it jump to the 1150 packet (like marry... it send a general packet... to get the item id or something like it...) i need only to get the item id at 1150 packet.. if i do.... the packet will be mostly complete.... can you help me?
cya!
|
|
|
02/20/2010, 20:08
|
#13
|
elite*gold: 0
Join Date: Oct 2009
Posts: 8,785
Received Thanks: 5,304
|
Quote:
Originally Posted by 12tails
Arco... i'm working on it right now... but when i try to use the lilies , roses, orchilds or tulips.... it jump to the 1150 packet (like marry... it send a general packet... to get the item id or something like it...) i need only to get the item id at 1150 packet.. if i do.... the packet will be mostly complete.... can you help me?
cya!
|
Add me on msn,
|
|
|
02/20/2010, 20:38
|
#14
|
elite*gold: 0
Join Date: Feb 2010
Posts: 480
Received Thanks: 207
|
Quote:
Originally Posted by .Arco
Look at it this way, maybe he didn't complete it but he released the partial code and someone else might be able to complete it. So your little statement is wrong.
|
Not necessarily.
Everyone has there own opinions and my opinion is people shoudn't release stuff that is not completed.
I'm sure people would agree with me.
Off-topic:
Do you have a code that you can release that PM/GM's can drop things and people can see it?
|
|
|
02/20/2010, 20:45
|
#15
|
elite*gold: 0
Join Date: Apr 2009
Posts: 782
Received Thanks: 458
|
well... i released it and asked for help... also many ppl here relase never ending things -.-''
i just want help to over it.. then i'll release it full : X
|
|
|
 |
|
Similar Threads
|
[Release] 5165 Warehouses Auth System
04/01/2011 - CO2 PServer Guides & Releases - 18 Replies
this is just a simple Auth system for warehouses. It will ask for password (set from WHGuardian) each time players will open their warehouse. Attempt limit is not included in this release... btw; with this release, warehouseGuardian will now save the password in Character file.
here are the screenshots:
http://img408.imageshack.us/img408/6986/98867182. jpg
Click The Image to see more screen shots
1. Go to NPCDialog.cs and search for this code:
public static void...
|
[RELEASE]Anti bot system 5165
06/15/2010 - CO2 PServer Guides & Releases - 15 Replies
Here is an simple anti bot system.
Credits goes to Arco for the npc send thing :)
First go to MyThreads.cs and find:
interval = Interval;
T = new Thread(new ThreadStart(Run));
T.Start();
|
[Release]NPC system 5165 simplified
05/10/2010 - CO2 PServer Guides & Releases - 14 Replies
//
|
some1 have 5165 source with flower system please post download link here
01/31/2010 - CO2 Private Server - 7 Replies
some1 have 5165 source with flower system please post download link here:(
|
All times are GMT +1. The time now is 23:06.
|
|