Haymaker 13 Posted April 7, 2016 So I'm trying to make a script execute for each classname. Essentially I want every one of these objects to have an addaction to execute a script which drops a specific object once every minute 10 times. I understand I can add an eventHandler for init, but that requires an object, and a classname isn't an object. The only thing I can think of is: nearestObjects [player, ["classname"], 999999999]; but then I'd have to constantly execute that script, and I fear locality issues. A workaround I'm considering is somehow creating them into a gearbox, and making them into a 'put' eventhandler, where if you added a gear item, water let's say, to the box, it will delete the water and addItemCargo every 1 minute ten times. This sounds like a good idea but my main issue is I'm new to modding and I'd like to avoid config at all costs :D Any help would be appreciated, thanks guys. Share this post Link to post Share on other sites
davidoss 548 Posted April 7, 2016 Extended Init eventhandler from cba a3 class Extended_Init_EventHandlers { class classname { init = "(_this select 0) call fnc_script"; }; }; Use base classname which all your objects belongs to. in function or script: +define _object in params +define _array contain your all object classnames. +create statement to exit if typeof _object is not in _array. +setvariable on _object +optional for different variables use switch (typeof _object) do {} 1 Share this post Link to post Share on other sites
Haymaker 13 Posted April 8, 2016 Extended Init eventhandler from cba a3 class Extended_Init_EventHandlers { class classname { init = "(_this select 0) call fnc_script"; }; }; Use base classname which all your objects belongs to. in function or script: +define _object in params +define _array contain your all object classnames. +create statement to exit if typeof _object is not in _array. +setvariable on _object +optional for different variables use switch (typeof _object) do {} Uh oh time to go read up on config :( Share this post Link to post Share on other sites
Icaruk 14 Posted April 8, 2016 Maybe this? // Run this only on server { [_x, 'call asd_fnc_function'] remoteExec ["addAction", -2]; // 0 all, 2 only server, -2 all except server } forEach (nearestObjects [position, ["classname"], 90000]); Or maybe it could be better to start a loop local to each player, checking if his (typeOf cursorTarget) is that className, if true: addAction, if false: removeAction. Share this post Link to post Share on other sites