The appearance of the player on the map

Brain

Member
Member
Dec 29, 2016
71
7
8
50
Parts Unknown
DreTaX - tell me , please, you need to check when the player appeared on the map when you connect to the server - it is possible?
If you do a search through Find you get errors if there is no player nullreferenceexception object reference not set.
Not interested in Fougerite.find - need right side of the engine
 

Jakkee

Retired Staff
Retired Staff
Plugin Developer
Jul 28, 2014
1,465
932
113
Australia
What?
What are you trying to find? A Player?
Or post part of your code so we have a rough idea where this error is coming from
 

Brain

Member
Member
Dec 29, 2016
71
7
8
50
Parts Unknown
What?
What are you trying to find? A Player?
Or post part of your code so we have a rough idea where this error is coming from
I need to check to see if the player on the map when you first connect to the server

if (PlayerClient.GetLocalPlayer().rootControllable.gameObject != null)
{
}
nullreferenceexception object reference not se
 

Jakkee

Retired Staff
Retired Staff
Plugin Developer
Jul 28, 2014
1,465
932
113
Australia
I need to check to see if the player on the map when you first connect to the server

if (PlayerClient.GetLocalPlayer().rootControllable.gameObject != null)
{
}
nullreferenceexception object reference not se
Probably throwing null because there is no player yet (Still connecting).
Try:
C#:
var obj = PlayerClient?.GetLocalPlayer()?.rootControllable?.gameObject?? null
if (obj != null)
{
    //Not null
}
 

Jakkee

Retired Staff
Retired Staff
Plugin Developer
Jul 28, 2014
1,465
932
113
Australia
Theres no player being checked in that function.
Thats why you are getting null errors

PlayerClient.GetLocalPlayer() Needs to be a playersclient.
E.G:
On_PlayerConnected(Player player, etc)
player.PlayerClient.rootcontrollable.etc..
 

Brain

Member
Member
Dec 29, 2016
71
7
8
50
Parts Unknown
Theres no player being checked in that function.
Thats why you are getting null errors

PlayerClient.GetLocalPlayer() Needs to be a playersclient.
E.G:
On_PlayerConnected(Player player, etc)
player.PlayerClient.rootcontrollable.etc..
How can I check?
 

Brain

Member
Member
Dec 29, 2016
71
7
8
50
Parts Unknown
Theres no player being checked in that function.
Thats why you are getting null errors

PlayerClient.GetLocalPlayer() Needs to be a playersclient.
E.G:
On_PlayerConnected(Player player, etc)
player.PlayerClient.rootcontrollable.etc..
the check is on the client , not the server
 

Jakkee

Retired Staff
Retired Staff
Plugin Developer
Jul 28, 2014
1,465
932
113
Australia
Client or Server?
If server, post your full function or PM it if you dont want it public
 

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,093
4,784
113
At your house.
github.com
In client no On_PlayerConnected
So It throws null because the player didn't load yet?

Easy as this:

C#:
public void On_PlayerConnected(Fougerite.Player Player)
{
   DataStore.Add("CheckStuff", Player.UID, 1);
}

public void On_PlayerSpawned(Fougerite.Player player)
{
    if (DataStore.Get("CheckStuff", player.UID) != null)
    {
        DataStore.Remove("CheckStuff", player.UID);
        // todo do something
    }
}
 

Brain

Member
Member
Dec 29, 2016
71
7
8
50
Parts Unknown
So It throws null because the player didn't load yet?

Easy as this:

C#:
public void On_PlayerConnected(Fougerite.Player Player)
{
   DataStore.Add("CheckStuff", Player.UID, 1);
}

public void On_PlayerSpawned(Fougerite.Player player)
{
    if (DataStore.Get("CheckStuff", player.UID) != null)
    {
        DataStore.Remove("CheckStuff", player.UID);
        // todo do something
    }
}
I wrote it for the client - not the server check