Jump to content
Sign in to follow this  
Kickapoo

Problem related to (isServer) and event handler.

Recommended Posts

So essentially what I'm trying to accomplish with this "script" is to make the group_count variable availble to clients so I can broadcast a taskHint and not only broadcast it to the server, if I put the event handler out of the if (isServer) it won't find the _grp as it is local (i assume) and thus it won't display for me nor clients and I don't know if it will work to make it "global" or not, and if I leave it the way it is now the taskHint will display for me (the computer hosting the mission) but not for other clients connected. Honestly too tired of trial and error right now to care to try so I'd like to ask any cunning reader of this thread to assist in any way they can with this.

As I kind of hinted I assume the problem is that the grp_count doesn't update for clients the way it is now, but it will for the one that is the isServer.

Anyone know a workaround for this?

Thanks in advance.

- Kickapoo.

private ["_grp", "_mines"];
grp_count = 0;

if (isServer) then {

_grp = [getMarkerPos "eod1", EAST, (configfile >> "CfgGroups" >> "East" >> "OPF_F" >> "Infantry" >> "OIA_InfTeam")] call BIS_fnc_spawnGroup;

_wp = _grp addWaypoint [getMarkerPos "eod1", 0];
_wp setWaypointType "MOVE";
_wp setWaypointSpeed "LIMITED";
_wp setWaypointBehaviour "SAFE";
_wp setWaypointFormation "LINE";

_wp1 = _grp addWaypoint [getMarkerPos "eod1_wp1", 0];
_wp1 setWaypointType "MOVE";
_wp1 setWaypointSpeed "LIMITED";
_wp1 setWaypointBehaviour "SAFE";
_wp1 setWaypointFormation "LINE";

_wp2 = _grp addWaypoint [getMarkerPos "eod1_wp2", 0];
_wp2 setWaypointType "MOVE";
_wp2 setWaypointSpeed "LIMITED";
_wp2 setWaypointBehaviour "SAFE";
_wp2 setWaypointFormation "LINE";

_wp3 = _grp addWaypoint [getMarkerPos "eod1_wp3", 0];
_wp3 setWaypointType "MOVE";
_wp3 setWaypointSpeed "LIMITED";
_wp3 setWaypointBehaviour "SAFE";
_wp3 setWaypointFormation "LINE";

_wp4 = _grp addWaypoint [getMarkerPos "eod1", 0];
_wp4 setWaypointType "CYCLE";
_wp4 setWaypointSpeed "LIMITED";
_wp4 setWaypointBehaviour "SAFE";
_wp4 setWaypointFormation "LINE";

_mines = createMine ["APERSMine", getMarkerPos "mines1", [], 5];

_mark = createMarker["EOD Marker 1",[3076, 2152]];
"EOD Marker 1" setMarkerText "Suspicious Activity (investigate)";
"EOD Marker 1" setMarkerColor "ColorRed";
"EOD Marker 1" setMarkerType "mil_destroy";

{
  _x addEventHandler ["Killed", {grp_count = grp_count + 1}];
} forEach (units _grp);

};

taskhint ["Task Added\nIntelligence suggests hostile activity in a nearby village, expect minor resistance and possible explosive devices.", [1, 1, 1, 1], "taskNew"];

while {grp_count < 4} do {
if (grp_count > 3) then
{
taskhint ["Task Completed\nEnemy threat(s) eliminated, return to base and await fucking watermelon.", [1, 1, 1, 1], "taskNew"];
deleteMarker "EOD Marker 1";
sleep 30;
_handle = execVM "missions.sqf";
};
};

Share this post


Link to post
Share on other sites

First: your grp_count is a killCount. Second: The if-condition in your while-block is never true.

You may use this condition for determining if all units of the group are dead: {alive _x} count units _grp == 0

And make sure you run this check only on your server by wrapping it in if (isServer) then { ... };

You can use a boolean public variable (e.g. missionComplete = true) to notify the clients that all units are dead and that on each client the task hint should be displayed.

http://community.bistudio.com/wiki/count

http://community.bistudio.com/wiki/publicVariable

http://community.bistudio.com/wiki/addPublicVariableEventHandler

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  

×