Jump to content
Djavu

help with addMissionEventHandler

Recommended Posts

Hello Friends. I'm having a problem. I'm using the Killzone Kid script to stream drone images onto a screen. "(I made my adaptations)". On the dedicated server, everyone can view the drone images, but the camera only transmits the image at the point where it was attached, "cam attachTo [uav, [0,0,0]," PiP0_pos "]," (without the quotes) when the shooter's camera is moved, the camera does not move together. But, however, if I'm alone on the server, everything works perfectly. Below is the code I am using:

Calls the addaction for the object in init.sqf

[laptop1, ["<t color=""#33CCFF"">Ligar</t>", {
 { null = execVM "script\uav\not_init.sqf" } remoteExec [ "call" ,0,true]; }, nil , 10 , true , true , "" , "_this distance _target < 2"]
 ] remoteExec ["addaction",-2,true];

not_init.sqf

[],{removeAllActions laptop1;}] remoteExec ["call",0,true];

if (!alive uav) then {["DRONE ABATIDO!"] remoteExec ["hint",0,true]; 
[[],{removeAllActions laptop1;}] remoteExec ["call",0,true];

[laptop1,[0,"img\MapaMundi.jpg"]] remoteExec ["setobjecttextureglobal",0,laptop1];
[monitor5,[0,"img\MapaMundi.jpg"]] remoteExec ["setobjecttextureglobal",0,monitor5];
};
[laptop1,[0,"img\MapaMundi.jpg"]] remoteExec ["setobjecttextureglobal",0,laptop1];
[monitor5,[0,"img\MapaMundi.jpg"]] remoteExec ["setobjecttextureglobal",0,monitor5];

[laptop1, ["<t color='#2bf000'>DRONE RECON</t>",{ { null = execVM "script\uav\drone1\drone1.sqf" } remoteExec [ "call" ,-2,true]; }, nil , 10 , false , true , "" , "_this distance _target < 3"]] remoteExec ["addaction",0,true];

publicVariable "laptop1";
publicVariable "monitor5";

drone1.sqf (The uav is placed in the editor)

[[],{removeAllActions laptop1;}] remoteExec ["call",0,true];
[laptop1, ["<t color='#2bf000'>DESCONECTAR DRONE RECON</t>", { { null = execVM "script\uav\drone1\fechar.sqf" } remoteExec [ "call" ,-2,true]; }, nil , 10 , true , true , "" , "_this distance _target < 3"]] remoteExec ["addaction",0,true];
[laptop1, ["<t color='#2bf000'>USAR CAMERA RECON</t>",{player action ["SwitchToUAVGunner",uav]}, nil , 10 , true , true , "" , "_this distance _target < 3"]] remoteExec ["addaction",0,true];
[laptop1, ["<t color='#2bf000'>PILOTAR DRONE</t>",{player action ["SwitchToUAVDriver",uav]}, nil , 9 , true , true , "" , "_this distance _target < 3"]] remoteExec ["addaction",0,true];

[laptop1,[0, "#(argb,512,512,1)r2t(uavrtt,1)"]] remoteExec ["setobjecttextureglobal",0,true];
[monitor5,[0, "#(argb,512,512,1)r2t(uavrtt,1)"]] remoteExec ["setobjecttextureglobal",0,true];
publicVariable "monitor5";
publicVariable "laptop1";

// Criar a camera
 cam = "camera" camCreate [0,0,0]; 
cam cameraEffect ["external", "Front", "uavrtt"]; 
cam attachTo [uav, [0,0,0], "PiP0_pos"];
publicVariable "uav";

cam camSetFov 0.08;

PublicVariable "cam"; // cam is private?
"uavrtt" setPiPEffect [0];
publicVariable "uav";



addMissionEventHandler ["Draw3D", { _dir = (uav selectionPosition "PiP0_pos") vectorFromTo (uav selectionPosition "PiP0_dir");
 cam setVectorDirAndUp [ _dir, _dir vectorCrossProduct [-(_dir select 1), _dir select 0, 0] ];

 if (!alive uav) then {{nul = execVM "script\uav\not_init2.sqf" } remoteExec ["call",-2,true];};

The event handler

addMissionEventHandler ["Draw3D", { _dir = (uav selectionPosition "PiP0_pos") vectorFromTo (uav selectionPosition "PiP0_dir");
 cam setVectorDirAndUp [ _dir, _dir vectorCrossProduct [-(_dir select 1), _dir select 0, 0] ];

does not seem to work, does not update camera position. if addaction call the script locally to the player, only it will see the image and it works perfectly.

I know that camcreate is local, so addaction calls the script on all players.

Share this post


Link to post
Share on other sites

You don't need to publicVariable edited objects.

It seems to me that you need to create your camera locally and not publicVariable it as well. This way, all players will have a local display but similar to the other guys, not overloading the network.

NOTE: in other situation, I tried to "attach" something to a flying object (ventral backpack to paratrooper). It's hard to make something neat for everyone and I had to use attachTo on each frame (inside the draw3D here). I changed my mind, it's a little bit flickering and resource expensive.

Share this post


Link to post
Share on other sites

What if  ran on the server and streamed to the clients? Something like:

addMissionEventHandler ["Draw3D", { 
 _dir = (uav selectionPosition "PiP0_pos")vectorFromTo (uav selectionPosition "PiP0_dir");
[cam,[ _dir, _dir vectorCrossProduct [-(_dir select 1), _dir select 0, 0] ];] remoteexec ["setVectorDirAndUp",-2,true];

}];

 

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

×