Jump to content
Sign in to follow this  
junky82

addaction to ai in multiplayer runs an introlike camerasequence

Recommended Posts

Hey boys,

 

i've got a real big problem (the perfect start for a scripting noob ;) ).

 

I started creating a multiplayermission in the eden editor, and i got an AI with an addaction on it.

So when all mods are synced, all the player will go to the AI and all can choose the addaction.

But if one of them was clicking on it, the script should run for all players at the same time.

But in my case, it is not just a script like healing or teleporting. This will be a camerascript.

 

I tried a lot of things, and they worked for me, while testing in the editor, but they are not working in multiplayer on the server. They were running just for each player, and the helis are not flying, just standing there in spawnposition.

And one more importend thing, before i post my scripts:

When i add a .sqf file, i will get this error: "Preprocess failed with error - Invalid file name(empty filename)"

Just when i change to .sqs the script will run in editor.

 

Init's of my AI called Opa_1:

(all examples worked in Editor, but not in MP)

 

example 1:

if (isServer) then { intro = this addAction ["Legen wir los.", {Opa_1 exec "script\opaintro.sqf";}, nil, 6, True, True, "", "(_target distance _this) < 6"];}

example 2:

 if (isserver) then {[[Opa_1, ["Legen wir los ...","script\opaintro.sqs"]],"addAction",true,true] call BIS_fnc_MP;}

example 3:

{Opa_1 addAction ["Legen wir los ...","script\opaintro.sqs"];} remoteExec ["bis_fnc_call", 0];

opaintro.sqs/.sqf (i just changed the filename for example 1):

? ((paramsArray select 0) == 0) : goto "del"
_camera = "camera" camcreate [0,0,0]
_camera cameraeffect ["internal", "back"]
showcinemaborder true;

opa_1 switchmove "Acts_B_out2_briefing";
opa_1 removeaction intro;

;comment "20:01:58";
_camera camPrepareTarget [-75303.13,29256.81,5625.25];
_camera camPreparePos [23691.55,16276.09,2.44];
_camera camPrepareFOV 0.324;
_camera camCommitPrepared 0

;comment "20:02:27";
_camera camPrepareTarget [84408.05,-62884.46,-6862.32];
_camera camPreparePos [23692.37,16276.17,2.65];
_camera camPrepareFOV 0.195;
_camera camCommitPrepared 10

~10



aheli1 hideobjectglobal false;
aheli1 enablesimulationglobal true;
aheli2 hideobjectglobal false;
aheli2 enablesimulationglobal true;
aheli3 hideobjectglobal false;
aheli3 enablesimulationglobal true;

playmusic "introbg_1";


;comment "20:19:05";
_camera camPrepareTarget [122550.25,31165.10,2120.64];
_camera camPreparePos [23688.01,16272.10,3.95];
_camera camPrepareFOV 0.696;
_camera camCommitPrepared 0

;comment "20:19:56";
_camera camPrepareTarget aheli2;
_camera camPreparePos [23686.90,16279.11,5.23];
_camera camPrepareFOV 0.033;
_camera camCommitPrepared 10

~10



titleCut ["", "BLACK OUT", 1]
~ 4

player cameraEffect ["terminate","back"]
camDestroy _camera

? ((paramsArray select 0) == 0) : goto "end"
titleCut ["", "BLACK IN", 5]

#end

exit

So the srcipt will execute for the player who hits the addaction, but not for all at the other players (but thats what i want). And the helicopters just will show up for the player which hits addaction.

This opaintro-script is the short one for testing. I've got a bigger one, just with more camera positions an more switchmoves an playmusic.

If needed, i am able to create a link for the missionto download, but i am using mods on this. I hope they are not important for the solution.

 

So please tell me, it's just a simple thing. And please explain your solution. This trial an error took about 8 hour's right now, and i am going crazy on that, because it is not working on the server.

Share this post


Link to post
Share on other sites

Simple problem with complicated solution. The problem is locality. Until you understand how that works stuff like this will be a real pain for you. Addaction is local to the player that uses it meaning the script will run only for him. If things need to happen on the server or other clients you need to make use of 'remoteexec' where it applies.

On my phone right now so cant give examples. Back home in a couple of days...

