currently i am creating some trigger based scripts, because i want to get rid of while loops on the server.
While i programmed the scripts i tried find the most efficient way to analyze clientactions. The trigger seemed to be a solution, because these are directly engine integrated and hopefully optimized actions.
I played around with triggers and this sample trigger has been created:
_triggerTimeset setTriggerStatements [
"[thislist] call armajunkies_fnc_aj_TriggerCondition",
//"this",
// Activation
format["[thislist, thisTrigger, '%1',true] spawn armajunkies_fnc_aj_onTerrTriggerStatusChange;conditiontime=time+5; player globalchat 'act'",_name],
// Deactivation
""
];
armajunkies_fnc_aj_TriggerCondition:
_triggerlist = _this select 0;
_active = false;
player globalChat str _thislist;
//TODO Es muss doch eine bessere Lösung geben?
{
if(isplayer _x && alive _x && ((getpos _x) select 2) < 15) then {_active=true;player globalChat "yep";};
} forEach _triggerlist;
player globalChat format["end with %1",_active];
_active
----
Reason for the function: I was not able to check if a playerobject is in the thislist by using in or count for the trigger from a dedicated server.
However: The code showed the impact on my server (the little helper messages). If i have 20 triggers, which i cant optimize in their way to check the condition, than i produce a massive overhead on the cpu.