Spawn a random vehicle with reward hint

genterprize on the BIS forums wanted to know how to spawn a random vehicle as a reward for a PvP team capturing an objective.  Here’s the solution I came up with:

You won a CH-47!

Example Image

Called via a trigger and requires the Multiplayer Framework Module to be present:

nul = ["WEST"] execVM "rewardAircraft.sqf";

Script Text:

// Function file for ArmA 2: Operation Arrowhead
// Created by: kylania

// Array of available aircraft.  Simply add or remove classnames to adjust the available pool.
_westAircraft = ["A10_US_EP1","AH64D_EP1","AH6J_EP1","CH_47F_EP1","MH6J_EP1","UH60M_EP1","UH60M_MEV_EP1"];
_eastAircraft = ["L39_TK_EP1","Mi17_TK_EP1","Mi24_D_TK_EP1","Su25_TK_EP1","UH1H_TK_EP1"];

// Marker where aircraft will spawn.
_spawnPoint = "aircraftSpawn"; 

// Customize hint colors.
_westColor = "#3366FF";
_eastColor = "#B8002E";

// Grab winning side from argument.
_winningSide = _this select 0;

// Prepare variables.
private ["_name","_picture","_reward","_color"];

if (isServer) then {
	// Spawn vehicle and choose hint color based on winning side.
	switch (_winningSide) do {
		case "WEST": {
			_reward = _westAircraft select floor(random count _westAircraft) createVehicle getMarkerPos _spawnPoint;
			_color = _westColor;
		case "EAST": {
			_reward = _eastAircraft select floor(random count _eastAircraft) createVehicle getMarkerPos _spawnPoint;
			_color = _eastColor;

	// Grab friendly name and image of vehicle.
	_name = getText (configFile >> "cfgVehicles" >> typeOf _reward >> "displayName");
	_picture = getText (configFile >> "cfgVehicles" >> typeOf _reward >> "picture");

	// Hint reward.  Thanks to Demonized for the MP fix!
        _text = parseText format[
        "Congrats <t color='%4'>%1</t> Team!<br/> You have been rewarded with an <t color='#FFCC33'>%2</t> for your efforts!<br/>
        <t color='%4'><img size='4' image='%3'/></t>", _winningSide, _name, _picture, _color
        [nil,nil,rHINT,_text] call RE; // Multiplayer Framework required!
}; // end of If
  1. #1 by badger on February 3, 2011 - 9:16 AM

    Cool, just one question:

    Where do you get winning side from? 🙂

    • #2 by kylania on February 8, 2011 - 12:27 PM

      From a trigger most probably. That’s the first part of the code listed. As for how to tell which side, maybe have the script check for none of the other side in the area maybe?

Comments are closed.