Die Credits für dieses Script gehen an moeck. Ich habe lediglich meinen Testserver zur Verfügung gestellt, mit ihm rumprobiert und schreibe das alles für euch auf.
Version: Altis Life 5.0
Schwierigkeitsgrad: 2 (eventuell 1 aber ein bisschen Verständnis wäre nicht verkehrt)
Was es tut:
Bei Tod des Spielers werden alle V-, I-Items, ausgenommen Kleidung, und das Geld in eine graue Kiste gelegt. Jeder kann über I (aufs I-Inventar) und T (auf die V Items und Geld) zugreifen. Nach 3 Minuten (kann umgestellt werden) verscheindet die Kiste. Wird der Spieler wiederbelebt behält er seine Kleidung, alles andere findet er dann in der Kiste wieder.
Legen wir los!
Schritt 1:
Im Pfad /core/functions/fn_dropItem.sqf ersetzt ihr den gesamten Inhalt hiermit:
#include "..\..\script_macros.hpp"
/*
File: fn_dropItems.sqf
Author: moeck
Description:
Called on death, Player drops any 'virtual' items and items. They are stored in a plastic case.
*/
params [
["_unit",objNull,[objNull]]
];
private _restricted_items = LIFE_SETTINGS(getArray,"drop_restricted_vitems");
private _pos = _unit modelToWorld[0,3,0];
_pos = [(_pos select 0),(_pos select 1),0];
private _obj = "Land_PlasticCase_01_small_F" createVehicle _pos; //Solltet ihr ein anderes Objekt wollen, den Classname in allen für diese Funktion benötigten Scripts ändern.
clearWeaponCargoGlobal _obj;
clearItemCargoGlobal _obj;
clearMagazineCargoGlobal _obj;
clearBackpackCargoGlobal _obj;
_name = format ["%1's Lootbox",name _unit];
_obj setVariable ["Name",_name,true]; // %1 bewirkt die Anzeige des Namens des verstorbenen Spielers an, so dass ihr das "'s Lootbox" ändern könnt falls gewünscht.
private _trunk =[];
private _weight = 0;
{
private _value = 0;
private _iweight = 0;
private _itemName= "";
private _item = "";
if (_x isEqualType "") then {_item = _x;} else {_item = configName _x};
if (_item isEqualTo "life_cash") then {
_value = CASH;
_itemName = "CASH";
_item = "money";
} else {
_value = ITEM_VALUE(_item);
_iweight = (([_item] call life_fnc_itemWeight) * _value);
_itemName = ITEM_VARNAME(_item);
};
_weight = _weight + _iweight;
if (_value > 0 && !(_item in _restricted_items)) then {
_trunk pushBack [_item,_value];
};
missionNamespace setVariable [_itemName,0];
} forEach (("true" configClasses (missionConfigFile >> "VirtualItems")) + ["life_cash"]);
_obj setVariable["Trunk",[_trunk,_weight],true];
if (LIFE_SETTINGS(getNumber,"drop_iitems_onDeath") isEqualTo 1) then {
if (!(uniform _unit isEqualTo "")) then {
{_obj addItemCargoGlobal [_x, 1];_unit removeItem _x} forEach (uniformItems _unit);
};
if (!(backpack _unit isEqualTo "")) then {
{_obj addItemCargoGlobal [_x, 1];_unit removeItem _x} forEach (backpackItems _unit);
};
if (!(vest _unit isEqualTo "")) then {
{_obj addItemCargoGlobal [_x, 1];_unit removeItem _x} forEach (vestItems _unit);
};
if (count (primaryWeaponItems _unit) > 0) then {
{_obj addItemCargoGlobal [_x, 1];_unit removeItem _x} forEach (primaryWeaponItems _unit);
};
if (count (handgunItems _unit) > 0) then {
{_obj addItemCargoGlobal [_x, 1];_unit removeItem _x} forEach (handGunItems _unit);
};
if !(primaryWeapon _unit isEqualTo "") then {_obj addItemCargoGlobal [(primaryWeapon _unit), 1]};
if !(handgunWeapon _unit isEqualTo "") then {_obj addItemCargoGlobal [(handgunWeapon _unit), 1]};
removeAllWeapons _unit;
{player removeMagazine _x;} forEach (magazines _unit);
};
[_obj] spawn {
params ["_obj"];
_timer = LIFE_SETTINGS(getNumber,"lootbox_timer");
uisleep (_timer*60);
deleteVehicle _obj
};
Alles anzeigen
Schritt 2:
core/functions/fn_fetchDeadGear.sqf nach (Zeile 14)
das einfügen
und die Zeilen 38 - 64 (die hier)
if !(primaryWeapon _unit isEqualTo "") then {_primitems = primaryWeaponItems _unit;};
if !(handgunWeapon _unit isEqualTo "") then {_handgunItems = handgunItems _unit;};
if !(_uniform isEqualTo "") then {{_uitems pushBack _x; true} count (uniformItems _unit);};
if !(_vest isEqualTo "") then {{_vitems pushBack _x; true} count (vestItems _unit);};
if !(_backpack isEqualTo "") then {{_bitems pushBack _x; true} count (backPackItems _unit);};
if !(primaryWeapon _unit isEqualTo "") then {
_unit selectWeapon (primaryWeapon _unit);
if !(currentMagazine _unit isEqualTo "") then {
_magazines pushBack currentMagazine _unit;
};
};
if !(secondaryWeapon _unit isEqualTo "") then {
_unit selectWeapon (secondaryWeapon _unit);
if !(currentMagazine _unit isEqualTo "") then {
_magazines pushBack currentMagazine _unit;
};
};
if !(handgunWeapon _unit isEqualTo "") then {
_unit selectWeapon (handgunWeapon _unit);
if !(currentMagazine _unit isEqualTo "") then {
_magazines pushBack currentMagazine _unit;
};
};
Alles anzeigen
hiermit ersetzen:
if (_dropItems isEqualTo 0) then {
if !(primaryWeapon _unit isEqualTo "") then {_primitems = primaryWeaponItems _unit;};
if !(handgunWeapon _unit isEqualTo "") then {_handgunItems = handgunItems _unit;};
if !(_uniform isEqualTo "") then {{_uitems pushBack _x; true} count (uniformItems _unit);};
if !(_vest isEqualTo "") then {{_vitems pushBack _x; true} count (vestItems _unit);};
if !(_backpack isEqualTo "") then {{_bitems pushBack _x; true} count (backPackItems _unit);};
if !(primaryWeapon _unit isEqualTo "") then {
_unit selectWeapon (primaryWeapon _unit);
if !(currentMagazine _unit isEqualTo "") then {
_magazines pushBack currentMagazine _unit;
};
};
if !(secondaryWeapon _unit isEqualTo "") then {
_unit selectWeapon (secondaryWeapon _unit);
if !(currentMagazine _unit isEqualTo "") then {
_magazines pushBack currentMagazine _unit;
};
};
if !(handgunWeapon _unit isEqualTo "") then {
_unit selectWeapon (handgunWeapon _unit);
if !(currentMagazine _unit isEqualTo "") then {
_magazines pushBack currentMagazine _unit;
};
};
};
Alles anzeigen
Schritt 3:
In /core/functions/fn_keyHandler.sqf sucht ihr den case 20, also den T Key und erweitert
_list = ((ASLtoATL (getPosASL player)) nearEntities [["Box_IND_Grenades_F","B_supplyCrate_F"], 2.5]) select 0;
mit ,"Land_PlasticCase_01_small_F, damit es am Ende so aussieht:
_list = ((ASLtoATL (getPosASL player)) nearEntities [["Box_IND_Grenades_F","B_supplyCrate_F","Land_PlasticCase_01_small_F"], 2.5]) select 0;
Schritt 4:
In der /core/vehicle/fn_openInventory.sqf erweitert ihr die Zeile (bei mir Zeile 12)
if (isNull _vehicle || !(_vehicle isKindOf "Car" || _vehicle isKindOf "Air" || _vehicle isKindOf "Ship" || _vehicle isKindOf "Box_IND_Grenades_F" || _vehicle isKindOf "B_supplyCrate_F")) exitWith {}; //Either a null or invalid vehicle type.
mit || _vehicle isKindOf "Land_PlasticCase_01_small_F",, so dass sie so aussieht:
if (isNull _vehicle || !(_vehicle isKindOf "Car" || _vehicle isKindOf "Air" || _vehicle isKindOf "Ship" || _vehicle isKindOf "Box_IND_Grenades_F" || _vehicle isKindOf "B_supplyCrate_F" || _vehicle isKindOf "Land_PlasticCase_01_small_F")) exitWith {}; //Either a null or invalid vehicle type.
Sucht (Zeile 22)
ctrlSetText[3501,format [(localize "STR_MISC_VehStorage")+ " - %1",getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "displayName")]];
und ersetzt sie mit:
if (_vehicle isKindOf "Land_PlasticCase_01_small_F") then {
ctrlSetText[3501,format [(localize "STR_MISC_VehStorage")+ " - %1",(_vehicle getVariable ["BoxName",""])]];
} else {
ctrlSetText[3501,format [(localize "STR_MISC_VehStorage")+ " - %1",getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "displayName ")]];
};
damit es dann so aussieht:
if (_vehicle isKindOf "Box_IND_Grenades_F" || _vehicle isKindOf "B_supplyCrate_F") then {
ctrlSetText[3501,format [(localize "STR_MISC_HouseStorage")+ " - %1",getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "displayName")]];
} else {
if (_vehicle isKindOf "Land_PlasticCase_01_small_F") then {
ctrlSetText[3501,format [(localize "STR_MISC_VehStorage")+ " - %1",(_vehicle getVariable ["BoxName",""])]];
} else {
ctrlSetText[3501,format [(localize "STR_MISC_VehStorage")+ " - %1",getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "displayName")]];
};
};
am Ende der Datei (bei mir Zeile 55) sucht ihr noch
erweiter sie mit || (_this isKindOf "Land_PlasticCase_01_small_F", damit sie so aussieht:
if ((_this isKindOf "Car") || (_this isKindOf "Air") || (_this isKindOf "Ship") || (_this isKindOf "Land_PlasticCase_01_small_F")) then {
Schritt 5:
In /core/vehicle/fn_vehInventory müsst ihr die Zeile 46
hierzu ändern
Schritt 6:
Im Pfad /config/Config_Vehicles nach der class B_supplyCrate_F einfügen
class Land_PlasticCase_01_small_F {
vItemSpace = 300;
conditions = "";
price = -1;
textures[] = {};
};
Schritt 7:
Jetzt müssen wir für das Geld noch ein vItem anlegen, damit es auch in die Lootbox geht. Dazu in /config/Config_vItems.hpp nach der class storagebig ein Gelditem anlegen
class money {
variable = "money";
displayName = "STR_Item_Money";
weight = 0;
buyPrice = -1;
sellPrice = -1;
illegal = false;
edible = -1;
icon = "icons\ico_money.paa";
};
Schritt 8:
in config/Config_Master.hpp nach drop_weapons_onDeath tragt ihr folgende Sachen ein:
drop_restricted_vitems[]={"apple","peach","tbacon","donuts"}; // V-Items die bei Tod NICHT in die Box gelegt werden sollen und somit gelöscht werden.
lootbox_timer = 3; // //Zeit, bis die Kiste weg ist. Kann durch ändern der 3 (= 3 Minuten) geändert werden.
drop_iitems_onDeath = true; // true = I-Items (Waffen etc.) werden in die Box gelegt, false = I-Items werden nicht in die Box gelegt.
Schritt 9:
In der /stringtable.xml nun noch den Namen hinterlegen, am besten im <Package name="Life_Items">
Geld ist hier übrigens nicht die schönste Wahl, € oder $ oder was auch immer ihr habt ist da besser.
Erweiterung:
Wenn ihr das "TakeAll" Script nutzt ersetzt bitte eure fn_vehTakeAllItem.sqf hiermit. Aber eben nur wenn ihr es wirklich bei euch drin habt, sonst geht nachher noch alles schief
#include "..\..\script_macros.hpp"
#define ctrlSelData(ctrl) (lbData[##ctrl,(lbCurSel ##ctrl)])
/*
File: fn_vehTakeAllItem.sqf
Author: Killerknight
Description:
Take all (max items) from selected and add it to the players inventory
*/
private["_ctrl","_num","_index","_data","_old","_value","_weight","_diff"];
if(!DarfEinzahlen) exitWith {[localize "STR_NOTF_Trunk_Store_Stop",true,"fast","orange","Error"]spawn Life_fnc_msg;};
if(DarfEinzahlen) then {
DarfEinzahlen = false;
[] spawn {
sleep 1;
DarfEinzahlen = true;
};
};
disableSerialization;
_num = 0;
if(isNull Life_trunk_vehicle OR !alive Life_trunk_vehicle) exitWith {[localize "STR_MISC_VehDoesntExist",true,"fast","orange","Error"]spawn Life_fnc_msg;};
if(!alive player) exitwith {closeDialog 0;};
if((lbCurSel 3502) == -1) exitWith {[localize "STR_Global_NoSelection",true,"fast","orange","Error"]spawn Life_fnc_msg;};
_ctrl = ctrlSelData(3502);
_config = configName (missionConfigFile >> "VirtualItems" >> _ctrl);
if (_ctrl isEqualTo "money") then {
_num = ((((Life_trunk_vehicle getVariable "Trunk") select 0) select (lbCurSel 3502)) select 1);
} else {
_num2 = getNumber(missionConfigFile >> "VirtualItems" >> _config >> "weight");
_num1 = (floor (((Life_maxWeight) - (Life_carryWeight)) / _num2));
_num = if (_num1 <= ((((Life_trunk_vehicle getVariable "Trunk") select 0) select (lbCurSel 3502)) select 1)) then {_num1}else{((((Life_trunk_vehicle getVariable "Trunk") select 0) select (lbCurSel 3502)) select 1)};
};
if(_num < 1) exitWith {["Du hast kein Platz dafür.",true,"fast","orange","Error"]spawn Life_fnc_msg;};
_index = [_ctrl,((Life_trunk_vehicle getVariable "Trunk") select 0)] call TON_fnc_index;
_data = (Life_trunk_vehicle getVariable "Trunk") select 0;
_old = Life_trunk_vehicle getVariable "Trunk";
if(_index == -1) exitWith {};
_value = _data select _index select 1;
if(_num > _value) exitWith {[localize "STR_MISC_NotEnough",true,"fast","orange","Error"]spawn Life_fnc_msg;};
_num = [_ctrl,_num,Life_carryWeight,Life_maxWeight] call Life_fnc_calWeightDiff;
if(_num isEqualTo 0) exitWith {[localize "STR_NOTF_InvFull",true,"fast","orange","Error"]spawn Life_fnc_msg;};
_weight = ([_ctrl] call Life_fnc_itemWeight) * _num;
if(_ctrl isEqualTo "money") then {
if !(_num isEqualType 0) then {_num = parseNumber (_num);diag_log format ["parsenumber: %1",_num]; };
if(_num isEqualTo _value) then {
_data set[_index,-1];
_data = _data - [-1];
} else {
_data set[_index,[_ctrl,(_value - _num)]];
};
CASH = CASH + _num;
[0] call SOCK_fnc_updatePartial;
Life_trunk_vehicle setVariable["Trunk",[_data,(_old select 1) - _weight],true];
[Life_trunk_vehicle] call Life_fnc_vehInventory;
} else {
if([true,_ctrl,_num] call Life_fnc_handleInv) then {
if(_num isEqualTo _value) then {
_data set[_index,-1];
_data = _data - [-1];
} else {
_data set[_index,[_ctrl,(_value - _num)]];
};
Life_trunk_vehicle setVariable["Trunk",[_data,(_old select 1) - _weight],true];
[Life_trunk_vehicle] call Life_fnc_vehInventory;
} else {
[localize "STR_NOTF_InvFull",true,"fast","orange","Error"]spawn Life_fnc_msg;
};
};
Alles anzeigen
Wenn ihr nun alles richtig gemacht habt so funktioniert dann auch alles bei euch Sollte es doch nicht so sein gerne hier nach Hilfe fragen.
Wer im übrigen eine Standart Altis Life 5.0 hat kann sogar alle Dateien aus dem Anhang einfach in seine Mission ersetzen. Für alle anderen sind sie aber zum Abgleich auch sehr gut zu nutzen.