Jump to content
Rosso777

Triggers and Hints.. WTF

Recommended Posts

I have been trying for DAYS to get triggers/hints working in my dedicated server (everything works perfectly in the editor, but no triggers/hints on my dedi server). Ideally I would like the player to activate a trigger (making an AI standing there talk in chat with unit globalChat "Hello";) , but even when I spawn an AI in the editor and then add a HINT comment to the activation of each waypoint, nothing.

I don't understand what I am missing. I have scoured several forums for nearly a week, but nothing seems to work. ANY and ALL help is greatly appreciated, as I have simply no idea wtf is wrong.

Here is my test script so you can see what I am looking at; this is the AI walking to different waypoints and then SHOULD either say a HINT or a GLOBALCHAT comment.  He spawns and follows his path, but no text. I have called this file from init, initplayerlocal, and initserver... by using [] execVm "trigger.sqf";    no success.
 

Spoiler


// Init
params [["_layerWhiteList",[],[[]]],["_layerBlacklist",[],[[]]],["_posCenter",[0,0,0],[[]]],["_dir",0,[0]],["_idBlacklist",[],[[]]]];
private _allWhitelisted = _layerWhiteList isEqualTo [];
private _layerRoot = (_allWhitelisted || {true in _layerWhiteList}) && {!(true in _layerBlackList)};


// Markers
private _markers = [];
private _markerIDs = [];


// Groups
private _groups = [];
private _groupIDs = [];

private _item1 = grpNull;
if (_layerRoot) then {
    _item1 = createGroup resistance;
    _this = _item1;
    _groups pushback _this;
    _groupIDs pushback 1;
};


// Objects
private _objects = [];
private _objectIDs = [];

private _item2 = objNull;
if (_layerRoot) then {
    _item2 = _item1 createUnit ["Exile_Unit_Player",[4021.73,5363.2,-3.05176e-005],[],0,"CAN_COLLIDE"];
    _item1 selectLeader _item2;
    _this = _item2;
    _objects pushback _this;
    _objectIDs pushback 2;
    _this setPosWorld [4021.73,5363.25,293.058];
    _this setVectorDirAndUp [[-0.374348,-0.927288,0],[0,0,1]];
    talker = _this;
    _this setVehicleVarName "talker";
    _this setname "Gregor Costas";;
    _this setface "GreekHead_A3_09";;
    _this setspeaker "Male02GRE";;
    _this setpitch 1.03;;
    _this setUnitTrait ['Medic',false];
    _this setUnitTrait ['Engineer',false];
    _this setUnitTrait ['ExplosiveSpecialist',false];
    _this setUnitTrait ['UAVHacker',false];
};


// Triggers
private _triggers = [];
private _triggerIDs = [];

private _item0 = objNull;
if (_layerRoot) then {
    _item0 = createTrigger ["EmptyDetectorArea10x10",[3999.66,5236.21,0],true];
    _this = _item0;
    _triggers pushback _this;
    _triggerIDs pushback 0;
    _item0 setPosATL [3999.66,5236.21,0];
    _this setTriggerArea [5,5,198.688,true,5];
    _this setTriggerActivation ["VEHICLE","PRESENT",false];
    _this setTriggerStatements ["call{this}","call{hint ""this trigger worked!"";}",""];
};


// Group attributes (applied only once group units exist)
_this = _item1;
if !(units _this isEqualTo []) then {
    [_this,0] setWaypointPosition [position leader _this,0];
    [_this, "Alpha 1-1"] call CBA_fnc_setCallsign;
    _this setCombatMode "BLUE";
    _this setBehaviour "CARELESS";
    _this setSpeedMode "LIMITED";
                if (!is3DEN && {!(["","ColorGUER","Alpha 1-1",true] isEqualTo ['','','',true])}) then            {                [_this,["","ColorGUER","Alpha 1-1",true]] spawn                {                    params ['_group','["","ColorGUER","Alpha 1-1",true]'];                    ["","ColorGUER","Alpha 1-1",true] params ['_type','_color','_text','_showGroupSize'];                    private _leader = leader _group;                    private _marker = createMarker                    [                        format ['ENH_GroupMarker_["","ColorGUER","Alpha 1-1",true]',str floor random 10e5],                        _leader                    ];                    _marker setMarkerType _type;                    _marker setMarkerColor _color;                    _marker setMarkerText _text;                    while {true} do                    {                        sleep 1;                        if (units _group isEqualTo []) exitWith {deleteMarker _marker};                        if (_group getVariable ['ENH_GroupMarker_Update',true]) then                        {                            _marker setMarkerPos _leader;                            if (_showGroupSize) then                            {                                _marker setMarkerText format ['["","ColorGUER","Alpha 1-1",true] ()',groupId _group, count units _group];                            };                        };                    };                };            };;
};


