Jump to content
jeffv202

Presence of an element according to the time.

Recommended Posts

Hello guys, i'm a beginner and i have no idea how to create this .I would like a civilian to be present between 6am and 9pm and after or before this time it disappears. Anyone have an idea how to create this? I've been googling for 30 minutes but I haven't found an answer.

 

A big thank you guys. 

Share this post


Link to post
Share on other sites

Are those times correct?   it is unlikely that a mission would last for 15 hours.

.

 

Share this post


Link to post
Share on other sites

You could possibly do something like the following

while {true} do {
	private _hour = floor daytime; // Get the hour of the local in-game time
	private _sheep = objNull; // Initialise the sheep

	if(_hour > 6 && {_hour < 21} && {_sheep isEqualTo objNull}) then {
		_sheep = createVehicle["Sheep_random_F", getPos player, [], 10, "NONE"]; // Create a sheep
	};
	
	if({_hour < 6 || {_hour > 21}} && {!(_sheep isEqualTo objNull)}) then {
			deleteVehicle _sheep; // Delete the sheep
	};
                               
	// Sleep a while to save some CPU
	sleep 30;
};

I am sure you could refine and make the code better in many ways, but I hope you do get the basic idea.

 

Please let us know if you have any more issues or further questions.

 

Have fun, stay safe and ArmA a lot.

  • Like 1

Share this post


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

I'm using sunOrMoon > 0.5 condition for day/night environment. Simple, efficient.

Yep, this should work fine, but it's a wee bit more difficult to control the exact time the unit will appear and disappear.

Share this post


Link to post
Share on other sites
22 minutes ago, ZaellixA said:

Yep, this should work fine, but it's a wee bit more difficult to control the exact time the unit will appear and disappear.

Bah, jeffV202 said it was an example. So, he didn't mention a time clock for the sheep. ⏲️🐑🐑🐏

  • Haha 1

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

×