OFPEC Forum
Addons & Mods Depot => Arma2 - Configs & Scripting => Topic started by: nuxil on 20 Sep 2010, 11:09:38
-
Hello good people.
i have a question.
lets say i have a serveraddon abc
is it possible to make addon abc to autostart a bunch of scripts each time a mission starts ?
so instead of editing 100 missions + upcomming missions with the execution of my scripts in addon abc.
is it possible to do what i want ?
-
What kind of autostart? The kind of autostart wherein EVERY mission starts these scripts (e.g. VFAI, DSAI, etc.) or the kind of autostart wherein you put down a module (F7) and that starts the scripts (e.g. all the default BIS modules, Mando Missile etc)? The first one requires you to use CBA (http://forums.bistudio.com/showthread.php?t=78622) whereas the second is as simple as configuring an init eventhandler on a game logic. Here's an example of that (just paste into a config.cpp file and compile the pbo together with your scripts):
class CfgPatches
{
class YOURTAG_Addon
{
units[] = {};
weapons[] = {};
requiredVersion = 1.05;
requiredAddons[] = {""};
};
};
class cfgvehicles
{
class Logic;
class YOURTAG_Name : Logic
{
displayName = "Name of module";
icon = "\ca\ui\data\icon_functions_ca.paa";
picture = "\ca\ui\data\icon_functions_ca.paa";
vehicleClass = "Modules";
class Eventhandlers {
init = "(_this select 0) execvm ""YourScript.sqf"" ";
};
};
};
Simply add YourScript.sqf to the addon and it should work out all right. If you have a bunch of scripts, simply have it run an init script which in turn starts all the others :) (or have many logics). You can also have regular folder paths and stuff, just use /scriptfolder/script.sqf.
The CBA method is kind of similar, but slightly more complicated, but check out CBA for documentation on that :)
Wolfrug out.
-
PS: Styling wise you may want to use quotes in single quotes or the other way round.
"Text ""Quotes in the Text"" End"
=>
"Text 'Quotes in the Text' End"
or
'Text "Quotes in the Text" End'
-
Hi Wolfrug and thanks for your reply.
i tried to look at the cba doc. but could not really find what i was looking for,
maybe you could point me ;p
also i dont want to rely on a 2nd addon for mine to work. but if no other way then i'll have to.
the 2nd methode you said. about using modules.
im not sure i understood it correct.
if i make a module doesnt both the server & client need the addon?
the thing is i only want the server sided scripts in the addon to autostart.
my addon is just a pack of scripts.
at the moment i am editing every missions init file and adding the path to my server addon init script
i find this methode a really shitty one. i dont want to edit every #!!# mission to run my server scripts :p
i been googeling a bit. but coulnt really find anything related.
i found this post here.
http://dev-heaven.net/boards/23/topics/show/1537
so i tried make/editing my vehicle config file for the server addon
to like
class CfgVehicles
{
class All;
class AllVehicles;
class Land;
class Man : Land
{
class Eventhandlers
{
init = '[] execvm "\myaddon\sqf\init.sqf"';
};
};
};
but this didnt work. i seams like init.qsf never got executed.
maybe this was because the ai's on the missions i tested it with was greated localy.donno.
-
Config EH overwrite each other. This is the reason to use CBA/XEH.
-
ok thanks kju.
i didnt know Config EH overwrite each other.
i'll look into the cba docs a bit more.
btw. about your styling you posted earler. i does matter sometimes.
i found out that when i deal with dialogs i somethimes need to use "foo = ""bar"""
example
class MY_BUTTON : BUTTON
{
text = "my button";
action = "myvar = ""test"";PublicVariable ""myvar""";
}
using
action = "myvar = 'test';PublicVariable 'myvar'";
action = 'myvar = "test";PublicVariable "myvar"';
would not work..
-
Hm weird. These work for me:
onLoad = "[] execVM 'features\bon_artillery\dialog\bon_initartillery.sqf';";
onUnload = "if (AAS_ArtyDialogOpen) then {player execVM 'features\bon_artillery\bon_arti_cancle.sqf';};";
action = "[99,player] execVM 'cClickSpawnButton.sqf';";
XEH is actually pretty easy. The best way to get into it is to look at examples (as always).
Basically for the simple usage you only need to convert your config EH to the XEH format.
A few examples:
class Extended_Init_EventHandlers
{
class Man
{
DisableBasicConversationsForAnyUnit_Gameplay_C_PROPER_Man_Init = "{_x setVariable ['BIS_noCoreConversations', true];} foreach allUnits;";
};
};
class Extended_PreInit_EventHandlers
{
PROPER_EasyFly_Planes_preinit = "PROPER_EasyFly_Planes_by_Celery_Plane_Init_Pre = compile preprocessFileLineNumbers '\EasyFly_Planes_by_Celery_Gameplay_C_PROPER\CLY_EasyFly.sqf'";
};
class Extended_Init_EventHandlers
{
class Plane
{
PROPER_EasyFly_Planes_by_Celery_Init_Plane = "[] spawn PROPER_EasyFly_Planes_by_Celery_Plane_Init_Pre;";
};
};
class Extended_GetIn_Eventhandlers
{
class Plane
{
PROPER_EasyFly_Planes_by_Celery_GetIn_Plane = "if (player == (_this select 2)) then { [] spawn PROPER_EasyFly_Planes_by_Celery_Plane_Init_Pre };";
};
};
class Extended_PreInit_EventHandlers
{
PROPER_ToughChopperRotor_preinit = "PROPER_ToughChopperRotor_Init_Pre = compile preprocessFileLineNumbers '\ToughChopperRotor_Gameplay_C_PROPER\PROPER_ToughChopperRotor.sqf'";
};
class Extended_Init_EventHandlers
{
class Helicopter
{
PROPER_ToughChopperRotor_Helicopter_Init = "[] spawn PROPER_ToughChopperRotor_Init_Pre;";
};
};
class Extended_GetIn_Eventhandlers
{
class Helicopter
{
PROPER_ToughChopperRotor_Helicopter_Init = "if (player == (_this select 2)) then {[] spawn PROPER_ToughChopperRotor_Init_Pre;};";
};
};
So there is not really much magic involved (unless you use the additional powerful spells available in XEH too). :)
-
hmm. seams easy enough. but i cant get it to work.
on my server i placed @cba in my arma2 install dir.
using mod parm. mod=@cba;@myserveraddon on the server startup.
i see the rpt log says.
[7877,115.793,0,"XEH: PreInit Started"]
[7877,115.91,0,"MISSINIT","-British_Army_Forces-co30_Domi","Takistan",true,true,true]
[7877,116.435,0,"XEH: PreInit Finished"]
so im assuming the init xeh is started.
config.cpp
#include "CfgPatches.hpp"
#include "Extended_Init_EventHandlers.hpp"
CfgPatches.hpp
class CfgPatches {
class MyServerAddon
{
units[] = {};
weapons[] = {};
requiredVersion = 0.1;
requiredAddons[] = {};
version = 0.1;
fileName = "myserveraddon.pbo";
author = "";
mail = "";
};
};
Extended_Init_EventHandlers.hpp
class Extended_Init_EventHandlers {
class Man
{
My_Man = '[] execvm "\myserveraddon\sqf\init.sqf"';
};
};
i cant get this to work.
when i connect to my server it says im missing cba_main..
thats really anoying. since i want it to be server sided only. and clients should not need to get such message, since they dont depend on it.
but anyway. if i put
if ((isServer) or (isDedicated)) then
{
nil = [] execvm "\myserveraddon\sqf\init.sqf";
};
in the init of a mission it works like a charm.
so where am i doing wrong here??
should i use class Extended_PreInit_EventHandlers instead?
with
serverInit = "[] execvm '\myserveraddon\sqf\init.sqf';";
im verry confused here.
-
For server side addon see:
http://dev-heaven.net/projects/serversidescripting/wiki
-
ahh nice..
i got it working now.
only problem i now have is the message i get by cba.
YOU ARE MISSING THE FOLLOWING MOD: CBA_MAIN
is there a way to disable this ?
-
Try to remove the CBA_versioning.pbo or cba_diagnostic.pbo on the server.