Jump to content
Sign in to follow this  
alleycat

isPlayer question

Recommended Posts

Some questions about server/client locality:

1.

http://community.bistudio.com/wiki/isPlayer

Can this command be used like this, without an object?

for example in the init.sqf calling:

if (isPlayer) then....

2. If I wanted to delay the game start until the server is done with some scripts called in init.sqf, how to do that?

init.sqf

if (isPlayer) then {
call { [lol] execVM "player_hud.sqf"; };
};
if (isServer) then {


_handle1 = execVM "script1.sqf" ;
_handle2 = execVM "script2.sqf" ;
};

3. How to make sure the isPlayer command only targets the local player of this machine? I dont want JIP players to restart these scripts for other players

Edited by alleycat

Share this post


Link to post
Share on other sites

if (local player) then {
}

or

if (!isDedicated) then {
}

Share this post


Link to post
Share on other sites

Errr, I've never used isPlayer before, but I generally use this to check if a certain object is a player.

if (_obj in playableUnits) then {};

Share this post


Link to post
Share on other sites

I just edited the first post including some more questions, did not see your posts. What I fear is that these server/client switches might silently fail and carpetbomb the server with scripts

---------- Post added at 04:45 PM ---------- Previous post was at 04:36 PM ----------

if (local player) then {
call { [player] execVM "player_hud.sqf"; };
};
if (isServer) then {


_handle1 = execVM "script1.sqf" ;
_handle2 = execVM "script2.sqf" ;
};

Modified the code following your suggestions. Going to test that on a dedicated

Edited by alleycat

Share this post


Link to post
Share on other sites

Why do all scripts in the init fail on JIP when they look like this:

//Anything inside this is skipped on JIP
if (local player) then {};

//This fails too in init.sqf, without being inside any player/server condition
player addAction

Share this post


Link to post
Share on other sites

Most likely because player object has not been set yet when you do the local check. Anything objNull is never local.

Share this post


Link to post
Share on other sites

That would explain why re-joining makes it work. Is there a way to get it to work on first load with a delay so the script starts a few seconds after the game is running?

Share this post


Link to post
Share on other sites
waitUntil {isDedicated || !isNull player};

Share this post


Link to post
Share on other sites

Why isDedicated?

---------- Post added at 07:01 PM ---------- Previous post was at 06:56 PM ----------

Why isDedicated?

Also, I got all the jip stuff working by using

		while {isNull player} do
	{
		diag_log text "(PLAYER ISNULL) waiting..";
		sleep 1;
	};	

However on the very first start it still fails to run scripts properly (clients that join the server when it starts, the opposite of JIP basically)

Share this post


Link to post
Share on other sites

So a dedicated server doesn't get stuck in the init (it doesn't have a player object, so it's trying to waitUntil objNull is never null, which is never.)

It's the same as writing

if (!isDedicated) then {
  waitUntil {!isNull player};
  // more code that should only run on clients/listen servers
};

For your second question I'd guess something else is wrong. Players that are in the game from start (not JiP) are never null.

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  

×