Jump to content
Sign in to follow this  
CARRICK_IRISH

Find chair object and addAction not working in MP

Recommended Posts

Hey folks,

right from the start: im a beginner in arma scripting an want to initialize an addAction to every camping-chair in the multiplayer game.

Here is my first solution but it is only working in the editor preview. it is not working on my dedicated server.

i think i have a problem with the "player" thing which is not working in MP?

_chairs = nearestObjects [player, ["Land_CampingChair_V1_F"], 5];

{
 if (typeOf _x == "Land_CampingChair_V1_F") then
   {
       _x addAction ["Hinsetzen","Missionpack\Chairs\sitdown.sqf"];
   };
}
forEach _chairs;

regards,

ian

Edited by ian_Carrick

Share this post


Link to post
Share on other sites

How are you running it? All clients should get the addAction but not the dedicated server (because "player" is null)

Share this post


Link to post
Share on other sites

I'm putting this to the Init.sqf but i guess this is absolutely the wrong way

Edited by ian_Carrick

Share this post


Link to post
Share on other sites

Try waiting for the player variable to not be null (= waiting for the client to get control of the chosen unit). Spawn is there to just separate the waiting from the init.sqf, if you have other stuff after it.

[] spawn {
 waituntil {!isnull player};
 _chairs = nearestObjects [player, ["Land_CampingChair_V1_F"], 5];

 {
   if (typeOf _x == "Land_CampingChair_V1_F") then
     {
         _x addAction ["Hinsetzen","Missionpack\Chairs\sitdown.sqf"];
     };
 }
 forEach _chairs;
};

Share this post


Link to post
Share on other sites

Ah, i will check the reference for null and spawn and try to implement your code when i'm at home. thank you for the keywords and the answers shuko and cuel

ian

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
Sign in to follow this  

×