#include "..\script_component.hpp"

/*
 * Author: IDSolutions
 * Purchases a vehicle and adds it to the player's garage
 *
 * Arguments:
 * 0: Class Name <STRING> - The classname of the vehicle to purchase
 * 1: Price <NUMBER> - The price of the vehicle
 * 2: Vehicle Type <STRING> - The type of vehicle ("car", "armor", "heli", "plane", "naval", "static")
 *
 * Return Value:
 * None
 *
 * Example:
 * ["B_APC_Tracked_01_rcws_F", 5000, "tank"] call forge_store_fnc_buyVehicle
 *
 * Public: No
 */

params ["_className", "_price", "_vehicleType"];

private _displayName = getText (configFile >> "CfgVehicles" >> _className >> "displayName");
private _garage = GETVAR(player,FORGE_Garage,[]);

if !([_price] call FUNC(handlePurchase)) exitWith {};

_garage pushBack [_vehicleType, _className];

SETPVAR(player,FORGE_Garage,_garage);

[_className, _vehicleType] call EFUNC(arsenal,addGarageVehicle);

[format ["You have purchased %1 for $%2.", _displayName, _price], "info", 3, "right"] call EFUNC(misc,notify);