Jump to content
cklymowsky

HOW to script which map to select in Arma 3

Recommended Posts

HI All,

 

I would like to add a feature to my multiplayer game for the player to select which map they would like to spawn in, either Tanoa, Altis, Stratis or Malden.

 

Is there a way to do this similar to "class Params" in the description .ext file?

 

class Params
{
	class MapSelection???
	{
		title = "....";
		values[] = {...};
		// When 'texts' are missing, values will be displayed directly instead
		default = ...;
		//file = "setViewDistance.sqf"; // (Optional) Script called when player joins, selected value is passed as an argument
	};
    
    class ViewDistance
	{
		title = "View distance (in metres)";
		values[] = {500,1000,2000,5000};
		// When 'texts' are missing, values will be displayed directly instead
		default = 2000;
		//file = "setViewDistance.sqf"; // (Optional) Script called when player joins, selected value is passed as an argument
	};
	class Daytime
	{
		title = "Time of Day";
		texts[] = {"Dawn", "Morning","Day","Dusk","Evening","Night"};
		values[] = {4,6,12,19,20,0};
		default = 12;
		function = "BIS_fnc_paramDaytime"; // (Optional) Function called when player joins, selected value is passed as an argument
 		isGlobal = 1; // (Optional) 1 to execute script / function locally for every player who joins, 0 to do it only on server
	};
};

 

Share this post


Link to post
Share on other sites

AFAIK, you can only choose the terrain in the mission select screen. If you're in the role assignment screen (where parameters are selected), you've already chosen the terrain.

Share this post


Link to post
Share on other sites
3 hours ago, Harzach said:

AFAIK, you can only choose the terrain in the mission select screen. If you're in the role assignment screen (where parameters are selected), you've already chosen the terrain.

 

Unfortunately this is the only way, next to starting missions from a modded main menu using playMission, if I got that right.

Maybe some finicky campaign workaround could let you end one mission and go straight to a chosen one with the map you want. Doubt this will work fine in MP.

 

Cheers

  • Like 1

Share this post


Link to post
Share on other sites

That's an interesting thought - would it be possible to do a co-op campaign where all missions are unlocked from the start?

Share this post


Link to post
Share on other sites
26 minutes ago, Harzach said:

That's an interesting thought - would it be possible to do a co-op campaign where all missions are unlocked from the start?

I don't see why not, never goofed around with it though.

 

Cheers

Share this post


Link to post
Share on other sites

So I tried the following as an mpmission and it works, but I had to first create a player and place on a map initially, I suppose there is no way around this?

 

description.ext

class Params
{
	class SelectMap 
	{
		title = "Select Map";
		texts[] =  {"Altis", "Stratis","Malden","Tanoa","Random"};
		values[] = {1,2,3,4,5};
		default = 3;
		file = "initServer.sqf"; 
		isGlobal = 1; // (Optional) 1 to execute script / function locally for every player who joins, 0 to do it only on server
	};
};

initServer.sqf

disableSerialization;

_mapValueSelected = "SelectMap" call BIS_fnc_getParamValue;
_mapSelected = switch _mapValueSelected do {
    case 1: {"Altis"};
    case 2: {"Stratis"};
	case 3: {"Malden"};
	case 4: {"Tanoa"};
	case 5: {["Altis", "Stratis", "Malden","Tanoa"] call BIS_fnc_selectRandom};
};

playScriptedMission [
	_mapSelected,
	{
		createCenter west; 
		_mg = createGroup west; 
		_mp = _mg createUnit ['B_Soldier_F',[0,0,0],[],0,'NONE']; 
		selectPlayer _mp; 
		onMapSingleClick 'player setPosATL _pos'; 
		removeAllWeapons player
	}, 
	missionConfigFile, 
	true
];

//Close all displays that could be the background display ... this is essentialy forceEnd command
//Closing #0 will cause game to fail
_zero = findDisplay(0);
{
	if (_x != _zero) then {
		_x closeDisplay 1;
	};
} foreach allDisplays;

