Trying to fix .cs

For any problems with Dawn of Light website or game server, please direct questions and problems here.

Moderator: Support Team

Trying to fix .cs

Postby Lyrn » Fri Aug 14, 2015 4:28 pm

Account vault keeper bugs anyone? It wasn't recognizing DBCharacter at first, so trying to direct it to GamePlayer didn't help either... http://prntscr.com/84lsj0 Any help appreciated ty in advance
Lyrn
DOL Acolyte
 
Posts: 103
Joined: Thu Oct 27, 2011 3:15 pm

Re: Trying to fix .cs

Postby Leodagan » Fri Aug 14, 2015 4:47 pm

This looks like a Custom Script, please provide the full source you're using (either in attachment file, or copy/pasted into [ code] [ /code])
User avatar
Leodagan
Developer
 
Posts: 1350
Joined: Tue May 01, 2012 9:30 am
Website: https://daoc.freyad.net
Location: Lyon

Re: Trying to fix .cs

Postby Lyrn » Fri Aug 14, 2015 5:53 pm

It's the account vault keeper guy. I'm having a lot of problems with the new revision. I'm missing database tables that idk where to find either. (classxspecialization / specialization / specxability / spell / spellline / style / stylexspell / race) I trust that is why I also cannot use a master trainer.
Code: Select all
/* * Account Vault Keeper - Kakuri Mar 20 2009 * A fake GameHouseVault that works as an account vault. * The methods and properties of GameHouseVault *must* be marked as virtual for this to work (which was not the case in DOL builds prior to 1584). * */ using System; using System.Collections; using System.Collections.Generic; using System.Reflection; using log4net; using DOL.Database; using DOL.GS.Housing; using DOL.GS.PacketHandler; namespace DOL.GS { public class AccountVaultKeeper : GameNPC { private static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public override bool Interact(GamePlayer player) { if (!base.Interact(player)) return false; string message = "Welcome! This vault is accessible by all characters on your account."; player.Out.SendMessage(message, eChatType.CT_Say, eChatLoc.CL_PopupWindow); ItemTemplate vaultItem = GetDummyVaultItem(player); AccountVault vault = new AccountVault(player, this, player.Client.Account.Name, 0, vaultItem); player.ActiveInventoryObject = vault; //player.ActiveVault = vault; player.Out.SendInventoryItemsUpdate(vault.GetClientInventory(player), eInventoryWindowType.HouseVault); return true; } public override bool WhisperReceive(GameLiving source, string text) { if (!base.WhisperReceive(source, text)) return false; GamePlayer player = source as GamePlayer; if (player == null) return false; return true; } private static ItemTemplate GetDummyVaultItem(GamePlayer player) { ItemTemplate vaultItem = new ItemTemplate(); vaultItem.Object_Type = (int)eObjectType.HouseVault; vaultItem.Id_nb = "alb_vault"; vaultItem.Name = "Albion Vault"; vaultItem.Model = 1489; switch (player.Realm) { /*case eRealm.Albion: vaultItem.Id_nb = "alb_vault"; vaultItem.Name = "Albion Vault"; vaultItem.Model = 1489; break;*/ case eRealm.Hibernia: vaultItem.Id_nb = "hib_vault"; vaultItem.Name = "Hibernia Vault"; vaultItem.Model = 1491; break; case eRealm.Midgard: vaultItem.Id_nb = "mid_vault"; vaultItem.Name = "Midgard Vault"; vaultItem.Model = 1493; break; } return vaultItem; } } public class AccountVault : GameHouseVault { public const int SIZE = 100; public const int FIRST_SLOT = 1600; private static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private GamePlayer m_player; private GameNPC m_vaultNPC; private string m_vaultOwner; private int m_vaultNumber = 0; private object m_vaultSync = new object(); /// <summary> /// An account vault that masquerades as a house vault to the game client /// </summary> /// <param name="player">Player who owns the vault</param> /// <param name="vaultNPC">NPC controlling the interaction between player and vault</param> /// <param name="vaultOwner">ID of vault owner (can be anything unique, if it's the account name then all toons on account can access the items)</param> /// <param name="vaultNumber">Valid vault IDs are 0-3</param> /// <param name="dummyTemplate">An ItemTemplate to satisfy the base class's constructor</param> public AccountVault(GamePlayer player, GameNPC vaultNPC, string vaultOwner, int vaultNumber, ItemTemplate dummyTemplate) : base(dummyTemplate, vaultNumber) { m_player = player; m_vaultNPC = vaultNPC; m_vaultOwner = vaultOwner; m_vaultNumber = vaultNumber; DBHouse dbh = new DBHouse(); //was allowsave = false but uhh i replaced with allowadd = false dbh.AllowAdd = false; dbh.GuildHouse = false; dbh.HouseNumber = player.ObjectID; dbh.Name = player.Name + "'s House"; dbh.OwnerID = player.GamePlayer.ObjectId; dbh.RegionID = player.CurrentRegionID; CurrentHouse = new House(dbh); } public override bool CanAddItems(GamePlayer player) { return CurrentHouse.Name == player.Name + "'s House"; } public override bool CanRemoveItems(GamePlayer player) { return CurrentHouse.Name == player.Name + "'s House"; } private IList<InventoryItem> GetItems() { string sqlQuery = "OwnerID = '" + m_vaultOwner + "' AND "; sqlQuery += "SlotPosition >= " + FirstDBSlot + " AND "; sqlQuery += "SlotPosition <= " + LastDBSlot; return (GameServer.Database.SelectObjects<InventoryItem>(sqlQuery)); } public override string GetOwner(GamePlayer player) { return player.Client.Account.Name; } protected override void NotifyObservers(GamePlayer player, IDictionary<int, InventoryItem> updateItems) { if (!player.IsWithinRadius(m_vaultNPC, WorldMgr.INTERACT_DISTANCE)) { player.Out.SendMessage("You are out of range of the vault keeper.", eChatType.CT_System, eChatLoc.CL_SystemWindow); player.ActiveInventoryObject = null; } player.Out.SendInventoryItemsUpdate(GetClientInventory(player), eInventoryWindowType.HouseVault); } public string VaultOwner { get { return m_vaultOwner; } set { m_vaultOwner = value; } } } }
Lyrn
DOL Acolyte
 
Posts: 103
Joined: Thu Oct 27, 2011 3:15 pm

Re: Trying to fix .cs

Postby Marko » Sun Jan 03, 2016 4:27 pm

Did you ever figure this out? I'm using these same scripts to create guild & account vaults, but they don't work with newer builds - I think due to changes in how housing is implemented - since these are just variations on house vaults... Which may be the warning there at the top of the file that those methods need to be virtual, but I'm not sure how to ensure that.

Let us know if you found a fix, for now I just rolled back to an older build to keep it working :(
User avatar
Marko
DOL Novice
 
Posts: 80
Joined: Mon Jun 09, 2014 8:17 pm
Location: Rural Central Utah (Near Bryce Canyon)

Re: Trying to fix .cs

Postby Marko » Tue Jan 12, 2016 6:51 pm

Well I found the problem. It is in the build http://www.dolserver.net/viewtopic.php? ... er#p155863 which restricts access to DOL.GS.GamePlayer, & upon which the DBCharacter call is dependent. This breaks both the AccountVault and the GuildVault scripts. Apparently there IS a way to fix this by using some kind of updated accessors, but no example is given, so I'm not sure what the fix would be...
User avatar
Marko
DOL Novice
 
Posts: 80
Joined: Mon Jun 09, 2014 8:17 pm
Location: Rural Central Utah (Near Bryce Canyon)

Re: Trying to fix .cs

Postby Graveen » Sat Jan 16, 2016 9:15 am

ok, it's noticed.
Image
* pm me to contribute in Dawn of Light: code, database *
User avatar
Graveen
Project Leader
 
Posts: 12660
Joined: Fri Oct 19, 2007 9:22 pm
Location: France

Re: Trying to fix .cs

Postby Leodagan » Sun Jan 17, 2016 10:29 am

In the "AccountVault" Line 124 :
Code: Select all
dbh.OwnerID = player.GamePlayer.ObjectId;
What is this meaning ?

I never saw a "GamePlayer" Property on a "GamePlayer" object...

Did you try to modify this yourself ?

If this was :
Code: Select all
dbh.OwnerID = player.DBCharacter.ObjectId;
you can update it to
Code: Select all
dbh.OwnerID = player.ObjectId;
User avatar
Leodagan
Developer
 
Posts: 1350
Joined: Tue May 01, 2012 9:30 am
Website: https://daoc.freyad.net
Location: Lyon

Re: Trying to fix .cs

Postby Marko » Fri Jan 22, 2016 7:17 pm

So I just checked my code (which is unaltered from the original User Resources code) and it was set up as you listed. I made the change you suggested - And badda-bing! My vaults are working again! You're Awesome! Thanks for your help!
User avatar
Marko
DOL Novice
 
Posts: 80
Joined: Mon Jun 09, 2014 8:17 pm
Location: Rural Central Utah (Near Bryce Canyon)


Return to “%s” Support

Who is online

Users browsing this forum: No registered users and 1 guest