Jump to content
JGames Family

WaitUntil and a variable.

Recommended Posts

Hi, I want to pùt a wait until the player has this variable in local player init:

player set variable ["FinishedLoading",true,true];

I tried:

waitUntil { (player getVariable "FinishedLoading") = true };

and 

waitUntil { (profileNamespace getVariable "FinishedLoading") = true };

with no sucess... any help?

Thx

Share this post


Link to post
Share on other sites

@JGames Family,

It's been a while since I was at this but I believe if you want to use "waitUntil" in an init you need to spawn it. Something like this,

[] spawn {waitUntil { (player getVariable "FinishedLoading") = true };};

Have fun!

  • Like 1

Share this post


Link to post
Share on other sites
11 minutes ago, wogz187 said:

@JGames Family,

It's been a while since I was at this but I believe if you want to use "waitUntil" in an init you need to spawn it. Something like this,


[] spawn {waitUntil { (player getVariable "FinishedLoading") = true };};

Have fun!

Did it, no success

  • Haha 1

Share this post


Link to post
Share on other sites

Doesn't work, what is it wrong... I tried with 

[] spawn {waitUntil { (player enableSimulation) isEqualTo true };};

also with no success... any help?

Share this post


Link to post
Share on other sites

Depends on what exactly you wanted to do. I see nothing about things you wanted to do. Every codes in this topic are completely useless though.

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Ok, so I want to make so that when it finishes loading (When it finishes loading it enables the simulation or put that variable in the player for example) it continues reading the init SQF to execute the rest of the scripts. @POLPOX

Share this post


Link to post
Share on other sites

Without addressing the validity of the rest of your code, understand that "=" is an assignment operator. you want the comparison operator "==". 

  • Like 1

Share this post


Link to post
Share on other sites
5 minutes ago, Harzach said:

Without addressing the validity of the rest of your code, understand that "=" is an assignment operator. you want the comparison operator "==". 

Tried both with no success

Share this post


Link to post
Share on other sites
3 minutes ago, JGames Family said:

Ok, so I want to make so that when it finishes loading (When it finishes loading it enables the simulation or put that variable in the player for example) it continues reading the init SQF to execute the rest of the scripts.

I use

waitUntil {time != 0};

for the purpose. (I know this is a dumb thing though)

 

Just now, Harzach said:

Without addressing the validity of the rest of your code, understand that "=" is an assignment operator. you want the comparison operator "==". 

Also, checking boolean (true/false) never requires operators.

  • Like 2

Share this post


Link to post
Share on other sites
1 minute ago, POLPOX said:

Also, checking boolean (true/false) never requires operators.

 

Indeed, I just like taking it one thing at a time. 🙂

Share this post


Link to post
Share on other sites

yeah but time can vary so might be better when its all loaded u know

3 minutes ago, POLPOX said:

I use


waitUntil {time != 0};

for the purpose. (I know this is a dumb thing though)

 

Also, checking boolean (true/false) never requires operators.

 

Share this post


Link to post
Share on other sites

@JGames Family,
Again, not exactly on point with sqf but the code would look something like (to paste in an init):

loadFIN=[] spawn {
    waitUntil {
                (player getVariable ["FinishedLoading", false])
    };
};

of course that isn't going to do anything because the script to determine "finishedLoading" would accomplish the same thing. This would be an extra step in that process. However you determine "finishedLoading" would serve the same purpose as the above.

Share what comes next and share how "FinishedLoading" is determined.

Have fun!

  • Like 1

Share this post


Link to post
Share on other sites
8 minutes ago, JGames Family said:

yeah but time can vary so might be better when its all loaded u know

The condition will be fulfilled as soon as you started the mission, so would fit but isn't that what you want?

  • Like 1

Share this post


Link to post
Share on other sites
3 minutes ago, wogz187 said:

@JGames Family,
Again, not exactly on point with sqf but the code would look something like (to paste in an init):


loadFIN=[] spawn {
    waitUntil {
                (player getVariable ["FinishedLoading", false])
    };
};

of course that isn't going to do anything because the script to determine "finishedLoading" would accomplish the same thing. This would be an extra step in that process. However you determine "finishedLoading" would serve the same purpose as the above.

Share what comes next and share how "FinishedLoading" is determined.

Have fun!

Its a loading screen, after that loading screen I wad when a player has finished loading I want to continue it reading the script

 

Share this post


Link to post
Share on other sites

@JGames Family,

Quote

"Its a loading screen, after that loading screen I wad when a player has finished loading I want to continue it reading the script"

So at the end of your custom loading script you switch the player variable "finishedLoading" to true?

Is that right?

Share this post


Link to post
Share on other sites

yeah

1 minute ago, wogz187 said:

@JGames Family,

So at the end of your custom loading script you switch the player variable "finishedLoading" to true?

Is that right?

 

Share this post


Link to post
Share on other sites

@JGames Family,
So you,
1) init player variable?
player setVariable ["FinishedLoading", false];
2) set the variable via script?
player setVariable ["FinishedLoading", true];
3) put code in the unit init?

What if you change the boolean to numbers?

player setVariable ["FinishedLoading", 0];
player setVariable ["FinishedLoading", 1];
loadFIN=[] spawn {
    waitUntil {
                (player getVariable ["FinishedLoading", 0]==1)
    };
};
  • Like 1

Share this post


Link to post
Share on other sites
//initPlayerLocal.sqf

[] spawn {
	[ "loadPlayerData" ] call BIS_fnc_startLoadingScreen;

	//simulate some time taken for loading data
	uiSleep 20;

	[ "loadPlayerData" ] call BIS_fnc_endLoadingScreen;

	TAG_loadedData = true;
};


waitUntil{ missionNamespace getVariable[ "TAG_loadedData", false ] };


hint "Done!";

//Do rest of code

 

  • Like 3

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

×