We'll use the CBA event system: http://dev-heaven.net/docs/cba/files...Event-sqf.html . This provides a nice way to solve these MP message sending.
On the server we register an event for a new mission. Whenever any player uses the action we trigger the event. Your init.sqf is almost unchanged, with only a small addition at the top. I also added a few comments:
PHP Code:
//Keep all the mission handling serverside
if (isServer) then {
//Add the new mission request handling
["new_mission", {
//Just pick a random mission
[] call SHK_addmission;
}] call CBA_fnc_addEventHandler;
//The new mission script (function)
SHK_addmission = {
if (isServer) then {
if (count SHK_missions == 0) then {
player sideChat "Opps Sorry But I have no Intel for you come back next week";
} else {
_this spawn {
private ["_t1","_missionName"];
if (count _this > 0) then {
_t1 = _this select 0;
} else {
_t1 = SHK_missions select (floor random count SHK_missions);
};
SHK_missions = SHK_missions - [_t1];
_missionName = format ["missions\%1.sqf", _t1+1];
[] execVM _missionName;
};
};
};
};
//Generate the mission list and select a first mission
private ["_selectedmission"];
//Do you use this elsewhere ? Else you can '_' before it!
missionCount = 4 ; //paramsarray select 4;
_selectedmission = paramsarray select 5;
if (isServer) then {
private ["_temp1","_t1"];
_temp1 = [0,1,2,3];
SHK_missions = [];
for "_i" from 0 to (missionCount - 1) do {
_t1 = _temp1 select (floor random count _temp1);
SHK_missions set [_i,_t1];
_temp1 = _temp1 - [_t1];
};
// first task
if (_selectedmission < 99) then {
[_selectedmission] call SHK_addmission;
} else {
[] call SHK_addmission;
};
};
};
We register the 'newmission' event, and when that is triggered we call the SHK_addmission to select a new mission. When you want this event to trigger you call it like this:
PHP Code:
//Why not *_remoteEvent ? - Well the player might also be a server, a hosted server
["new_mission", []] call CBA_fnc_globalEvent;
And that's it.
You can also use event like this to remove the action instead of the trigger solution in the other thread. In your init (not in a isServer check !!!) do this, (assumed your CIV is named MyCiv and you saved the action in MyCivAction):
PHP Code:
["remove_action", {
if (!isNil "MyCivAction") then {
MyCiv removeAction MyCivAction;
MyCivAction = nil;
};
}] call CBA_fnc_addEventHandler;
Then your action sqf might look like this in total:
PHP Code:
//Remove the action
["remove_action", []] call CBA_fnc_globalEvent;
//Why not *_removeEvent ? - Well the player might also be a server, a hosted server
["new_mission", []] call CBA_fnc_globalEvent;
And you can add another event to tell players to put the action back on, and activate that from the server:
PHP Code:
["add_action", {
if (isNil "MyCivAction") then {
MyCivAction = MyCiv addAction ["MyActionName", "MyScript.sqf"];
};
}] call CBA_fnc_addEventHandler;
I only tested the first part - the new mission part, and not the remove/add-Action parts. However, unless there is a typo, it should work.