The second and major problem is that you are using sqs both in your 2nd option of executing the code and also inside the camera script. Sqs is dead so avoid using it. ~ and ? Should not be in the camera script and delete the ; comment lines. U also need ; at the end of each line. Change ~10 to sleep 10; etc. The camera scenes that you are copying are from camera.sqs which is fine but u need to change the format to sqf by doing what i said above.

  • Like 1

Share this post


Link to post
Share on other sites

Thanks for your replies,

 

so i will wait for the code-examples from Azza.

 

While i am waiting, i will convert my script to sqf like you both said.

Thanks Sarogahtyp (had to look twice at the name ;) ) for the link to help converting.

After that i will post my new cam-script-template, and maybe you can have a look at that.

 

After that i will give "remoteexec" a try by myself. Maybe i am faster then Azza ... maybe not ;)

 

And at least, i was wondering why everyone ist postin "execVM" and i need to use "exec" ... now i know.

 

Read you later, junky

Share this post


Link to post
Share on other sites

Your examples are all here:

remoteExec

 

Thanks Sarogahtyp (had to look twice at the name ;) ) for the link to help converting.

Read it backwards or look at my avatar image both helps ;-)

  • Like 1

Share this post


Link to post
Share on other sites

Good news,

 

i converted the *.sqs file and it works ;)

Here ist the init-line i used on my ai (just for local testing):

this addAction ["sqf converted...", { player execVM "script\opaintro.sqf"}];

DO NOT USE THIS ONE!!!CAMERA WONT WORK IN MULTIPLAYER!!!

And this is my new cam-script-template(free to use for everyone):

if (isServer) then {

		_camera = "camera" camcreate [0,0,0];
		_camera cameraeffect ["internal", "back"];
		showcinemaborder true;
		
		opa_1 switchmove "Acts_B_out2_briefing";
		opa_1 removeaction intro;
		
		//camerascene 1
		
		_camera camPrepareTarget [-75303.13,29256.81,5625.25];
		_camera camPreparePos [23691.55,16276.09,2.44];
		_camera camPrepareFOV 0.324;
		_camera camCommitPrepared 0;
		
		_camera camPrepareTarget [84408.05,-62884.46,-6862.32];
		_camera camPreparePos [23692.37,16276.17,2.65];
		_camera camPrepareFOV 0.195;
		_camera camCommitPrepared 10;
		sleep 10;
		
		aheli1 hideobjectglobal false;
		aheli1 enablesimulationglobal true;
		aheli2 hideobjectglobal false;
		aheli2 enablesimulationglobal true;
		aheli3 hideobjectglobal false;
		aheli3 enablesimulationglobal true;
		playmusic "introbg_1";
		
		//camerascene 2
		
		_camera camPrepareTarget [122550.25,31165.10,2120.64];
		_camera camPreparePos [23688.01,16272.10,3.95];
		_camera camPrepareFOV 0.696;
		_camera camCommitPrepared 0;
		
		_camera camPrepareTarget aheli2;
		_camera camPreparePos [23686.90,16279.11,5.23];
		_camera camPrepareFOV 0.033;
		_camera camCommitPrepared 10;
		sleep 10;
		
		titleCut ["", "BLACK OUT", 1];
		sleep 4;
		
		player cameraEffect ["terminate","back"];
		camDestroy _camera;
		
		titleCut ["", "BLACK IN", 5];
		}

I just get an error with "intro". ArmA says that it is a non defined variable. I think i need to define it earlier, maybe in the init.sqf. But maybe i could use the "hideOnUse" parameter within the addaction line.

But ... i've learned a bit, and i was wondering how i could use such an old template for years to create my ArmA 3 videos, and some ingame multiplayer sequences ;) Maybe i did not recognized, there is no sync.

And "had to look twice at the name" means, that i had to read it backwards ;) ...

 

So now i will step forward to the hard lesson ...

thanks for the link again sarogahtyp ... now i will study that thing ;)

And i am still hoping that Azza had an eye on this thread. Thanks so far boys.

 

Read you later, junky

Share this post


Link to post
Share on other sites

i think u forgot

intro =

before your addaction call

  • Like 1

Share this post


Link to post
Share on other sites

So i am back with a good and a bad news ...

The script executes on the server, and my helis are flying. First time i saw that ;) This is the good one ...

This is my init-line on my ai for now:

this addAction ["sqf converted...", { "script\opaintro.sqf" remoteExec ["execVM"];}];

