Forum ‹ QuickConnect ‹ Questions about simple connect and player objects
6 posts
• Page 1 of 1
Questions about simple connect and player objects
When you register a user using SimpleRegister, how do you get it to create a playerObject for that user? I assumed that they get created automatically, but my BigDB PlayerObjects list is still empty after I've created a user.
I want to give the player certain properties when they sign up (number of credits and so forth), but I am unsure how to do that.
There isn't a UserRegistered method I can override on the server side and even if there was I'm not sure how you would create a playerObject and add fields to it.
Any help would be really appreciated.
I want to give the player certain properties when they sign up (number of credits and so forth), but I am unsure how to do that.
There isn't a UserRegistered method I can override on the server side and even if there was I'm not sure how you would create a playerObject and add fields to it.
Any help would be really appreciated.
- MrBiscuits
- Paid Member
- Posts: 26
- Joined: May 15th, 2011, 8:09 pm
Re: Questions about simple connect and player objects
Nothing is saved to the PlayerObjects table until you actually put data in the PlayerObject of the player, and call Save() on it.
The easiest way to add data on registration is to always check if the PlayerObject has the properties you want, and if it doesn't you add it and save it. Check the second piece of example code on this page:
http://playerio.com/documentation/bigdb/playerobject
The easiest way to add data on registration is to always check if the PlayerObject has the properties you want, and if it doesn't you add it and save it. Check the second piece of example code on this page:
http://playerio.com/documentation/bigdb/playerobject
-

Henrik - .IO
- Posts: 576
- Joined: January 4th, 2010, 1:53 pm
Re: Questions about simple connect and player objects
Great thanks that works.
I'm having a problem when I update the playerObject on the server and saving it using PlayerObject.Save().
The client requests the updated playerObject using:
client.bigDB.loadMyPlayerObject(function(_obj:DatabaseObject):void
but the data doesn't seem to have been updated in time so the client still receives the old data.
If I put a breakpoint on the server after the PlayerObject.Save() and wait for a few seconds, then allow it to continue (it sends a receipt to the client saying the data is updated, which then calls loadMyPlayerObject), the data gets updated ok on the client.
Is there a way to fix this?
I'm having a problem when I update the playerObject on the server and saving it using PlayerObject.Save().
The client requests the updated playerObject using:
client.bigDB.loadMyPlayerObject(function(_obj:DatabaseObject):void
but the data doesn't seem to have been updated in time so the client still receives the old data.
If I put a breakpoint on the server after the PlayerObject.Save() and wait for a few seconds, then allow it to continue (it sends a receipt to the client saying the data is updated, which then calls loadMyPlayerObject), the data gets updated ok on the client.
Is there a way to fix this?
- MrBiscuits
- Paid Member
- Posts: 26
- Joined: May 15th, 2011, 8:09 pm
Re: Questions about simple connect and player objects
All BigDB methods are asynchronous, which means that they return immediately, they don't wait for the operation to complete. If you want to send a message to the client to load an object you saved server-side, you need to call Save with a success callback, and in that callback you send a message to the client to reload the object, because when that callback fires, the object is definitely saved.
-

Henrik - .IO
- Posts: 576
- Joined: January 4th, 2010, 1:53 pm
Re: Questions about simple connect and player objects
Ah right that makes sense.
What is the syntax for adding a callback function name to the playerObject.Save() function?
Edit: I've figured it out now
player.PlayerObject.Save(delegate()
{
FunctionName(player);
});
Also is there a C# server reference anywhere?
What is the syntax for adding a callback function name to the playerObject.Save() function?
Edit: I've figured it out now
player.PlayerObject.Save(delegate()
{
FunctionName(player);
});
Also is there a C# server reference anywhere?
- MrBiscuits
- Paid Member
- Posts: 26
- Joined: May 15th, 2011, 8:09 pm
Re: Questions about simple connect and player objects
MrBiscuits wrote:Also is there a C# server reference anywhere?
Right here: http://playerio.com/documentation/refer ... ltiplayer/
-

Henrik - .IO
- Posts: 576
- Joined: January 4th, 2010, 1:53 pm
6 posts
• Page 1 of 1