DMS_Exile/@ExileServer/addons/a3_dms/scripts/fn_SpawnPersistentVehicle.sqf

102 lines
2.2 KiB
Plaintext
Raw Normal View History

/*
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;
Major UI Improvements, Fixes, Improved readme * **NEW CONFIG VALUES**: |DMS_Show_Kill_Poptabs_Notification| |DMS_Show_Kill_Respect_Notification| |DMS_dynamicText_Duration| |DMS_dynamicText_FadeTime| |DMS_dynamicText_Title_Size| |DMS_dynamicText_Title_Font| |DMS_dynamicText_Message_Color| |DMS_dynamicText_Message_Size| |DMS_dynamicText_Message_Font| |DMS_standardHint_Title_Size| |DMS_standardHint_Title_Font| |DMS_standardHint_Message_Color| |DMS_standardHint_Message_Size| |DMS_standardHint_Message_Font| |DMS_textTiles_Duration| |DMS_textTiles_FadeTime| |DMS_textTiles_Title_Size| |DMS_textTiles_Title_Font| |DMS_textTiles_Message_Color| |DMS_textTiles_Message_Size| |DMS_textTiles_Message_Font| * "DMS_PlayerNotificationTypes" has been adjusted to include "systemChatRequest" and the brand new "textTilesRequest". **NOTE:** Due to the way "text tiles" work, a player can only have one on his screen at a time. As a result, if another text tile is created while the mission message is up, the message will immediately disappear to display the new text tile. Currently, the "Frag Messages" (the ones that say "Player Kill +100") use text tiles. I don't think it should be a major issue (especially if you use "systemChatRequest", so the player can just scroll up), but if I get reports of it being stupid, I will default to "dynamicTextRequest", which should also look pretty damn nice. * These changes should make it much easier for people to use DMS notification functions for other purposes. * Fixed AI waypoints - the AI should now properly circle the objective at the proper radius. * Tweaked "DMS_AI_WP_Radius_moderate" and "DMS_AI_WP_Radius_difficult" (reduced the radii). Due to the AI pathing fix. * Fixed a couple typos in "DMS_fnc_SpawnAISoldier". "_customGearSet" should work now (although I'm fairly certain nobody uses it since nobody ever complained :P ) * Improved "DMS_fnc_SpawnNonPersistentVehicle"; Vehicles should no longer spawn jumbled up in most cases (like cardealer). Also, it's updated to the latest Exile methods to ensure that vehicles have no nightvision/thermal if configured to do so in Exile configs. Also added the "MPKilled" EH used by Exile for non-persistent (persistent vehicles already had it). * You can now choose whether or not you want to display the poptabs or respect kill messages when killing an AI with "DMS_Show_Kill_Poptabs_Notification" and "DMS_Show_Kill_Respect_Notification". Both are enabled by default. * Fixed typos in the "OnKilled" EH (didn't really affect anything) * Fixed cases when "currentMuzzle" would return a number. Thanks to [azmodii](https://github.com/azmodii) for the reminder. * Optimized the "AI share info" function in "OnKilled"
2015-10-09 00:16:48 +00:00
// Save vehicle on exit.
_vehObj addEventHandler ["GetOut", { _this call ExileServer_object_vehicle_event_onGetOut}];
// 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