Jump to content
Sign in to follow this  
wiggum2

Markers, triggers and JIP

Recommended Posts

Hmmm ok but in my first example i used CBA_fnc_globalEvent and maked sure the trigger will not fire again but still it did not work...

you can use the onPlayerConnected function to setMarkerPos the markers you wish to have updated to JIP players, this way when the player joins, the markers and their properties are transferred to the player

http://community.bistudio.com/wiki/6thSense.eu:EG#Join_in_Progress

So maybe this should work:

init.sqf:

onplayerConnected {
"ziel1" setMarkerPos (getMarkerPos "ziel1");
};

Share this post


Link to post
Share on other sites

Here's how I would do it all. I've marked the different files I would put the stuff for clear separation of server, client and jip handling:

/*** function.sqf or something: ***/
My_ChangeMarkerColorLocal = {
(_this select 0) setMarkerColorLocal (_this select 1);
};

/*** events\server.sqf: ***/
//Store the marker color change for future JIPs.

// JIP_STORE is an vehicle perhaps the invisible H-pad. We use it to store stuff.

["chg_mrk_col", {
private ["_jipMarkers"];
_jipMarkers = JIP_STORE getVariable ["markers", []];
_jipMarkers set [count _jipMarkers, _this];
JIP_STORE setVariable ["markers", _jipMarkers, true];
}] call CBA_fnc_addEventHandler;

/*** events\client.sqf: ***/
//Update the marker color locally
["chg_mrk_col", My_ChangeMarkerColorLocal] call CBA_fnc_addEventHandler;

/*** init.sqf - amongst the other stuff: ***/

//Load the functions
[] call compile preProcessFile "functions.sqf";

//Setup the event handling
if (isServer) then {
[] call compile preProcessFile "events\server.sqf";
};
if (!isDedicated) then {
   [] call compile preProcessFile "events\client.sqf";	
};

//Run any JIP setup
[] execVM "jip.sqf";


/*** jip.sqf ***/

//If a human player then setup the markers
_markers = JIP_STORE getVariable "markers";
if (!isDedicated && !isNil _markers) then {
{
	_x call My_ChangeMarkerColorLocal;
} forEach _markers;
};

This is untested but I have used this approach without issues. I believe you can only have one onPlayerConnected at any time so I would recommend against using that.

Edited by Muzzleflash

Share this post


Link to post
Share on other sites

Thanks Muzzleflash i will try it out but still hope there is a easier way to do it... ;)

Share this post


Link to post
Share on other sites

I tried what Muzzleflash posted but still no luck.

Maybe the problem is that i use triggers to change the color of the markers ?

But a trigger with condition:

isServer

should not fire for a JIP player...

EDIT:

I mean, CBA_fnc_setMarkerPersistent should be do just that, keeping JIP markers synced...but why is it not working for me ?

Edited by Wiggum

Share this post


Link to post
Share on other sites

Just a quick question...

deleteVehicle this;

inside the ON ACT field of a trigger will delete the trigger for JIP players too ?

Share this post


Link to post
Share on other sites

Depends on whether the condition for the trigger is true before the player connected, If the condition was something like !alive obj and obj is server side then the condition will be true the moment jip connects (i think). If the condition is something like player in thislist, then it probably wont delete it for jip, since the condition was not fulfilled when they connected.

I may be wrong here.

Share this post


Link to post
Share on other sites

So a publicVariable would be best to make triggers JIP safe (keep them from firing again for example) ?

Edited by Wiggum

Share this post


Link to post
Share on other sites

well, if you only care about the trigger firing once, and updating for everyone, why not check if its the server trigger?

this && (isServer || isDedicated)

it would be better yet to create the trigger in a script so that its only created server side.

Share this post


Link to post
Share on other sites

About CBA_fnc_globalExecute:

https://dev-heaven.net/docs/cba/files/network/fnc_globalExecute-sqf.html

What would you use for a hint that everyone (server + clients) should see ?

-2 most likely i think.

[-2, {hint _this}, "TEST"] call CBA_fnc_globalExecute;

But in my testing the server (hosted) get the hint twice so i use -1, but still dont understand why its that way...

Share this post


Link to post
Share on other sites

there is the multiplayer framework that does remote execution of hints on all clients:

[nil,nil,rHINT,"Enjoy the game."] call RE;

Share this post


Link to post
Share on other sites

Oh, i think using a publicVariable is the best way to make triggers JIP safe:

init.sqf:

if (!isnil "trigger1") then {deleteVehicle objTrigger1};

Trigger:

Name:

objTrigger1

Condition:

not alive enemy1

On Act:

hint "objective completed"; trigger1 = true; publicVariable "trigger1";

If a player joins in progress then the trigger will get deleted for him.

Now, two questions:

1st Will the trigger be deleted before any of the ON ACT code is executed ?

2nd Do i need to define the variable trigger1 inside the init.sqf or is trigger1 = true enough to prevent it from being Nil for the JIP player ?

Edited by Wiggum

Share this post


Link to post
Share on other sites

The double execute seems strange, and is not how it is designed. I do wonder if it's a bug in CBA or in how you use it. How do you figure you receive it twice?