Before i will tell the problem, i will write down my thoughts, why did i do that code.

There ar many examples within the link from sarogahtyp (and you are right with the "intro =") ... but number 1 worked with my first try (green will be copied example #1):

this addAction ["sqf converted...", { "hello" remoteExec ["hint"];}];

So my opinion had been, "hello" is the thing i want to remoteexec, and "hint" is the ?function? (not sure if it is a function), "hello" will be executed with "hint". So i decided to write "script\opaintro.sqf" instead of "hello", and to execute a script i put "execVM" instead of "hint", just because i would normaly write:

this execVM "script\opaintro.sqf";

 

This is not tested in multiplayer, just me on the server (without admin login) ...

 

But now, i've got an other problem.

The helis are flying, but my camera is not working ... so, like i edit in red at my previous post "DO NOT USE THIS ONE!!!CAMERA WONT WORK!!!"

so i need to fix the camera, i think ... and i will do ;)

 

Read you later, junky

Share this post


Link to post
Share on other sites

okay, i read another topic and it says that u cant execute a script with remoteExec. I would do a preprocessed and precompiled function for it then.

you can use this in the init.sqf:

 

fnc_my_function = compileFinal preprocessFile "your.sqf";
then u can use (call or spawn) it where ever u want with:

 

return_value = [param1, param2] call fnc_my_function;
or
[param1, param2] call fnc_my_function;
or
param1 call fnc_my_function;
or
[] call fnc_my_function;

and u can use remote exec then.

Share this post


Link to post
Share on other sites

Hmmm ... i do not know why, but i just deleted the "if (is Server) then {}" part from my cam-script-template... and now it is playing the camera.

This is now confirmed on server ... so one is executing the addaction, and we all see the sequence at the same time ;) i am so happy right now :D

 

so this is my final INIT:

intro = this addAction ["sqf converted...", { "script\opaintro.sqf" remoteExec ["execVM"];}];

cam-script:

		_camera = "camera" camcreate [0,0,0];
		_camera cameraeffect ["internal", "back"];
		showcinemaborder true;
		
		opa_1 switchmove "Acts_B_out2_briefing";
		opa_1 removeaction intro;
		
		//camerascene 1
		
		_camera camPrepareTarget [-75303.13,29256.81,5625.25];
		_camera camPreparePos [23691.55,16276.09,2.44];
		_camera camPrepareFOV 0.324;
		_camera camCommitPrepared 0;
		
		_camera camPrepareTarget [84408.05,-62884.46,-6862.32];
		_camera camPreparePos [23692.37,16276.17,2.65];
		_camera camPrepareFOV 0.195;
		_camera camCommitPrepared 10;
		sleep 10;
		
		aheli1 hideobjectglobal false;
		aheli1 enablesimulationglobal true;
		aheli2 hideobjectglobal false;
		aheli2 enablesimulationglobal true;
		aheli3 hideobjectglobal false;
		aheli3 enablesimulationglobal true;
		playmusic "introbg_1";
		
		//camerascene 2
		
		_camera camPrepareTarget [122550.25,31165.10,2120.64];
		_camera camPreparePos [23688.01,16272.10,3.95];
		_camera camPrepareFOV 0.696;
		_camera camCommitPrepared 0;
		
		_camera camPrepareTarget aheli2;
		_camera camPreparePos [23686.90,16279.11,5.23];
		_camera camPrepareFOV 0.033;
		_camera camCommitPrepared 10;
		sleep 10;
		
		titleCut ["", "BLACK OUT", 1];
		sleep 4;
		
		player cameraEffect ["terminate","back"];
		camDestroy _camera;
		
		titleCut ["", "BLACK IN", 5];
		

i just don't know why the isServer made a problem, i can not explain that for me.

But thanks for helping me that way, i learned a bit ;)

 

Read you at the next lesson for me ...

 

by junky

 

PS: now i will edit my big camscript, and when i got a problem, i will let you know :lol:

Share this post


Link to post
Share on other sites

thats lol that we didnt noticed that "isServer".

The answer why that cant work is locality.

 

effects_local.gif

 

notice that icon on BIki page for your camera commands. It means that the effect has to be executed local.

If u remoteExec ed your script then it is executed by the client but that isServer condition is false on the client and so the if condition is false ur commands r not executed.

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
Sign in to follow this  

×