Jump to content
Sign in to follow this  
zorilya

mission creation via script problem multiplayer

Recommended Posts

I'm using a script to call into existence a group of units and create a task associated with killing them then searching for and collecting intel that spawns on or around their position. problem is that this script creates one for every player. i'm running the script from the mission init file so i don't understand it.

this is the script that i am executing in the init.


_locationslist = nearestLocations [[0,0,0],["NameVillage","NameCity","NameCityCapital","StrongpointArea","NameLocal"],20000];
_randloc = round (random ((count _locationslist) -1));
_location = _locationslist select (if (
					_randloc <= 0) then {0
					} else {
					_randloc
					}
				);

_area = (if (type _location == "NameVillage") then {300} else {200});



sleep 0.1;	

// create the enemy group;

_grpeast = createGroup EAST;

"RU_Commander" createUnit [[0,0,0],_grpeast,"",0.5,"LIEUTENANT"];

for "_i" from 0 to 8 do {(_enemymen select (round (random ((count _enemymen) -1)))) createUnit [[0,0,0],_grpeast];};

{_x setPos (getPos _location);} foreach units _grpeast;

sleep 1;

nul = [(leader _grpeast),_area] execVM 'Garrison_script.sqf';

//create a marker for the rough area to look for the enemy.

_marker = createMarker ["Marker1", position _location];
"Marker1" setMarkerShape "ELLIPSE";
"Marker1" setMarkerBrush "Solid";
"Marker1" setMarkerColor "colorRed";
"Marker1" setMarkerSize [_area,_area];
"Marker1" setMarkerAlpha 0.5; 

//create investigation task

tskobj_1 = player createSimpleTask["Investigate marked location"];
tskobj_1 setSimpleTaskDescription ["Our Intel suggeests this to be the rough enemy location. Proceed to pinpoint the enemy position", "Locate enemy", "Enemy position?"];
tskobj_1 setSimpleTaskDestination (getMarkerPos "Marker1");

//add intel to pickup


sleep 100;
nul = ["rand",nearestBuilding (leader _grpeast),(leader _grpeast)] execVM "intelplacement.sqf";

;

// debug

//player setPos [((getPos _location select 0) + 2),((getPos _location select 1) + 2),(getPos _location select 2)];

;

any ideas?

Share this post


Link to post
Share on other sites

Its because the server and every client run the init.sqf.

Put this at the top of your script and it will only be eun by the server.

If (isServer) exitWith {};

Or even better you can limit it in the init.sqf

If (isServer) then {
     _nul = [] execVM "myscript.sqf";
};

---------- Post added at 02:54 PM ---------- Previous post was at 02:48 PM ----------

Your also going to have to split your code up. For multiplayer scripting you need to try and create all groups of ai on the server and only work with them on the server, all of the the other scripting like tasks and local markers need to be run localy for each client.

You should probaly read this before you go any further and then come back and ask any questions you have on how to implement the ideas on that page.

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

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  

×