Register for your free account! | Forgot your password?

You last visited: Today at 17:58

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

Advertisement



can you help me

Discussion on can you help me within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
marlyandedsel's Avatar
 
elite*gold: 0
Join Date: Aug 2010
Posts: 343
Received Thanks: 21
can you help me

I have my confiscator.cs file but i got error everytime i redeem some items
heres the code. red color is the error. can you help me

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConquerSx.PacketHandling
{

public class Confiscator
{
public static int CpsItem(Game.Item I)
{
return I.Plus * 300;
}
public static void ClainItem(Main.GameClient GC, byte[] Data)
{
string P = ""; string Phex = "";
for (byte bit = 0; bit < Data.Length - 8; bit++)
{
int Pi = Data[bit];
P += Data[bit] + " ";
Phex += Pi.ToString("X") + " ";
}
//Console.WriteLine("packet: {0} ", P);


uint Uid = BitConverter.ToUInt32(Data, 4);
uint NPC1 = BitConverter.ToUInt32(Data, 6);
uint NPC = BitConverter.ToUInt32(Data, 12);
//Console.WriteLine("Npc {0} ID {1}", NPC, Uid);

if (NPC == 33)
{
GC.SendPacket(Packets.ItemPacket(Uid, 100, 33));
// return;
foreach (Game.Character C in Game.World.H_Chars.Values)
{

if (C.EntityID == GC.MyChar.EntityID)
{
foreach (Game.Item I in GC.MyChar.ConfiscatorClain.Values)
{
if (I.Position == 1)
{
GC.MyChar.CPs += (uint)PacketHandling.Confiscator.CpsItem(I);
GC.MyChar.ConfiscatorClain.Remove(I.UID);
Database.DeleteClain(I.UID, GC.MyChar);
}
}
}
else
{
foreach (KeyValuePair<uint, Game.Item> Item in GC.MyChar.ConfiscatorClain)
{
Game.Item I = Item.Value;
// Console.WriteLine("Npc {0} ID {1}", I.UID, Uid);
if (I.UID == Uid)
{
Console.WriteLine(I.NameReward);
if (I.NameClain == C.Name)
{
Console.WriteLine(C.Name);
if (I.Time == 0)
{
// foreach (Game.Item I in GC.MyChar.ConfiscatorClain.Values)

C.ConfiscatorReward.Remove(I.UID);
Database.DeleteReward(I.UID, C);
GC.MyChar.ConfiscatorClain.Remove(I.UID);
Database.DeleteClain(I.UID, GC.MyChar);
GC.SendPacket(Packets.ItemPacket(Uid, 1, 33));
C.MyClient.SendPacket(Packets.ItemPacket(Uid, 2, 32));
GC.MyChar.AddFullItem(I.ID, I.Bless, I.Plus, I.Enchant
, I.Soc1, I.Soc2, I.Color, I.Progress, I.TalismanProgress
, I.Effect, I.FreeItem, I.CurDur, I.MaxDur, I.Suspicious
, I.Locked, I.LockedDays, I.RBG[0], I.RBG[1], I.RBG[2], I.RBG[3]);
GC.SendPacket2(Data);
C.MyClient.SendPacket2(Data);
}
}
}
}
}
}
}
}
public static void RewardItem(Main.GameClient GC, byte[] Data)
{
string P = ""; string Phex = "";
for (byte bit = 0; bit < Data.Length - 8; bit++)
{
int Pi = Data[bit];
P += Data[bit] + " ";
Phex += Pi.ToString("X") + " ";
}
//Console.WriteLine("packet: {0} ", P);

uint Uid = BitConverter.ToUInt32(Data, 4);
uint NPC = BitConverter.ToUInt32(Data, 12);
//Console.WriteLine("Npc {0} ID {1}", NPC, Uid);
if (Data[12] == 32)
{
foreach (Game.Character C in Game.World.H_Chars)
{
if (C.EntityID != GC.MyChar.EntityID)
{
foreach (Game.Item Item in C.ConfiscatorClain.Values)
{
if (Item.UID == Uid)
{
if (Item.NameClain == C.Name)
{
if (Item.Time <= 7)
{
if (GC.MyChar.CPs >= (uint)PacketHandling.Confiscator.CpsItem(Item))
{

GC.MyChar.CPs -= (uint)PacketHandling.Confiscator.CpsItem(Item);
GC.MyChar.ConfiscatorReward.Remove(Item.UID);
Database.DeleteReward(Item.UID, GC.MyChar);
C.ConfiscatorClain.Remove(Item.UID);
Database.UpSac(Item.UID, C);
GC.SendPacket(Packets.ItemPacket(Uid, 2, 32));
C.MyClient.SendPacket(Packets.ItemPacket(Uid, 1, 32));
Item.Position = 1;
C.MyClient.SendPacket(Packets.Sac(Item, C, (ushort)PacketHandling.Confiscator.CpsItem(Item), GC.MyChar.Name));
C.ConfiscatorClain.Add(Item.UID, Item);
//Congratulation %s has detaine the items whit %d for player% s.
GC.LocalMessage(2000, System.Drawing.Color.Red, "Congratulation " + GC.MyChar.Name + " has detain the items " + Item.DBInfo.ID + " with " + (ushort)PacketHandling.Confiscator.CpsItem(Item) + " for player " + C.Name + " ");
}
else
GC.LocalMessage(2005, System.Drawing.Color.Red, "Sorry, you need " + (ushort)PacketHandling.Confiscator.CpsItem(Item) + " Cps to clain");
}
}
}
}
}
}//
}
}
}
}
marlyandedsel is offline  
Old 12/27/2010, 12:57   #2


 
Korvacs's Avatar
 
