DMS_Exile/@ExileServer/addons/a3_dms/scripts/fn_SpawnPersistentVehicle.sqf
eraser1 829943bf65 mI gramur Iz gUd (new mission, function, and features)
* **NEW CONFIG VALUES**:

|DMS_MarkerText_ShowMissionPrefix|
|DMS_MarkerText_MissionPrefix|
|DMS_MarkerText_ShowAICount|
|DMS_MarkerText_AIName|
* New function: DMS_fnc_SpawnPersistentVehicle. It will spawn
inaccessible vehicles by default and convert VALID pincode inputs to the
proper format.
* New mission: "Car Thieves" (thieves.sqf). It uses the new
DMS_fnc_SpawnPersistentVehicle. When the mission is completed
successfully, the code is displayed in the completion message.
* You can now add a "prefix" to the marker text of each mission.
* You can now display the number of remaining AI in the marker text (it
should update about every 15 seconds).
* Rearranged the missions in the config to look prettier. Don't judge.
* Added the "Zamak", "Tempest", and "HEMMT" to "DMS_TransportTrucks"
array. Removed "Exile_Car_Van_Black"
* "dynamicTextRequest" messages will now appear at the top of the
screen, so it shouldn't distract/block stuff in focus.
* Fixed some spelling, improved some grammar (will require mission
updates, it's really minor though).
2015-10-04 22:27:22 -05:00

103 lines
2.3 KiB
Plaintext

/*
DMS_fnc_SpawnPersistentVehicle
Created by eraser1
Usage:
[
_vehicleClass, // STRING: Vehicle classname to spawn.
_pos, // ARRAY (positionATL or position2d): Where the vehicle will be spawned (strict)
_pinCode // STRING or NUMBER: String has to be 4 digits. Number has to be between 0-9999, and will be automatically formatted.
] call DMS_fnc_SpawnPersistentVehicle;
Returns the created vehicle object.
*/
private ["_vehicleClass", "_pos", "_pinCode", "_vehObj"];
_OK = params
[
["_vehicleClass","",[""]],
["_pos",[],[[]],[2,3]],
["_pinCode","",[0,""]]
];
_vehObj = objNull;
try
{
if (!_OK) then
{
throw (format ["invalid parameters: %1",_this]);
};
if ((count _pos) isEqualTo 2) then
{
_pos set [2,0];
};
if ((typeName _pinCode)=="SCALAR") then
{
if (_pinCode<0 || {_pinCode>9999}) then
{
throw (format ["invalid SCALAR _pinCode value (must be between 0 and 9999): %1",_pinCode]);
};
switch (true) do
{
case (_pinCode<10):
{
_pinCode = format ["000%1",_pinCode];
};
case (_pinCode<100):
{
_pinCode = format ["00%1",_pinCode];
};
case (_pinCode<1000):
{
_pinCode = format ["0%1",_pinCode];
};
default
{
_pinCode = str _pinCode;
};
};
};
if ((count _pinCode)!=4) then
{
throw (format ["invalid STRING _pinCode value (must be 4 digits): %1",_pinCode]);
};
// Create and set the vehicle
_vehObj = [_vehicleClass,_pos] call DMS_fnc_SpawnNonPersistentVehicle;
_vehObj setPosATL _pos;
// Set up EHs
_vehObj addEventHandler ["GetOut", { _this call ExileServer_object_vehicle_event_onGetOut}];
_vehObj addMPEventHandler ["MPKilled", { _this call ExileServer_object_vehicle_event_onMPKilled}];
// Set up vars
_vehObj setVariable ["ExileIsPersistent", true];
_vehObj setVariable ["ExileAccessCode", _pinCode];
_vehObj setVariable ["ExileOwnerUID", "76561198027700602"]; // That is my (eraser1's) PUID. Just so you don't think I'm trying to be sneaky...
// Deny access until specified to do so.
_vehObj setVariable ["ExileIsLocked",-1];
_vehObj setVariable ["ExileLastLockToggleAt", time];
_vehObj setVariable ["ExileAccessDenied", true];
_vehObj setVariable ["ExileAccessDeniedExpiresAt", 999999];
}
catch
{
diag_log format ["DMS ERROR :: Calling DMS_fnc_SpawnPersistentVehicle with %1!",_exception];
};
_vehObj