Jump to content
iSassafras

[Solved] MP: How many times does init.sqf execute?

Recommended Posts

Hey guys, the title pretty much says it already. I feel kind of stupid for asking this, but I couldn’t figure it out from the wiki.

 

The BIS wiki says the init.sqf is being executed on every machine before the mission starts and JIP clients will also execute it. But does that mean it‘s just executed once on every machine or will a JIP trigger it again for everyone?

 

I‘m asking because my mission has some scripts and variables that need to run on every machine, but it‘s important they only run once and only local.

 

 

  • Like 1

Share this post


Link to post
Share on other sites

Yes, init.sqf is executed once, before the mission is started, but that means here on each PC, independently. So , any JIP (or re-JIP) will run this sqf. The init.sqf will not run again on other players' PC or even server, but some codes can be global. For example, if you create a vehicle by createVehicle command, the vehicle will be created locally but visible and accessible for everyone.

 

same for initPlayerLocal.sqf, a good place for running codes after player is defined (in game) but if your code has a global effect, it will be "broadcast" everywhere.

So, pay attention for local commands like createVehicleLocal or createMarkerLocal if needed. On the contrary global ones are also useful when fired from server...

Have a look at:

https://community.bistudio.com/wiki/Event_Scripts

https://community.bistudio.com/wiki/Multiplayer_Scripting

to start.

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites

Thank your very much for the reply! That makes it a lot easier.
I had some identical lines in initPlayerLocal.sqf and initServer.sqf and everytime I changed something in one of them I had to keep in mind to also do it in the other. Using the init.sqf will make it a lot easier. 🙂

  • Like 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

×