elite*gold: 20
Join Date: Mar 2006
Posts: 6,126
Received Thanks: 2,518
Whats the error?
Korvacs is offline  
Old 12/27/2010, 17:52   #3
 
marlyandedsel's Avatar
 
elite*gold: 0
Join Date: Aug 2010
Posts: 343
Received Thanks: 21
Hello here is the error

Quote:
Originally Posted by Korvacs View Post
Whats the error?
Hi, here is the error hope you can help me and thanks.

System.InvalidCastException: Unable to cast object of type 'System.Collections.DictionaryEntry' to type 'conquersx.Game.Character'.
at conquersx.PacketHandling.Confiscator.RewardItem(Ga meClient GC, Byte[] Data) in K:\source conquersx\conquersxv8\Conquer-Sx\PacketHandling\Confiscator.cs:line 103
at conquersx.PacketHandler.Handle(GameClient GC, Byte[] Data) in K:\source conquersx\conquersxv8\Conquer-Sx\PacketHandler.cs:line 946
System.InvalidCastException: Unable to cast object of type 'System.Collections.DictionaryEntry' to type 'conquersx.Game.Character'.
at conquersx.PacketHandling.Confiscator.RewardItem(Ga meClient GC, Byte[] Data) in K:\source conquersx\conquersxv8\Conquer-Sx\PacketHandling\Confiscator.cs:line 103
at conquersx.PacketHandler.Handle(GameClient GC, Byte[] Data) in K:\source conquersx\conquersxv8\Conquer-Sx\PacketHandler.cs:line 946
System.InvalidCastException: Unable to cast object of type 'System.Collections.DictionaryEntry' to type 'conquersx.Game.Character'.
at conquersx.PacketHandling.Confiscator.RewardItem(Ga meClient GC, Byte[] Data) in K:\source conquersx\conquersxv8\Conquer-Sx\PacketHandling\Confiscator.cs:line 103
at conquersx.PacketHandler.Handle(GameClient GC, Byte[] Data) in K:\source conquersx\conquersxv8\Conquer-Sx\PacketHandler.cs:line 946
marlyandedsel is offline  
Old 12/27/2010, 17:59   #4
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,380
Quote:
Originally Posted by marlyandedsel View Post
Hi, here is the error hope you can help me and thanks.

System.InvalidCastException: Unable to cast object of type 'System.Collections.DictionaryEntry' to type 'conquersx.Game.Character'.
at conquersx.PacketHandling.Confiscator.RewardItem(Ga meClient GC, Byte[] Data) in K:\source conquersx\conquersxv8\Conquer-Sx\PacketHandling\Confiscator.cs:line 103
at conquersx.PacketHandler.Handle(GameClient GC, Byte[] Data) in K:\source conquersx\conquersxv8\Conquer-Sx\PacketHandler.cs:line 946
System.InvalidCastException: Unable to cast object of type 'System.Collections.DictionaryEntry' to type 'conquersx.Game.Character'.
at conquersx.PacketHandling.Confiscator.RewardItem(Ga meClient GC, Byte[] Data) in K:\source conquersx\conquersxv8\Conquer-Sx\PacketHandling\Confiscator.cs:line 103
at conquersx.PacketHandler.Handle(GameClient GC, Byte[] Data) in K:\source conquersx\conquersxv8\Conquer-Sx\PacketHandler.cs:line 946
System.InvalidCastException: Unable to cast object of type 'System.Collections.DictionaryEntry' to type 'conquersx.Game.Character'.
at conquersx.PacketHandling.Confiscator.RewardItem(Ga meClient GC, Byte[] Data) in K:\source conquersx\conquersxv8\Conquer-Sx\PacketHandling\Confiscator.cs:line 103
at conquersx.PacketHandler.Handle(GameClient GC, Byte[] Data) in K:\source conquersx\conquersxv8\Conquer-Sx\PacketHandler.cs:line 946
Ok well you're trying to iterate through a dictionary... which is a key value pair (key and value as one object..)

So all you need to do is put

.Values to iterate through the dictionary VALUES rather than the pair.

Alternatively if you wanted to iterate through the uids you could do the .Keys

I'd STRONGLY recommend reading through a basic introductory C# book.

As it happens I still have a link to a pdf version of C# for dummies. I was looking through the book earlier and, while, rather basic, it contains stuff that every coder on epvp who is trying to work with C# proxies/pservers SHOULD KNOW



This is not "high end" information but I guarentee if you read through all, or even most of this book and put into practice some of the materials then you will be in the top 5-10 percent of 'programmers' on epvp (a sad but true fact)
pro4never is offline  
Thanks
1 User
Reply




All times are GMT +1. The time now is 17:59.


Powered by vBulletin®
Copyright ©2000 - 2026, 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 ©2026 elitepvpers All Rights Reserved.