Author Topic: init script for addons  (Read 784 times)

0 Members and 1 Guest are viewing this topic.

Offline OliverPA

  • Members
  • *
  • I was a llama!
init script for addons
« on: 07 Jul 2007, 16:46:41 »

I've been trying for days to create an addon that executes a script whenever a mission starts.
So far I've searched many forums, unpbo'd many addons to get some ideas, ... with no luck.
The addon I'm trying to create adds no units, but simply consists of a script that runs in the background and needs to be called whenever a mission is started. Also the script should be called for any mission without having to edit the mission itself.

Thanks for your help!

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: init script for addons
« Reply #1 on: 07 Jul 2007, 17:12:06 »
An addon so it must be present in a mission before it can execute any scripts because the vehicle has to be 'initialized' before the init eventHandler (which you undoubtedly are using) is triggered, so what you're trying to achieve is impossible to do, with an addon or having to edit the mission itself.
Project MCAR   ---   FWW2 - Finland At War 1939-1945
Chuck Norris can divide by zero.

Offline OliverPA

  • Members
  • *
  • I was a llama!
Re: init script for addons
« Reply #2 on: 14 Jul 2007, 13:51:59 »
Thanks, your answer helped me find a solution:

Code: [Select]
class CfgVehicles {
  class Land;
  class Man : Land {};

  class CAManBase : Man {
    class eventhandlers {
      init = "[] execVM ""\SightAdjustment\scripts\SightAdjustmentInit.sqf"";";

The script itself checks whether it's called the first time or not, so it will get called quite often but always exits quickly except for the first call.
regards, Oliver.