Jump to content
pawelisus

How to get player side on connect

Recommended Posts

addMissionEventHandler ["PlayerConnected", {

_playeruid = _this select 1;

_playerUnit = 0;


        waitUntil

        {

            sleep 1;

            _playerUnit = _playeruid call BIS_fnc_getUnitByUID;

            not isNull _playerUnit;

        };
_playerside = side _playerUnit;

]};

Main problem is that the _playerside is equal to UNKNOWN. I've noticed that _playerUnit is <Null-Object>. I think BIS_fnc_getUnitByUID is called before player joined and I cant find a way to call it after him spawning.

Share this post


Link to post
Share on other sites

I'm not good at multiplayer scripts at all, but I see that you're using a loop in unscheduled environment . Also, the brackets in the code are mixed up in places.

May be try:

addMissionEventHandler ["PlayerConnected", {

_playerUnit = (_this select 1) call BIS_fnc_getUnitByUID;

_playerside = side _playerUnit;

}];

 

  • Like 1

Share this post


Link to post
Share on other sites
1 hour ago, Ibragim A said:

you're using a loop in unscheduled environment

That is why I used spawn in my original code...

Share this post


Link to post
Share on other sites
1 hour ago, sarogahtyp said:

That is why I used spawn in my original code...

Ohhh, I didnt saw that one.. you've not replied so I asked about the problem

 

Share this post


Link to post
Share on other sites
2 hours ago, Ibragim A said:

I'm not good at multiplayer scripts at all, but I see that you're using a loop in unscheduled environment . Also, the brackets in the code are mixed up in places.

May be try:


addMissionEventHandler ["PlayerConnected", {

_playerUnit = (_this select 1) call BIS_fnc_getUnitByUID;

_playerside = side _playerUnit;

}];

 

In my original code brackets are fine, I made a mistake writing it to a topic but thanks. Unfortunately it wont work because if it will be called emediately it will just return side "UKNOWN" because player isn't spawned yet

Share this post


Link to post
Share on other sites

This is all taken care of in your other topic. This one is redundant.

  • Like 2

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×