// Waypoints
private _waypoints = [];
private _waypointIDs = [];

private _item3 = [];
if (_layerRoot) then {
    _item3 = _item1 addWaypoint [[3956.35,5277.08,0],0];
    _this = _item3;
    _waypoints pushback _this;
    _waypointIDs pushback 3;
    _this setWaypointStatements ["call{true}","call{hint ""Waypoint 1"";}"];
    _this setWaypointType "MOVE";
    _this setWaypointTimeout [30,45,60];
};

private _item4 = [];
if (_layerRoot) then {
    _item4 = _item1 addWaypoint [[4103.43,5270.44,0],0];
    _this = _item4;
    _waypoints pushback _this;
    _waypointIDs pushback 4;
    _this setWaypointStatements ["call{true}","call{hintSilent """";
hint ""Waypoint 2"";}"];
    _this setWaypointType "MOVE";
};

private _item5 = [];
if (_layerRoot) then {
    _item5 = _item1 addWaypoint [[4043.08,5308.32,0],0];
    _this = _item5;
    _waypoints pushback _this;
    _waypointIDs pushback 5;
    _this setWaypointStatements ["call{true}","call{talker globalChat ""This is globalChat."";}"];
    _this setWaypointType "MOVE";
};

private _item6 = [];
if (_layerRoot) then {
    _item6 = _item1 addWaypoint [[3997.52,5236.5,0],0];
    _this = _item6;
    _waypoints pushback _this;
    _waypointIDs pushback 6;
    _this setWaypointStatements ["call{true}","call{talker sideChat ""this is sideChat."";}"];
    _this setWaypointType "MOVE";
    _this setWaypointSpeed "LIMITED";
};


// Logics
private _logics = [];
private _logicIDs = [];


// Connections
if (!isNull _item0 && !isNull _item2) then {_item0 triggerAttachVehicle [_item2];};


// Inits (executed only once all entities exist; isNil used to ensure non-scheduled environment)
isNil {
};


[[_objects,_groups,_triggers,_waypoints,_logics,_markers],[_objectIDs,_groupIDs,_triggerIDs,_waypointIDs,_logicIDs,_markerIDs]]
 

 

Share this post


Link to post
Share on other sites

I didn't know this method... playing with 3den layers and items as in mission.sqm???

 

For 3den, I'm using create3denEntity... Once in mission, I just spawn units...

Anyway, your trigger is "VEHICLE" "PRESENT" but it seems not linked to a vehicle.

Share this post


Link to post
Share on other sites
2 minutes ago, pierremgi said:

I didn't know this method... playing with 3den layers and items as in mission.sqm???

 

For 3den, I'm using create3denEntity... Once in mission, I just spawn units...

Anyway, your trigger is "VEHICLE" "PRESENT" but it seems not linked to a vehicle.

 

Hi Pierre. First of all, you're a legend in my book. I've seen you in these forums and you're a rockstar; I've been reading all your stuff.

This method has been working for me because my server is private and with family only. I have been able to do A LOT because it's just three of us and I can control everything as we play; it's great. But with this trigger, yes, I know it says Vehicle, but this was just the AI testing method; get the AI to walk into the trigger and when he does, hint "this trigger worked!" or something like that.  Nothing has worked. No hints, no waypoint hints, nothing. However, everything I have spawned, including groups, waypoints, AI group settings, loadouts, convoys... it's all perfect. EXCEPT THESE TRIGGERS! UGH! I am going to checkout that create3denEntity now. Thank you. I will update.

Share this post


Link to post
Share on other sites

@pierremgi I am already trying to implement this create3denEntity, but I think it's a bit over my head. Not quite sure what to replace and where. Do you have any examples of ones you've used on a dedicated server? (Note: I have a GTX hosted server... is this the proper usage of dedicated? I am always confused between Dedicated and Server).

Share this post


Link to post
Share on other sites
15 hours ago, pierremgi said:

For 3den, I'm using create3denEntity.

I think he means placed in the editor when he says "but even when I spawn an AI in the editor".

As in, instead of using the script to spawn, instead place and test an editor placed unit.

 

15 hours ago, pierremgi said:

Anyway, your trigger is "VEHICLE" "PRESENT" but it seems not linked to a vehicle.

 

16 hours ago, Rosso777 said:

_item1 = createGroup resistance;

16 hours ago, Rosso777 said:

   _item2 = _item1 createUnit ["Exile_Unit_Player",[4021.73,5363.2,-3.05176e-005],[],0,"CAN_COLLIDE"];

16 hours ago, Rosso777 said:

 _item0 = createTrigger ["EmptyDetectorArea10x10",[3999.66,5236.21,0],true];
    _this setTriggerActivation ["VEHICLE","PRESENT",false];

16 hours ago, Rosso777 said:

if (!isNull _item0 && !isNull _item2) then {_item0 triggerAttachVehicle [_item2];};

Looks like its linked up ok.

 

 

From the looks of several scripts I've seen you post, they all look like editor export to sqf.

You really should learn from what they show you and rewrite them. As is, they are full of unneeded stuff.

 

Your main problem is that if your script runs from initServer.sqf (best place for it imo), of which you said is dedicated, so you need to remoteExec the hint/chats for it to show on the client machines.

Spoiler

//Run from initServer.sqf during your mission using...
//[] execVM "trigger.sqf"

_group = createGroup resistance;

_unit = _group createUnit ["Exile_Unit_Player",[4021.73,5363.25,293.058],[],0,"CAN_COLLIDE"];
_unit setname "Gregor Costas";
_unit setface "GreekHead_A3_09";
_unit setspeaker "Male02GRE";
_unit setpitch 1.03;
_unit setUnitTrait ['Medic',false];
_unit setUnitTrait ['Engineer',false];
_unit setUnitTrait ['ExplosiveSpecialist',false];
_unit setUnitTrait ['UAVHacker',false];

_unit setVehicleVarName "talker";
talker = _unit;

_group selectLeader _unit;

_trig = createTrigger ["EmptyDetectorArea10x10",[3999.66,5236.21,0],false];
_trig setTriggerArea [5,5,198.688,true,5];
_trig setTriggerActivation ["VEHICLE","PRESENT",false];
_trig setTriggerStatements ["this","'this trigger worked!'remoteExec ['hint',[0,-2] select isDedicated]",""];
_trig triggerAttachVehicle [_unit];

[_group, "Alpha 1-1"] call CBA_fnc_setCallsign;
_group setCombatMode "BLUE";
_group setBehaviour "CARELESS";
_group setSpeedMode "LIMITED";

[_group,["","ColorGUER","Alpha 1-1",true]] spawn {
	params ['_group','_markerSettings'];
	_markerSettings params ['_type','_color','_text','_showGroupSize'];

	private _leader = leader _group;
	private _marker = createMarker [ format ["ENH_GroupMarker_%1", floor random 10e5], _leader];
	_marker setMarkerType _type;
	_marker setMarkerColor _color;
	_marker setMarkerText _text;

	while {true} do {
		sleep 1;
		if (units _group isEqualTo []) exitWith {deleteMarker _marker};
		if (_group getVariable ['ENH_GroupMarker_Update',true]) then {
			_marker setMarkerPos _leader;
			if (_showGroupSize) then {
				_marker setMarkerText '["","ColorGUER","Alpha 1-1",true] ()';
			};
		};
	};
};

_wp = _group addWaypoint [[3956.35,5277.08,0],0];
_wp setWaypointStatements ["true","'Waypoint 1' remoteExec['hint',[0,-2] select isDedicated]"];
_wp setWaypointType "MOVE";
_wp setWaypointTimeout [30,45,60];

_wp = _group addWaypoint [[4103.43,5270.44,0],0];
_wp setWaypointStatements ["true","'Waypoint 2' remoteExec['hint',[0,-2] select isDedicated]"];
_wp setWaypointType "MOVE";

_wp = _group addWaypoint [[4043.08,5308.32,0],0];
_wp setWaypointStatements ["true","[talker,'This is globalChat.'] remoteExec['globalChat',[0,-2] select isDedicated]"];
_wp setWaypointType "MOVE";

_wp = _group addWaypoint [[3997.52,5236.5,0],0];
_wp setWaypointStatements ["true","[talker,'this is sideChat.'] remoteExec['sideChat',[0,-2] select isDedicated]"];
_wp setWaypointType "MOVE";
_wp setWaypointSpeed "LIMITED";

Looks a lot cleaner and is basically the same as the code you showed minus all the unneeded things (you can compare it to your original as I have left it mainly in the same order, but with better descriptive variables names). Which makes it so much easier to read

Hopefully correct, as I'm not at my main pc atm, so written in notepad on my htpc sat infront of the tv :ouch:

 

 

  • Like 2

Share this post


Link to post
Share on other sites

Well, I mentioned the create3denEntity which... creates entities while you're in 3den. It's something useful if you're working with codes for 3den (like some tools you would add to the editor (see enhanced 3den or MGI Modules)

If you just want to spawn units or objects during the game, you don't need that. I should ask you: what's your aim?

Scripting for MP needs some good starts.

First of all, on dedicated there is no player (by definition), so player (as command) as no sense.

You must spawn AI units/vehicles on server (preferably, not mentioning headless client which is useless in your case).

You can run on server all codes for these AIs, but it's better to run locally all features for player (as example, personal message or HUDs, or behaviors concerning the player...). Just because you don't need to broadcast such things. It's a waste of bandwidth and net resource. So, don't try all combinations of initPlayerLocal.sqf, init.sqf and initServer.sqf... just think about what you want to obtain, when.

 

You can create a scripted trigger. That's what your script does more or less.

So first, I suggest you to abandon all these "layer" and "item" things in the process you describe, to focus on a simple example:

Let's say you want to create a trigger for a unit (unit1) saying "hello", just "hello", if one player enters its area:

If you want a globalChat, I guess that you want a message displayed on all PCs...

unit1 must be known by all PCs , for course.

The globalChat command is AG EL, so matter where is located the unit (chatting) , but the result is local (where the code is running).

So, in this case, a trigger "not server only" could do the trick as it will run on all PCs:

In init.sqf:   (trigger must be known every where)

 private _trig = createTrigger ["EmptyDetector",[3999.66,5236.21,0] ];
 _trig setTriggerArea [5,5,198,true,5];  // why not make sure the height is OK : 5m is fin.
 _trig setTriggerActivation ["ANYPLAYER","PRESENT",false];
 _trig setTriggerStatements ["this","unit1 globalChat 'hello' ",""];

 

For personal message (first player in area, make it repeatable if you want for other players):
also in init.sqf:
  private _trig = createTrigger ["EmptyDetector",getpos unit1 , false];
  _trig setTriggerArea [5,5,198,true,5];  _trig setTriggerActivation ["ANYPLAYER","PRESENT",false];
  _trig setTriggerStatements ["this","if (local  (thisList #0)) then {unit1 globalChat format ['hello %1', name (thislist #0) ]}",""];

 

 

  • Like 1

Share this post


Link to post
Share on other sites

@Larrow Wow. I don't even know what to say to that post... your knowledge is impressive and I appreciate EVERYTHING you put into it; especially your advice to take what the editor gives me and learn from it. This is something I have been working on lately, as I've printed out and been perusing multiple script tutorial guides.

The fact that you not only took the time to respond with helpful information as well as REWRITE what I was trying to accomplish, I am going to buy you a couple beers, per your signature. Thank you sir. I will take your information and code and learn from it... which should be much easier to do now that I can compare what the editor gave me with what YOU wrote. Simply awesome.

Share this post


Link to post
Share on other sites

@pierremgi  So very helpful, thank you sir. You answered so many questions for me in your post. The way you explained the usage of init and how the first player in a trigger will activate it, and then needing to repeat it for all players afterwards... brilliant. I had no idea how any of that worked. Now I have a great place to start with the information that you and Larrow have both given me.

Share this post


Link to post
Share on other sites

Update: So far, no luck on triggers (or hints for that matter). I have tried several different ways to include what Larrow wrote, and pierremgi suggested. No cheese as of yet. Still working on it, though. We will crack this case!

Share this post


Link to post
Share on other sites

Fixed code in previous post, there was a couple of hidden characters (thought I'd caught them all). Serves me right for using notepad 😄

Do you start Arma with -showScriptErrors enabled ? As it would have picked this up for you and shown you an error.

 

TEST_MISSION - Tested on dedicated with two clients

 

Was not sure what map you where using and I do not have Exile or CBA installed, so the test script in the above mission has had all positions, spawned character swapped for standard I_Soldier_F and few other things commented out and replaced, so its easy for you to go back through and put back the positions needed for your mission. e.g

//_trig = createTrigger ["EmptyDetectorArea10x10",[3999.66,5236.21,0],false];
_trig = createTrigger ["EmptyDetectorArea10x10",[4100,4100,0],false];

just uncomment the first line and delete the second. For all places I have commented out a line.

  • Like 1

Share this post


Link to post
Share on other sites

Currently having some luck using AI waypoints' activation box and adding:

["InfoTitleAndText", ["Pilot", "Roger, en route to your location."]] call ExileClient_gui_toaster_addTemplateToast;

It's clearly an Exile function but it's working and I will take it.

Still no luck with player-activated triggers.

Share this post


Link to post
Share on other sites
1 hour ago, Rosso777 said:

Still no luck with player-activated triggers.

Mind for the position of the trigger (I just changed getpos _this (my test) for getpos unit1, or wherever you want to spawn this trigger).

Share this post


Link to post
Share on other sites
58 minutes ago, pierremgi said:

Mind for the position of the trigger (I just changed getpos _this (my test) for getpos unit1, or wherever you want to spawn this trigger).

 

Going to mess with this later today, thanks Pierre. I am also digging through your Advanced Modules from Steam and... damn man... you're impressive. This is amazing stuff. Hoping I can learn by digging through this and seeing how you did things.

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

×