Forum BigDB Loading a 'PlayerObject's Object' on the server.

Discussion and help relating to the PlayerIO database solution, BigDB.

Loading a 'PlayerObject's Object' on the server.

Postby FuzzySlash » December 26th, 2011, 1:05 am

Hi!
Me and my team are close to finishing our multiplayer strategy game.It's been quite fun working with the playerIO api.
Right now I'm trying to load an object on the server.

For example, say we have a player object that stores an inventory array... inside the array are Objects, like {Name:"Rusty Sword", Type:"Melee Weapon"}
How do I load an object from that array to the server? (This may be really simple, I just have no idea).
For example:
Code: Select all
DatabaseArray Inventory = player.PlayerObject.GetArray("Inventory");
//And now I want to get the Item from the array:
<Object I want> = Inventory.Get<?>(index); // How do I retrieve it?
//Next I want to check whether the type is "Melee Weapon":
if(<Object>["Type"]=="Melee Weapon"){
//do stuff
}


Thank you!
Fuzzy
FuzzySlash
 
Posts: 37
Joined: April 15th, 2011, 3:59 am

Re: Loading a 'PlayerObject's Object' on the server.

Postby Henrik » December 26th, 2011, 8:07 pm

http://playerio.com/documentation/refer ... abasearray

You were almost right. :-)

Code: Select all
DatabaseArray Inventory = player.PlayerObject.GetArray("Inventory");
DatabaseObject item = Inventory.GetObject(0); //Get the first item
if (item.GetString("Type") == "Melee Weapon") {
    //...
}
Henrik
.IO
 
Posts: 1880
Joined: January 4th, 2010, 1:53 pm

Re: Loading a 'PlayerObject's Object' on the server.

Postby FuzzySlash » December 27th, 2011, 11:29 am

Whey! :)
This'll help a lot, thank you very much,
Fuzzy
FuzzySlash
 
Posts: 37
Joined: April 15th, 2011, 3:59 am


Return to BigDB