Hallo zusammen,
ich würde unseren Medics/ADAC'lern gern die Möglichkeit geben Fahrzeuge zu löschen. Hatte auf nem früheren Server schon die Möglichkeit und fand die sehr sinnvoll.
Ich habe als Grundlage (1. Versuch) die impoundAction.sqf als Grundlage hergenommen und abgeändert.
fn_vehicleRemove.sqf
#include "..\..\script_macros.hpp"
/*
File: fn_vehicleRemove.sqf
Author: Bryan "Tonic" Boardwine
Description:
Impounds the vehicle
*/
private ["_vehicle","_type","_time","_value","_vehicleData","_upp","_ui","_progress","_pgText","_cP","_filters","_impoundValue","_price","_impoundMultiplier"];
_vehicle = param [0,objNull,[objNull]];
_filters = ["Car","Air","Ship"];
if (!((KINDOF_ARRAY(_vehicle,_filters)))) exitWith {};
if (player distance cursorObject > 10) exitWith {};
//if (_vehicle getVariable "NPC") exitWith {hint localize "STR_NPC_Protected"};
_vehicleData = _vehicle getVariable ["vehicle_info_owners",[]];
if (_vehicleData isEqualTo 0) exitWith {deleteVehicle _vehicle}; //Bad vehicle.
_vehicleName = FETCH_CONFIG2(getText,"CfgVehicles",(typeOf _vehicle),"displayName");
_price = M_CONFIG(getNumber,"LifeCfgVehicles",(typeOf _vehicle),"price");
[0,"STR_NOTF_BeingImpounded",true,[((_vehicleData select 0) select 1),_vehicleName]] remoteExecCall ["life_fnc_broadcast",RCLIENT];
life_action_inUse = true;
_upp = localize "STR_NOTF_Impounding";
//Setup our progress bar.
disableSerialization;
"progressBar" cutRsc ["life_progress","PLAIN"];
_ui = uiNamespace getVariable "life_progress";
_progress = _ui displayCtrl 38201;
_pgText = _ui displayCtrl 38202;
_pgText ctrlSetText format ["%2 (1%1)...","%",_upp];
_progress progressSetPosition 0.01;
_cP = 0.01;
for "_i" from 0 to 1 step 0 do {
sleep 0.09;
_cP = _cP + 0.01;
_progress progressSetPosition _cP;
_pgText ctrlSetText format ["%3 (%1%2)...",round(_cP * 100),"%",_upp];
if (_cP >= 1) exitWith {};
if (player distance _vehicle > 10) exitWith {};
if (!alive player) exitWith {};
};
"progressBar" cutText ["","PLAIN"];
if (player distance _vehicle > 10) exitWith {hint localize "STR_NOTF_ImpoundingCancelled"; life_action_inUse = false;};
if (!alive player) exitWith {life_action_inUse = false;};
if (count crew _vehicle isEqualTo 0) then {
if (!(KINDOF_ARRAY(_vehicle,_filters))) exitWith {life_action_inUse = false;};
_type = FETCH_CONFIG2(getText,"CfgVehicles",(typeOf _vehicle),"displayName");
life_impound_inuse = true;
[_vehicle,player] remoteExec ["TON_fnc_vehicleDelete",RSERV];
waitUntil {!life_impound_inuse};
} else {
hint localize "STR_NOTF_DeletingCancelled";
};
/*
if (life_HC_isActive) then {
[_vehicle,true,player] remoteExec ["HC_fnc_vehicleDelete",HC_Life];
} else {
[_vehicle,true,player] remoteExec ["TON_fnc_vehicleDelete",RSERV];
};
waitUntil {!life_impound_inuse};
if (playerSide isEqualTo west) then {
_impoundMultiplier = LIFE_SETTINGS(getNumber,"vehicle_cop_impound_multiplier");
_value = _price * _impoundMultiplier;
[0,"STR_NOTF_HasImpounded",true,[profileName,((_vehicleData select 0) select 1),_vehicleName]] remoteExecCall ["life_fnc_broadcast",RCLIENT];
if (_vehicle in life_vehicles) then {
hint format [localize "STR_NOTF_OwnImpounded",[_value] call life_fnc_numberText,_type];
BANK = BANK - _value;
} else {
hint format [localize "STR_NOTF_Impounded",_type,[_value] call life_fnc_numberText];
BANK = BANK + _value;
};
if (BANK < 0) then {BANK = 0;};
[1] call SOCK_fnc_updatePartial;
};
} else {
hint localize "STR_NOTF_ImpoundingCancelled";
};
*/
life_action_inUse = false;
Alles anzeigen
Ich habe die Strings in der Stringtable noch nicht angepasst bzw. Auch der "Entlohnungspart" ist aktuell irrelevant.
Meine Grundlage für das Skript ist meine alte 4.0er Version leider jedoch auf extDB 1.
fn_removeVehicle.sqf
#include <macro.h>
/*
File: fn_removeAction.sqf
Author: Bryan "Tonic" Boardwine
Edited.
Description:
Removes the vehicle
*/
private["_vehicle","_type","_price","_vehicleData","_upp","_ui","_progress","_pgText","_cP","_filters", "_aliveunits"];
_vehicle = [_this,0,ObjNull,[ObjNull]] call BIS_fnc_param;
_filters = ["Car","Air","Ship"];
if(!((KINDOF_ARRAY(_vehicle,_filters)))) exitWith {};
if(player distance cursorTarget > 10) exitWith {};
_vehicleData = _vehicle GVAR ["vehicle_info_owners",[]];
if(count _vehicleData == 0) exitWith {deleteVehicle _vehicle}; //Bad vehicle.
_vehicleName = FETCH_CONFIG2(getText,CONFIG_VEHICLES,(typeOf _vehicle),"displayName");
[[0,"STR_NOTF_BeingDeleted",true,[SEL(SEL(_vehicleData,0),1),_vehicleName]],"life_fnc_broadcast",true,false] call life_fnc_MP;
life_action_inUse = true;
_upp = localize "STR_NOTF_Deleting";
//Setup our progress bar.
disableSerialization;
5 cutRsc ["life_progress","PLAIN"];
_ui = GVAR_UINS "life_progress";
_progress = _ui displayCtrl 38201;
_pgText = _ui displayCtrl 38202;
_pgText ctrlSetText format["%2 (1%1)...","%",_upp];
_progress progressSetPosition 0.01;
_cP = 0.01;
while{true} do {
sleep 0.09;
_cP = _cP + 0.01;
_progress progressSetPosition _cP;
_pgText ctrlSetText format["%3 (%1%2)...",round(_cP * 100),"%",_upp];
if(_cP >= 1) exitWith {};
if(player distance _vehicle > 10) exitWith {};
if(!alive player) exitWith {};
};
5 cutText ["","PLAIN"];
if(player distance _vehicle > 10) exitWith {hint localize "STR_NOTF_DeletingCancelled"; life_action_inUse = false;};
if(!alive player) exitWith {life_action_inUse = false;};
_aliveunits = {(alive _x)} count (crew _vehicle);
if(_aliveunits == 0) then {
if(!(KINDOF_ARRAY(_vehicle,_filters))) exitWith {life_action_inUse = false;};
_type = FETCH_CONFIG2(getText,CONFIG_VEHICLES,(typeOf _vehicle),"displayName");
switch (true) do {
case (_vehicle isKindOf "Car"): {_price = LIFE_SETTINGS(getNumber,"impound_car");};
case (_vehicle isKindOf "Ship"): {_price = LIFE_SETTINGS(getNumber,"impound_boat");};
case (_vehicle isKindOf "Air"): {_price = LIFE_SETTINGS(getNumber,"impound_air");};
};
life_impound_inuse = true;
[[_vehicle,player],"TON_fnc_vehicleRemove",false,false] call life_fnc_MP;
waitUntil {!life_impound_inuse};
hint format[localize "STR_NOTF_Deleted",_type,_price];
[[0,"STR_NOTF_HasDeleted",true,[profileName,SEL(SEL(_vehicleData,0),1),_vehicleName]],"life_fnc_broadcast",true,false] call life_fnc_MP;
ADD(BANK,_price);
} else {
hint localize "STR_NOTF_DeletingCancelled";
};
life_action_inUse = false;
Alles anzeigen
Fahrzeuglöschen wird im Vehicle Interaktionsmenü dargestellt und ist ausgegraut bis das Fahrzeug Schaden hat (anderes Problem). Sobald das Fahrzeug beschädigt ist, kann ich das Fahrzeug "löschen". Der
Fortschrittsbalken wird Ordnungsgemäß angezeigt (abgesehn, davon dass impounden drinsteht). Nur wird das Fahrzeug weder von der Map gelöscht noch in der Datenbank.
Alle Logs sind komplett fehlerfrei! Sowohl extDB 2, als auch Client- bzw RPT-Log.
Gruß
tesafilm95