Forum BigDB Global data and accessing other player's data?

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

Global data and accessing other player's data?

Postby twick » December 14th, 2010, 6:17 am

Hi again!

I was wondering if it's possible to store global data in bigDB. By this I mean anyone being able to access this data (read/write), but I don't want it associated with any account (global game state such as night/day for example). Ideally I'd only want the server to retrieve this data. I could just use a variable within the server, but I'd want to store the information if the server goes down or whatever!

I was also wondering If the server can access other player's bigDB data and not just the player that's logged in. I want to implement a gift system, which sends an item to another account (but not necessarily playing at that moment). The items are stored in bigDB.

Thanks in advance!
twick
 
Posts: 15
Joined: October 13th, 2010, 5:27 pm

Re: Global data and accessing other player's data?

Postby Henrik » December 14th, 2010, 11:32 am

Yes, of course you can. The normal way of working with BigDB is that you load and save objects that have keys you make up yourself. The PlayerObject functionality is just a convenience-method that assigns one object per player and gives it restrictive access rights.

For global data, make your own table, save and load objects with your own keys, and remove all access rights. That means that clients can't modify or read the data, but the server can always do whatever.

If you want to modify the PlayerObject of another player in server code, you have to load the object manually from the PlayerObjects table. The key to each player's object is their connectuserid.
Henrik
.IO
 
Posts: 1880
Joined: January 4th, 2010, 1:53 pm

Re: Global data and accessing other player's data?

Postby batiali » December 14th, 2010, 11:36 am

Hey,
yes and yes.

By default, you have PlayerObjects table in BigDB, which stores data for each individual.
You can, go to admin panel -> bigDB from left menu -> create table and store global data there.

To access other players data, you need to give access to PlayerObjects table under your game's setting.
Go to your game's main page from admin panel (not bigDB) -> edit settings -> under connections, there is public connection -> click edit. There is rights tab under that settings. Default is full creator rights: you need to check others according to what you really want. In general you should want to load, create and save them.
But be careful doing this. It's pretty unsecure to do such thing.
batiali
 
Posts: 29
Joined: August 11th, 2010, 2:53 pm

Re: Global data and accessing other player's data?

Postby twick » December 15th, 2010, 2:30 am

Thanks for the replies!

I will try it out tonight. However, I thought of a potential problem when accessing other player's data. If I were to send an item to a certain player and another player sent it to him as well at the same time, how would this affect the database?

For example, user has 10 potions. I gift him 1 at the same time as someone else gifts him 1. Would he get 12 total or would the data the server retrieved be obsolete and just set it to 11 both times?
twick
 
Posts: 15
Joined: October 13th, 2010, 5:27 pm

Re: Global data and accessing other player's data?

Postby Benjaminsen » December 15th, 2010, 9:01 am

If calling save while useOptimisticLocks is set to true, the save will fail if the object has changed in the meantime.
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark


Return to BigDB



cron