I'm using the 4267 CoFuture source and am trying to code some simple commands. I made this command to distribute dexterity attributes but when i try it, the console gives an error saying the index was outside the bounds od the array.
I'm using the 4267 CoFuture source and am trying to code some simple commands. I made this command to distribute dexterity attributes but when i try it, the console gives an error saying the index was outside the bounds od the array.
Yah, always remember that [0] is the initial command, they don't start with 1.
It's even more fun when you're selecting ranges of stuff and trying to figure out why it's not grabbing the right data... then you realize you were counting them up wrong :P
#region Met/Db Storage case 47://input test npc (prize npc)
{ if (LinkBack == 0) { Text("I can help you store your excess mets and dbs!", Client); Text("What would you like to do today?", Client); Link("Mets", 1, Client); Link("Dbs", 2, Client); Link("Check balance", 11, Client); Link("Nevermind...", 255, Client); Face(91, Client); End(Client); }
if (LinkBack == 1)//Mets { Text("Are you wanting to put mets in or withdraw?", Client); Text("Met balance - " + Client.Char.MetPoint, Client); Link("Withdraw", 3, Client); Link("Deposit", 4, Client); Link("Nevermind...", 255, Client); Face(91, Client); End(Client); }
if (LinkBack == 2)//Dbs { Text("Are you wanting to put dragonballs in or withdraw?", Client); Text("DragonBall balance - " + Client.Char.DbPoint, Client); Link("Withdraw", 5, Client); Link("Deposit", 6, Client); Link("Nevermind...", 255, Client); Face(91, Client); End(Client); } if (LinkBack == 11) { Text("Met balance - " + Client.Char.MetPoint, Client); Text("DragonBall balance - " + Client.Char.DbPoint, Client); Link("Main menu", 0, Client); Link("Thanks", 255, Client); Face(91, Client); End(Client); } if (LinkBack == 3) { Text("How many mets are you withdrawing today?", Client); Input(" ", 7, Client); Link("Nevermind...", 255, Client); Face(91, Client); End(Client); } if (LinkBack == 4) { Text("How many mets are you depositing today?", Client); Input(" ", 8, Client); Link("Nevermind...", 255, Client); Face(91, Client); End(Client); } if (LinkBack == 5) { Text("How many dragonballs are you withdrawing today?", Client); Input(" ", 9, Client); Link("Nevermind...", 255, Client); Face(91, Client); End(Client); } if (LinkBack == 6) { Text("How many dragonballs are you depositing today?", Client); Input(" ", 10, Client); Link("Nevermind...", 255, Client); Face(91, Client); End(Client); } else if (LinkBack == 7)//withdraw mets { string Mets = ""; for (int i = 14; i < 14 + Data[13]; i++) { Mets += Convert.ToChar(Data[i]); } Console.WriteLine("NameGiven = " + Mets); int MetsInt = 0; try { MetsInt = int.Parse(Mets); Console.WriteLine("Int = " + MetsInt); } catch { Text("You did not enter a number!", Client); Link("Oops, my bad!", 255, Client); Face(91, Client); End(Client); Console.WriteLine("Error: Could not convert to int!"); } if (Client.Char.MetPoint >= MetsInt) { if ((Client.Char.Inventory.Count + MetsInt) <= 40) { int Quantity = MetsInt; while (Quantity > 0) { AddItem(1088001, 255, 0, 0, 0, 0, Client); Quantity -= 1; } Client.Char.MetPoint -= MetsInt; Database.SaveMetPoint(Client.Char); Text("You have " + Client.Char.MetPoint + " MetPoints left", Client); Link("Main Menu", 0, Client); Link("Wow, thanks alot!", 255, Client); Face(91, Client); End(Client);
} else { Text("You do not have enough room in your inventory", Client); Link("Oops, my bad", 255, Client); Face(91, Client); End(Client); } } else { Text("You do not have that many MetPoints!", Client); Link("Oops, my bad", 255, Client); Face(91, Client); End(Client); }
} else if (LinkBack == 8)//deposit mets { string Mets = ""; for (int i = 14; i < 14 + Data[13]; i++) { Mets += Convert.ToChar(Data[i]); } Console.WriteLine("NameGiven = " + Mets); int MetsInt = 0; try { MetsInt = int.Parse(Mets); Console.WriteLine("Int = " + MetsInt); } catch { Text("You did not enter a number!", Client); Link("Oops, my bad!", 255, Client); Face(91, Client); End(Client); Console.WriteLine("Error: Could not convert to int!"); } if (InventoryContains(1088001, Client, MetsInt)) { RemoveItem(1088001, Client, MetsInt); Client.Char.MetPoint += MetsInt; Database.SaveMetPoint(Client.Char); Text("You now have " + Client.Char.MetPoint + " MetPoints!", Client); Link("Main Menu", 0, Client); Link("Wow, thanks alot!", 255, Client); Face(91, Client); End(Client);
} else { Text("You do not have that many mets in your inventory!", Client); Link("Oops, my bad", 255, Client); Face(91, Client); End(Client); }
} else if (LinkBack == 9)//withdraw Dbs { string Dbs = ""; for (int i = 14; i < 14 + Data[13]; i++) { Dbs += Convert.ToChar(Data[i]); } Console.WriteLine("NameGiven = " + Dbs); int DbsInt = 0; try { DbsInt = int.Parse(Dbs); Console.WriteLine("Int = " + DbsInt); } catch { Text("You did not enter a number!", Client); Link("Oops, my bad!", 255, Client); Face(91, Client); End(Client); Console.WriteLine("Error: Could not convert to int!"); } if (Client.Char.DbPoint >= DbsInt) { if ((Client.Char.Inventory.Count + DbsInt) <= 40) { int Quantity = DbsInt; while (Quantity > 0) { AddItem(1088000, 255, 0, 0, 0, 0, Client); Quantity -= 1; } Client.Char.DbPoint -= DbsInt; Database.SaveDbPoint(Client.Char); Text("You have " + Client.Char.DbPoint + " DbPoints left", Client); Link("Main Menu", 0, Client); Link("Wow, thanks alot!", 255, Client); Face(91, Client); End(Client);
} else { Text("You do not have enough room in your inventory.", Client); Link("Oops, my bad", 255, Client); Face(91, Client); End(Client); } } else { Text("You do not have that many DbPoints!", Client); Link("Oops, my bad", 255, Client); Face(91, Client); End(Client); }
} else if (LinkBack == 10)//deposit Dbs { string Dbs = ""; for (int i = 14; i < 14 + Data[13]; i++) { Dbs += Convert.ToChar(Data[i]); } Console.WriteLine("NameGiven = " + Dbs); int DbsInt = 0; try { DbsInt = int.Parse(Dbs); Console.WriteLine("Int = " + DbsInt); } catch { Text("You did not enter a number!", Client); Link("Oops, my bad!", 255, Client); Face(91, Client); End(Client); Console.WriteLine("Error: Could not convert to int!"); } if (InventoryContains(1088000, Client, DbsInt)) { RemoveItem(1088000, Client, DbsInt); Client.Char.DbPoint += DbsInt; Database.SaveDbPoint(Client.Char); Text("You now have " + Client.Char.DbPoint + " DbPoints!", Client); Link("Main Menu", 0, Client); Link("Wow, thanks alot!", 255, Client); Face(91, Client); End(Client);
} else { Text("You do not have that many DragonBalls in your inventory!", Client); Link("Oops, my bad", 255, Client); Face(91, Client); End(Client); }
} break; }
#endregion
database voids
PHP Code:
public static void SaveMetPoint(Character Char) { lock (DatabaseConnection) { MySqlCommand Comm = new MySqlCommand("UPDATE `characters` SET `MetPoint` = " + Char.MetPoint + " WHERE `CharID` = " + Char.ID + "", DatabaseConnection);
}
} public static void SaveDbPoint(Character Char) { lock (DatabaseConnection) { MySqlCommand Comm = new MySqlCommand("UPDATE `characters` SET `DbPoint` = " + Char.DbPoint + " WHERE `CharID` = " + Char.ID + "", DatabaseConnection);
}
}
Not sure if you need these but w/e
here's the voids, most should be in source already though
public static bool RemoveItem(int ItemID, COClient Client, int Amount) { List<Struct.ItemInfo> RemoveList = new List<Struct.ItemInfo>(Amount); int Count = 0; foreach (Struct.ItemInfo Item in Client.Char.Inventory.Values) if (Item.ItemID == ItemID) { if (Count < Amount) { Database.DeleteItem(Item.UID); RemoveList.Add(Item); Client.SendData(ConquerPacket.ItemUsage(Item.UID, 0, Struct.ItemUsage.RemoveItem)); Count++; } else break; } foreach (Struct.ItemInfo Item in RemoveList) Client.Char.Inventory.Remove(Item.UID); return false; }
public static bool InventoryContains(int ItemID, COClient Client, int Amount) { int got = 0; foreach (Struct.ItemInfo Item in Client.Char.Inventory.Values) if (Item.ItemID == ItemID) got++; if (got >= Amount) return true; if (ItemID == 1088000) ErrorMsg("I cant do it, I still need " + (Amount - got) + " dragonballs.", Client); if (ItemID == 1088001) ErrorMsg("I cant do it, I still need " + (Amount - got) + " meteors.", Client); return false; }
You might wanna remove some of the console.writeline's. I had them in there when I was first writing it for debug purposes... it's kinda a messy release but it should work.
[REQUEST] What is the command on binary to make attributes 900? 10/05/2009 - CO2 Private Server - 1 Replies I need the command that will make my attributes 900. I tried /vit 900 and different commands but they don't work. I did the /superman command too many times and I need to get them back to 900 without editing the DB. Help me please.
/GM DISTRIBUTE aint working ? 05/11/2009 - Dekaron Private Server - 5 Replies I tryed to use the code, but nothing happens,
ive tryed to clone a item in the DB but then i cant login -> 400,100
Anyone know fic for this ?
Thx
how to distribute those point for fire 05/18/2007 - Conquer Online 2 - 1 Replies hi everyone. i really nid u all help me out..
i juz rb from water to fire.. i dunno how to distribute my point..
can anyone teach me? ty so much