failMission "END1";

 

Share this post


Link to post
Share on other sites
33 minutes ago, Grumpy Old Man said:

Seems to be cumbersome, as it requires multiple already set-up servers, if I got that right.

 

Cheers

I remember seeing that, I think it's really only practical for larger communities, most likely of the "Life" variety.

Share this post


Link to post
Share on other sites

I'm not sure if this is the correct way of doing this, please advise...

 

I want to start a MP game so once the players have selected their units and parameters, they press OK the game runs the following functions below and commences. 

 

The current behavior with the scripts below, does this but, I have to press the "CONTINUE" button on the VR map where I've created the initial player for the game.

 

Is there a way to do this without placing a "playable" unit or "player" and skipping the initial "CONTINUE" button on the initially saved map?

 

Also, SHOULD I BE USING class createMission{postInit = 1}; or class createMission{preInit = 1}; ? in description?

 

descrition.ext

Quote

class CfgFunctions
{
	class BEAKS
	{
		class preInit
		{
			file = "functions\preInit";				
			class createMission {};		// SHOULD I BE USING class createMission{postInit = 1}; or class createMission{preInit = 1}; ?
		};
	};
};

class Params
{
	class SelectMap 
	{
		title = "Select Map";
		texts[] =  {"Altis", "Stratis","Malden","Tanoa","Random"};
		values[] = {1,2,3,4,5};
		default = 5;
		file = "initServer.sqf"; 
		isGlobal = 1; // (Optional) 1 to execute script / function locally for every player who joins, 0 to do it only on server
	};
	class Daytime
	{
		title = "Time of Day";
		texts[] = {"Dawn", "Morning","Day","Dusk","Evening","Night"};
		values[] = {4,6,12,19,20,0};
		default = 12;
		function = "BIS_fnc_paramDaytime"; // (Optional) Function called when player joins, selected value is passed as an argument
 		isGlobal = 1; // (Optional) 1 to execute script / function locally for every player who joins, 0 to do it only on server
	};
};

initServer.sqf

Quote


disableSerialization;

_mapValueSelected = "SelectMap" call BIS_fnc_getParamValue;
_mapSelected = switch _mapValueSelected do {
    case 1: {"Altis"};
    case 2: {"Stratis"};
	case 3: {"Malden"};
	case 4: {"Tanoa"};
	case 5: {["Altis", "Stratis", "Malden","Tanoa"] call BIS_fnc_selectRandom};
};

[_mapSelected] call BEAKS_fnc_createMission;

 

 

 

fn_createMission.sqf

Quote

params ["_mapSelected"];

playScriptedMission [
	_mapSelected,
	{	
		_randomPosMapNoWater = [nil, ["water"]] call BIS_fnc_randomPos;
		waitUntil {
			count _randomPosMapNoWater > 0
		};	
		_tower = "Land_Cargo_Tower_V1_No1_F" createVehicle _randomPosMapNoWater;
		createCenter west; 
		_mg = createGroup west; 
		_mp = _mg createUnit ['B_Soldier_F',[0,0,0],[],0,'NONE']; 
		selectPlayer _mp; 
		player setPosATL [(getPosATL _tower) select 0, ((getPosATL _tower) select 1) + 5,0];		
	}, 
	missionConfigFile, 
	true
];



//Close all displays that could be the background display ... this is essentialy forceEnd command
//Closing #0 will cause game to fail
_zero = findDisplay(0);
{
	if (_x != _zero) then {
		_x closeDisplay 1;
	};
} foreach allDisplays;

failMission "END1";

 

 

Share this post


Link to post
Share on other sites

Can someone suggest why the createMission.sqf exits to the main menu and then crashes Arma the second or third time I run it?

 

Which dialog should I not close to return to mission menu?

 

I am trying to select a map or choose randomly before starting a MP game.

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

×