PDA

View Full Version : How to create Modules via a script ?



McGlazd
Jun 9 2009, 20:40
Hello,

I am not even sure if this is possible. But since modules are Logic class, they must have the same behaviour. I'm trying to find a solution to use SOM in multiplayer missions. To make the module local, I create it from a trigger activated by radio.

And it doesn't work, that's why I'm asking for help! :yay:




// creating SOM
_socom = "SecOpManager" createVehicle (position player);
_socom synchronizeObjectsAdd [player];

hint "Init starting...";

// Wait until SOM is initialized
waitUntil { not isNil { _socom getVariable "initDone"} };
waitUntil { _socom getVariable "initDone" };

// activate arty
[["artillery_barrage"], player, [[ARTY, [1,2,3,4,5,6,7,8,9]]]] call BIS_SOM_addSupportRequestFunc;

hint "Arty initialized";



I do get the message "Arty initialized", which means the SOM has been actually created. I believe. But for some reason it doesn't work. Maybe because of the synchro things, I don't know... :confused:


Thank you !

Alex72
Jun 9 2009, 21:51
SOM doesnt work in MP as is?

Oh and here i thaught "wow how easy to setup a randomized game for me and a mate when we got nothing else to do". :) Well ok i hope you come up with a solution to it. ;)

Good luck!

Alex

i0n0s
Jun 9 2009, 22:12
This is just a guess but:
As soon as you create the vehicle, the socom init will run and find no synched objects -> exit.

Headspace
Jun 9 2009, 22:48
I'd try using createUnit for logics. Run the sync right after creating it. Do not use createVehicle.

Dr_Eyeball
Jun 10 2009, 00:18
According to DH topic (http://dev-heaven.net/boards/37/topics/show/949), you can't use createVehicle for logics, but can use either:
- createVehicleLocal, or
- createGroup sideLogic, plus createUnit

McGlazd
Jun 10 2009, 04:59
According to DH topic (http://dev-heaven.net/boards/37/topics/show/949), you can't use createVehicle for logics, but can use either:
- createVehicleLocal, or
- createGroup sideLogic, plus createUnit

Thank you, I'll give a try and send here a feedback this evening.

Cyborg11
Jun 11 2009, 11:48
And? Did it worked, McGlazd?

McGlazd
Jun 11 2009, 17:20
It is not stable. Sometime I can get the support menu from Communications but only briefly...

ENONIC
Jun 11 2009, 23:13
DnA sayed that there are issues with the com-menue in MP and that this will be fixed with the next patch. I realy hope so :) Maby we should wait till then. If there is a code problem with it, we can test as much as we want and wount get real results. Think this patch should be released at 19th June!?!?!? Dount want to give bad informations in the early morning, so im not shure.

Where ist the editingguid :rolleyes: ...

So a question abaout your script. You have created the SOM with:

_socom = "SecOpManager" createVehicle (position player);

But this is still local namespace. isnt it? the "_" means you creat a local variable. this is only held by the system as long the script is being executed. Maby im wrong. But i think you have to creat it in global namespace... !? so without "_" Like the variable "player" is a global variable.

ENONIC
Jun 12 2009, 14:33
Ok if taken this script and played a little bit around, here my edited version:


hint "calling script...";

// creating SOM
_group = createGroup sideLogic;
"SecOpManager" createUnit [position player, _group, "socom = this"];//<---Working in editor, singleplayer, IngameServer
//socom = "SecOpManager" createVehicleLocal getPos player; //<---not working
socom synchronizeObjectsAdd [player];

hint "Init starting...";

// Wait until SOM is initialized
waitUntil { not isNil { socom getVariable "initDone"} };
waitUntil { socom getVariable "initDone" };

hint "Init done... Adding ArtySupport";

// activate arty
//YOu can only call one barrage with this. After you fired the arty once, you have to call it again.
[["artillery_barrage"], player, [[ARTY, [1,2,3,4,5,6,7,8,9]]]] call BIS_SOM_addSupportRequestFunc;

hint "Arty initialized";

This is working in Editor, SinglePlayer and On the IngameServer, taht is started form the multiplayer menu with the "new" button. Nut it is not working on a dedicated server. Then the socom will not get initialized. Last hint is "Init starting...". So maby im still doing somethig wrong for a Dedicated Server!??

Edit:
Now iv tried this:


// creating SOM
_group = createGroup sideLogic;
"SecOpManager" createUnit [position P1, _group, "socom = this"];//<---Working in editor, singleplayer, IngameServer
//socom = "SecOpManager" createVehicleLocal getPos P1;// <---not working
socom synchronizeObjectsAdd [P1];

P1 is the name of the Player in the Editor. Now the SOM will be initialized on the dedicated server, and provides Missions! But still no ComMenu-Entrys for calling support :)

It is nesecary to call the BIS_SOM_addSupportRequestFunc again if you have fired the barrage once!

MattXR
Jun 12 2009, 15:01
Doesnt work on a dedicated but that could be fixed by next patch as someguy just said soo wait and see best bet! only a week and a bit to go

McGlazd
Jun 14 2009, 07:36
DnA sayed that there are issues with the com-menue in MP and that this will be fixed with the next patch. I realy hope so :) Maby we should wait till then. If there is a code problem with it, we can test as much as we want and wount get real results. Think this patch should be released at 19th June!?!?!? Dount want to give bad informations in the early morning, so im not shure.

Where ist the editingguid :rolleyes: ...

So a question abaout your script. You have created the SOM with:

_socom = "SecOpManager" createVehicle (position player);

But this is still local namespace. isnt it? the "_" means you creat a local variable. this is only held by the system as long the script is being executed. Maby im wrong. But i think you have to creat it in global namespace... !? so without "_" Like the variable "player" is a global variable.

The "_" is only a convention. It doesn't force this variable to be local. Actually, in this script _socom is the name of the created object. Not the object itself.

Thank you for your remarks in your second post. I was blocked to the same point. I don't feel alone anymore ;)

lawndartleo
Jan 11 2010, 04:57
Am I to understand that SOM is still porked in MP and that is why it generates a single mission for myself and the players joining my (non dedicated) server?