Save back to Database[SOLVED]

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

Moderator: Support Team

Save back to Database[SOLVED]

Postby Loki » Mon Dec 12, 2016 11:08 pm

Code: Select all
var inv = GameServer.Database.SelectObjects<InventoryItem>("OwnerID = '" + playerac.ObjectId + "'");

I have my players OwnerID from Inventory, how do I without interacting save an item to the Inventory table
Code: Select all
INSERT INTO `thid_24`.`inventory` (`OwnerID`, `OwnerLot`, `ITemplate_Id`, `UTemplate_Id`, `IsCrafted`, `Creator`, `SlotPosition`, `Count`, `SellPrice`, `Experience`, `Color`, `Emblem`, `Extension`, `Condition`, `Durability`, `PoisonSpellID`, `PoisonMaxCharges`, `PoisonCharges`, `Charges`, `Charges1`, `Cooldown`, `LastTimeRowUpdated`, `Inventory_ID`) VALUES (<{OwnerID: }>, <{OwnerLot: }>, <{ITemplate_Id: }>, <{UTemplate_Id: }>, <{IsCrafted: }>, <{Creator: }>, <{SlotPosition: }>, <{Count: }>, <{SellPrice: }>, <{Experience: }>, <{Color: }>, <{Emblem: }>, <{Extension: }>, <{Condition: }>, <{Durability: }>, <{PoisonSpellID: }>, <{PoisonMaxCharges: }>, <{PoisonCharges: }>, <{Charges: }>, <{Charges1: }>, <{Cooldown: }>, <{LastTimeRowUpdated: 2000-01-01 00:00:00}>, <{Inventory_ID: }>);
Code: Select all
var item = GameServer.Database.FindObjectByKey<ItemTemplate>(Magma_Imbued_Cloak); var y = GameServer.Database.AddObject(item);
It has to save the said item to the ownerID I have from above. Can I get a hint please

Thank you
Last edited by Loki on Tue Dec 13, 2016 2:46 pm, edited 1 time in total.
“ If debugging is the process of removing software bugs, then programming must be the process of putting them in. ”

Join https://discord.gg/r3T2U7S Official DOL Discord Chat
User avatar
Loki
Developer
 
Posts: 468
Joined: Fri Jun 23, 2006 2:14 am
Location: uk

Re: Save back to Database

Postby Loki » Mon Dec 12, 2016 11:20 pm

Code: Select all
var item = GameServer.Database.FindObjectByKey<ItemTemplate>(Magma_Imbued_Cloak); client.Player.Inventory.AddItem(eInventorySlot.FirstEmptyBackpack, item);
How do I insert the cloak with said owner ID
Code: Select all
client.Player.Inventory.AddItem(eInventorySlot.FirstEmptyBackpack, item);
“ If debugging is the process of removing software bugs, then programming must be the process of putting them in. ”

Join https://discord.gg/r3T2U7S Official DOL Discord Chat
User avatar
Loki
Developer
 
Posts: 468
Joined: Fri Jun 23, 2006 2:14 am
Location: uk

Re: Save back to Database

Postby Loki » Tue Dec 13, 2016 12:13 pm

By not interacting with the player may I add.
“ If debugging is the process of removing software bugs, then programming must be the process of putting them in. ”

Join https://discord.gg/r3T2U7S Official DOL Discord Chat
User avatar
Loki
Developer
 
Posts: 468
Joined: Fri Jun 23, 2006 2:14 am
Location: uk

Re: Save back to Database

Postby Loki » Tue Dec 13, 2016 1:53 pm

Code: Select all
int sessionID = Convert.ToInt32(playerac.Name); clientc = WorldMgr.GetClientFromID(sessionID); InventoryItem generic0 = new InventoryItem(); ItemTemplate tgeneric0 = GameServer.Database.FindObjectByKey<ItemTemplate>("UpsilonWizardStaff"); generic0 = GameInventoryItem.Create<ItemTemplate>(tgeneric0); clientc.Player.Inventory.AddItem(eInventorySlot.FirstEmptyBackpack, generic0); clientc.Player.UpdatePlayerStatus();

I used a section from the jump command as no interaction is needed to jump player to me (not sure if this will work but), so given the above I get no errors but said character never gets the staff?

any ideas
“ If debugging is the process of removing software bugs, then programming must be the process of putting them in. ”

Join https://discord.gg/r3T2U7S Official DOL Discord Chat
User avatar
Loki
Developer
 
Posts: 468
Joined: Fri Jun 23, 2006 2:14 am
Location: uk

Re: Save back to Database

Postby Loki » Tue Dec 13, 2016 1:55 pm

hmmm my bad that staff not in my DB let me try with know item /slap
“ If debugging is the process of removing software bugs, then programming must be the process of putting them in. ”

Join https://discord.gg/r3T2U7S Official DOL Discord Chat
User avatar
Loki
Developer
 
Posts: 468
Joined: Fri Jun 23, 2006 2:14 am
Location: uk

Re: Save back to Database

Postby Loki » Tue Dec 13, 2016 2:01 pm

Ok no errors and with an item in my db still not given to player,

any help or tips ?
“ If debugging is the process of removing software bugs, then programming must be the process of putting them in. ”

Join https://discord.gg/r3T2U7S Official DOL Discord Chat
User avatar
Loki
Developer
 
Posts: 468
Joined: Fri Jun 23, 2006 2:14 am
Location: uk

Re: Save back to Database

Postby Loki » Tue Dec 13, 2016 2:04 pm

Code: Select all
clientc.Player.Inventory.AddItem(eInventorySlot.FirstEmptyBackpack, generic0); clientc.Player.Inventory.BeginChanges(); clientc.Player.Inventory.CommitChanges(); clientc.Player.UpdatePlayerStatus();

Nope :-(

/stuck
“ If debugging is the process of removing software bugs, then programming must be the process of putting them in. ”

Join https://discord.gg/r3T2U7S Official DOL Discord Chat
User avatar
Loki
Developer
 
Posts: 468
Joined: Fri Jun 23, 2006 2:14 am
Location: uk

Re: Save back to Database[SOLVED]

Postby Loki » Tue Dec 13, 2016 2:46 pm

Code: Select all
clientc = WorldMgr.GetClientByPlayerName(playerac.Name, true, true);

This was the key :-)
“ If debugging is the process of removing software bugs, then programming must be the process of putting them in. ”

Join https://discord.gg/r3T2U7S Official DOL Discord Chat
User avatar
Loki
Developer
 
Posts: 468
Joined: Fri Jun 23, 2006 2:14 am
Location: uk


Return to “%s” Support

Who is online

Users browsing this forum: No registered users and 1 guest