Forum Multiplayer Internal PlayerIO Error

Discussion and help relating to the PlayerIO Multiplayer API.

Internal PlayerIO Error

Postby Emalton » April 18th, 2018, 5:01 pm

I seem to have an error happening on PlayerIO's internal server sided code. It happens whenever "player.Name" is fired.

When player.Name is fired, it gets the name of the player tied to their PlayerObject, which is preloaded as indicated below.

Here's an isolated version of my problem:

Code: Select all
public override void GameStarted()
{
    PreloadPlayerObjects = true;
}

public override bool AllowUserJoin(GamePlayer player)
{
    if (player.Name == string.Empty) // Check to see if the player's name is empty. (it is in this case)
    {
        Console.WriteLine(player.ConnectUserId + " tried to join and failed because they do not have a name!");
        return false;
    }
}

public class GamePlayer : CommonPlayer
{
    public float X, Y = Configuration.Block.Size;
}

public class CommonPlayer : BasePlayer
{
    public virtual string Name { get { return PlayerObject.GetString("Name", string.Empty); } set { PlayerObject.Set("Name", value); } }

    public virtual Rank Rank { get { return (Rank)PlayerObject.GetInt("Rank", (int)Rank.None); } set { PlayerObject.Set("Rank", (int)value); } }
}


Error Outputted:
Code: Select all
simpleAccount tried to join and failed because they do not have a name!
>User simpleAccount (1): Left game
>Error: Object reference not set to an instance of an object.
   at PlayerIO.ServerCore.GameManager.GameHost.runEvent_(GameEvent evt, BasePlayer player, Message message, Action action)
   at PlayerIO.ServerCore.GameManager.GameHost.<>c__DisplayClass3c.<RunEvent>b__3a()
   at PlayerIO.ServerCore.GameManager.ExternalCodeManager.RunExternalCode[T](UInt32 gameId, Func`1 externalCode, Nullable`1 maxNaturalTimeOverride, Int64& ticks)
   at PlayerIO.ServerCore.GameManager.GameHost.RunEvent(GameEvent evt, BasePlayer player, Message message, Action action)


Please help!

Emalton
Emalton
 
Posts: 86
Joined: June 28th, 2013, 3:49 am

Re: Internal PlayerIO Error

Postby robscherer123 » April 18th, 2018, 9:34 pm

I'm not sure if this would entirely be an issue related, but do you have the PreloadPlayerObjects value set to true?
robscherer123
Paid Member
 
Posts: 313
Joined: December 12th, 2012, 8:46 pm

Re: Internal PlayerIO Error

Postby Emalton » April 18th, 2018, 10:25 pm

Hi robscherer123, thank you for your reply!!

I do have PreloadPlayerObjects set to true as shown in the first post.

--

After digging deeper, this error only happens if I return false instead of true. If I return true, the error doesn't happen.
Emalton
 
Posts: 86
Joined: June 28th, 2013, 3:49 am

Re: Internal PlayerIO Error

Postby Emalton » April 19th, 2018, 2:51 am

For now I'm just returning true in AllowUserJoin and just disconnecting when the UserJoined method is reached. Not preferred but I guess it works. :)
Emalton
 
Posts: 86
Joined: June 28th, 2013, 3:49 am

Re: Internal PlayerIO Error

Postby robscherer123 » April 19th, 2018, 2:18 pm

Ah my fault, I didn't realize the top line you had already showed you do have it set to true. >.<

I never noticed the AllowUserJoin function, that would have come in handy for my game. So are you getting Name returning empty EVERY time, or is it seemingly random?

My guess would be (if I'm understanding correctly), from the documentation that AllowUserJoin fires at some point before PlayerJoined (obviously). And that PreloadPlayerObjects makes the database object loaded before the player is even joined. But from the documentation AllowUserJoin fires "before a user is fully joined". So maybe there's an issue here where the PlayerObject is loaded after AllowUserJoin is called, but before PlayerJoined is called. Would that seem to be what's happening?
robscherer123
Paid Member
 
Posts: 313
Joined: December 12th, 2012, 8:46 pm

Re: Internal PlayerIO Error

Postby Emalton » April 20th, 2018, 7:53 pm

robscherer123 wrote:Ah my fault, I didn't realize the top line you had already showed you do have it set to true. >.<

It's okay. :)

robscherer123 wrote:I never noticed the AllowUserJoin function, that would have come in handy for my game. So are you getting Name returning empty EVERY time, or is it seemingly random?

The value of name is correct, but it errors when I do "return false" afterwards. And yeah, it's helpful when it works! :P

robscherer123 wrote:My guess would be (if I'm understanding correctly), from the documentation that AllowUserJoin fires at some point before PlayerJoined (obviously).

Yeah, calling "return false" in AllowUserJoin prevents PlayerJoined from firing, and the server disconnects the player and sends "groupdisallowuserjoin" or something.

robscherer123 wrote:And that PreloadPlayerObjects makes the database object loaded before the player is even joined.

Yeah, it should load before "AllowUserJoin" as well. (Otherwise it would be pointless.)

robscherer123 wrote:But from the documentation AllowUserJoin fires "before a user is fully joined". So maybe there's an issue here where the PlayerObject is loaded after AllowUserJoin is called, but before PlayerJoined is called. Would that seem to be what's happening?

The value does return correctly and is properly displayed in the development server variable data but returning false for some reason messes things up.

--

I DON'T UNDERSTAND!!!! lol
Emalton
 
Posts: 86
Joined: June 28th, 2013, 3:49 am

Re: Internal PlayerIO Error

Postby robscherer123 » April 20th, 2018, 8:00 pm

Ah, hmm maybe I slightly misunderstood then. So you mean just simply returning false inside AllowPlayerJoin is throwing an error inside PlayerIO?
robscherer123
Paid Member
 
Posts: 313
Joined: December 12th, 2012, 8:46 pm

Re: Internal PlayerIO Error

Postby Emalton » April 20th, 2018, 11:51 pm

robscherer123 wrote:Ah, hmm maybe I slightly misunderstood then. So you mean just simply returning false inside AllowPlayerJoin is throwing an error inside PlayerIO?


Yeah whenever I do player.Name beforehand.
Emalton
 
Posts: 86
Joined: June 28th, 2013, 3:49 am


Return to Multiplayer



cron