Also when you host ingame server, then you are both, Client and Server, so -1 (clients) will reach you, 0 (server) will reach you, and -2 (all) will reach you also.

But, as said more often you should use globalExecute only for debugging, and use CBA_fnc_addEventHandler, globalEvent, localEvent, remoteEvent, and whereIsLocalEvent instead

---------- Post added at 12:46 ---------- Previous post was at 12:29 ----------

I've just tried to confirm your findings of double processing when using -2 but cannot reproduce in ingame server host:

[-2, {diag_log "dude"}] call CBA_fnc_globalExecute

Executed from debug console. e.g str's debug console or pvpscene's devconsole

Writes once "dude" in my rpt file, so perhaps its the triggering that's wrong on your end.

Edited by Sickboy

Share this post


Link to post
Share on other sites

I used a very outdated CBA version, just updated it...maybe this issue was fixed long ago.

Is it really that "bad" to use globalExecute ?

Because it works perfect and is easy to use for me...

Sickboy, can you tell me if my way (post #37) of making triggers JIP safe (keep them from triggering again) is correct ?

Share this post


Link to post
Share on other sites

Well it's up to you, you can either take the easy way, or the right way (which isn't actually hard in this case), it's up to you to decide :)

Share this post


Link to post
Share on other sites

Hi Wiggum,

I'm guessing you are using a Editor placed Trigger, that creates a trigger on each machine that connects to the game.

That trigger, once "not alive enemy1" becomes true, will fire the following code on all connected machines:

hint "objective completed"; trigger1 = true; publicVariable "trigger1";

Meaning, if you have 4 players and a dedicated server, "trigger1" will be publicVariable'd 5 times, at same time...

Will the trigger be deleted before any of the ON ACT code is executed ?

No, probably after.

_neo_

Share this post


Link to post
Share on other sites

Thanks for your help !

So basiclly there is no way to make a editor placed trigger JIP safe ?

Im mean i could use a isServer check in the condition fiel, but is this the only way ?

Share this post


Link to post
Share on other sites

Triggers only execute code after the briefing init process.

If you use CBA, you also have access to Extended_PreInit_EventHandlers and you might be able to delete the trigger before it executes.

http://forums.bistudio.com/showthread.php?p=2087071#post2087071

In any case, I wouldn't use editor placed triggers for these purposes, but I guess it comes down to preference and comfortability.

Share this post


Link to post
Share on other sites
Triggers only execute code after the briefing init process.

If you use CBA, you also have access to Extended_PreInit_EventHandlers and you might be able to delete the trigger before it executes.

http://forums.bistudio.com/showthread.php?p=2087071#post2087071

In any case, I wouldn't use editor placed triggers for these purposes, but I guess it comes down to preference and comfortability.

actually I have had strange occurances where the trigger would activate faster than the init.sqf.

For ex: I was using some triggers to add some units in them into an array of units doing animations and idle talk (T_Units = T_Units + thisList). The variable T_Units was defined in the init.sqf. However, when hinting the variable on the trigger that adds the units into this array, it returned an undefined variable? I then added 1 sec waiting time for the trigger to activate and it corrected itself. Switched to my laptop to continue testing, and it started returning again undefined variable.

Did a radio trigger test after a few seconds to check the variable again, and it returned as an empty array (but was defined).

I know this is offtopic, but I find it strange how the trigger activates faster than the variable is defined - timing issue?

Share this post


Link to post
Share on other sites
So basiclly there is no way to make a editor placed trigger JIP safe ?

What do you mean by "safe"? What do you want the trigger to do? If you're simply using the trigger to set a variable, then you don't need to do anything special and it should work perfectly fine for JIP players (provided that the conditions of the trigger are still true when the JIP player joins).

Share this post


Link to post
Share on other sites
Thanks for your help !

So basiclly there is no way to make a editor placed trigger JIP safe ?

Im mean i could use a isServer check in the condition fiel, but is this the only way ?

Just use isServer if you are too lazy to create triggers/conditions in server only script.

Share this post


Link to post
Share on other sites
actually I have had strange occurances where the trigger would activate faster than the init.sqf.

For ex: I was using some triggers to add some units in them into an array of units doing animations and idle talk (T_Units = T_Units + thisList). The variable T_Units was defined in the init.sqf. However, when hinting the variable on the trigger that adds the units into this array, it returned an undefined variable? I then added 1 sec waiting time for the trigger to activate and it corrected itself. Switched to my laptop to continue testing, and it started returning again undefined variable.

Did a radio trigger test after a few seconds to check the variable again, and it returned as an empty array (but was defined).

I know this is offtopic, but I find it strange how the trigger activates faster than the variable is defined - timing issue?

The triggers should only 'fire' after the briefing (though I would have to re-check to be 100% sure),

but there is no guarantee that init.sqf has finished processing before the user goes from briefing into the mission, especially since arma2's scheduled script execution, but also depending on what statements you execute, or what waitUntils etc ;-)

But that's why you'd use Extended EventHandlers PreInit, it's definitely executed before the triggers, as long as at least 1 unit on the map is officially XEH supported :)

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  

×