HX3 Foren

HX3 Foren (https://hx3.de/)
-   Editing & Scripting (https://hx3.de/editing-scripting-187/)
-   -   Entwaffnung von toten Spielern (https://hx3.de/editing-scripting-187/entwaffnung-toten-spielern-23663/)

Wolkenbeisser 13.04.2014 21:27

Entwaffnung von toten Spielern
 
Hallo zusammen.

Ich habe nun auch den Weg zu A3 gefunden (habe vorher ziemlich intensiv A2-Missionen gebastelt). Habe es mir schon lange gekauft, aber erst seit kurzem installiert... und schon brauche ich Hilfe... :(

Zur Sache:
Ich verwende zwei Scripts, die zusammen mit der Init.sqf dem Spieler beim Respawn wieder die Vortodesausrüstung geben (Codes siehe weiter unten). Obwohl ich das noch nicht ausgiebig testen konnte waren die ersten zwei, drei Versuche erfolgreich.

Nun möchte ich aber auch einbauen, dass bestimmte Waffen entfernt werden, wenn ein Spieler stirbt. Wenn ich z.B. den Spielern einer 4-Mann Multiplayer Coop nur EIN Scharfschützengewehr zur Verfügung stellen möchte, dann muss dieses bei der Leiche des soeben verstorbenen Spielers gelöscht werden (schliesslich spawnt er ja wieder mit einem solchen - und ich möchte nicht, dass das Scharfschützengewehr dupliziert wird).

Ich habe dazu bisher einen Trigger mit der Bedingung "true", der ein Script wie folgt startet:

Code:

_null = [] execVM "entwaffnung.sqf";
Die entwaffnung.sqf sieht bisher so aus:

Code:

waitUntil {!alive player};
sleep 3.0;
_holders = nearestObjects [getPos player, ["WeaponHolderSimulated", "GroundWeaponHolder", "Default"], _radius];
_holders removeWeaponCargo "arifle_TRG20_F";

Wenn ich es teste (ich bringe mich zuerst selbt um mit einer satchel und switche dann nach ca. 5 Sekunden zu einer anderen Spielbaren Figur um zu sehen, ob die Waffen der Leiche gelöscht wurden), dann wird das Gewehr jedoch nicht gelöscht. Was mache ich falsch?


..............hier übrigens noch die init.sqf und die beiden Scripts, sie sicherstellen sollen, dass der Spieler wieder mit der Vortodesbewaffnung respawnt.

init.sqf
Code:

//////////// --- Missions Briefing --- ////////////
[] execVM "Briefing.sqf";




//////////// --- Verwendung der richtigen Scripts für die Wiederherstellung der Vortodesbewaffnung --- ////////////
waitUntil { !isNull player }; // Wartet bis der Spieler wieder da ist //

// Bewaffnungs-Scripts kompilieren //
getLoadout = compile preprocessFileLineNumbers 'get_loadout.sqf';
setLoadout = compile preprocessFileLineNumbers 'set_loadout.sqf';
                                               
// Ausrüstung alle 2 Sekunden speichern //
[] spawn {
    while{true} do {
        if(alive player) then {
            loadout = [player,["repetitive"]] call getLoadout;
        };
    sleep 2; 
    };
};

// Ausrüstung laden beim Respawn //
player addEventHandler ["Respawn", {
        [player,loadout] spawn setLoadout;
    }
];

get_loadout.sqf
Code:

/*

        AUTHOR: aeroson
        NAME: get_loadout.sqf
        VERSION: 3.4
       
        DOWNLOAD & PARTICIPATE:
        https://github.com/aeroson/a3-loadout
        http://forums.bistudio.com/showthread.php?148577-GET-SET-Loadout-(saves-and-loads-pretty-much-everything)
       
        DESCRIPTION:
        I guarantee backwards compatibility.
        These scripts allows you set/get (load/save) all of the unit's gear, including:
        uniform, vest, backpack, contents of it, all quiped items, all three weapons with their attachments, currently loaded magazines and number of ammo in magazines.
        All this while preserving order of items.
        Useful for saving/loading loadouts.
        Ideal for revive scripts where you have to set exactly the same loadout to newly created unit.
        Uses workaround with placeholders to add vest/backpack items, so items stay where you put them.
       
        PARAMETER(S):
        0 : target unit
        1 : (optional) array of options, default [] :
                "ammo" will save ammo count of partially emptied magazines
                "repetitive" intended for repetitive use, will not use selectWeapon, means no visible effect on solder, but will not save magazines of assigned items such as laser designator batteries
       
        RETURNS:
        Array : array of strings/arrays containing target unit's loadout, to be used by fnc_set_loadout.sqf
       
        addAction support:
        Saves player's loadout into global var loadout

*/

private ["_target","_options","_saveMagsAmmo","_isRepetitive","_isOnFoot","_currentWeapon","_currentMode","_isFlashlightOn","_isIRLaserOn","_magazinesAmmo","_loadedMagazines","_saveWeaponMagazines","_getMagsAmmo","_backPackItems","_assignedItems","_data"];

_options = [];

// addAction support
if(count _this < 4) then {
        #define PARAM_START private ["_PARAM_INDEX"]; _PARAM_INDEX=0;
        #define PARAM_REQ(A) if (count _this <= _PARAM_INDEX) exitWith { systemChat format["required param '%1' not supplied in file:'%2' at line:%3", #A ,__FILE__,__LINE__]; }; A = _this select _PARAM_INDEX; _PARAM_INDEX=_PARAM_INDEX+1;
        #define PARAM(A,B) A = B; if (count _this > _PARAM_INDEX) then { A = _this select _PARAM_INDEX; }; _PARAM_INDEX=_PARAM_INDEX+1;
        PARAM_START
        PARAM_REQ(_target)
        PARAM(_options,[])
} else {
        _target = player;
};
 
_saveMagsAmmo = "ammo" in _options;
_isRepetitive = "repetitive" in _options;
_isOnFoot = vehicle _target == _target;
       
_currentWeapon = "";
_currentMode = "";
_isFlashlightOn = false;
_isIRLaserOn = false;

_magazinesAmmo = magazinesAmmoFull _target;

// save weapon mode and muzzle
if(_isOnFoot) then {
        _currentWeapon = currentMuzzle _target;
        _currentMode = currentWeaponMode _target;
        _isFlashlightOn = _target isFlashlightOn _currentWeapon;
        _isIRLaserOn = _target isIRLaserOn _currentWeapon;
} else {
        _currentWeapon = currentWeapon _target;
};
       

_loadedMagazines=[];

// universal weapon saving
_saveWeaponMagazines = {
        private ["_weapon","_magazines","_muzzles","_saveMagazine"];
        _weapon = _this select 0;
        _magazines = [];       

        _saveMagazine = { // find, save and eat mag for _weapon               
                private ["_weapon","_magazine","_ammo"];
                _weapon = _this select 0;
                _magazine = "";
                _ammo = 0;
                {                       
                        if((_x select 4)==_weapon) then {
                                _magazine = _x select 0;                               
                                _ammo = _x select 1;
                                _x = -1;
                        };
                } forEach _magazinesAmmo;
                _magazinesAmmo = _magazinesAmmo - [-1];       
                if(_magazine!="") then {
                        if(_saveMagsAmmo) then {
                                _magazines set [count _magazines, [_magazine, _ammo]];
                        } else {
                                _magazines set [count _magazines, _magazine];
                        };
                };
        };       

        if(_weapon != "") then {
                [_weapon] call _saveMagazine;
                _muzzles = configFile>>"CfgWeapons">>_weapon>>"muzzles";
                if(isArray(_muzzles)) then {       
                        { // add one mag for each muzzle
                                if (_x != "this") then {                                       
                                        [_x] call _saveMagazine;                       
                                };
                        } forEach getArray(_muzzles);               
                };
        };

        _loadedMagazines set [count _loadedMagazines, _magazines];
};

// save loaded mags for each weapon separetely, since some weapons can use same magazines
[primaryWeapon _target] call _saveWeaponMagazines;
[handgunWeapon _target] call _saveWeaponMagazines;
[secondaryWeapon _target] call _saveWeaponMagazines;

_getMagsAmmo = { // default function with _saveMagsAmmo == false
        _this select 0;
};
if(_saveMagsAmmo) then {
        // check if input array contains magazine, if it does, find it add ammo count
        _getMagsAmmo = {
                private ["_items","_location","_item","_itemIndex"];
                _items = _this select 0;               
                _location = _this select 1;
                {
                        _item = _x;
                        _itemIndex = _forEachIndex;
                        {
                                if((_x select 4)==_location && (_x select 0)==_item) then {
                                        _items set[_itemIndex, [_item, _x select 1]];
                                        _x = -1;                                       
                                };
                        } forEach _magazinesAmmo;
                        _magazinesAmmo = _magazinesAmmo - [-1];       
                } forEach _items;
                _items;
        };
       
};

// get backpack items
_cargo = getbackpackcargo (unitbackpack _target);
_backpacks = [];
{
        for "_i" from 1 to ((_cargo select 1) select _foreachindex) do {
                _backpacks set [count _backpacks, _x];
        };
} foreach (_cargo select 0);       
_backPackItems = (backpackitems _target) + _backpacks;

// get assigned items, headgear and goggles is not part of assignedItems
_assignedItems = assignedItems _target;
_headgear = headgear _target;
_goggles = goggles _target;
if((_headgear != "") && !(_headgear in _assignedItems)) then {
        _assignedItems set [count _assignedItems, _headgear];
};
if((_goggles != "") && !(_goggles in _assignedItems)) then {
        _assignedItems set [count _assignedItems, _goggles];
};



/*
// use this once magazinesAmmoFull is fixed and shows magazines of assignedItems

// get magazines of everything else except weapons, most likely assigned items
// only ["Uniform","Vest","Backpack"] locations remain, weapon locations have already been eaten
_magazines = [];
{       
        if(_x select 2) then {
                if(_saveMagsAmmo) then {
                        _magazines set[count _magazines, [_x select 0, _x select 1]];
                } else {
                        _magazines set[count _magazines, _x select 0];
                };
                _x = -1;
        };
} forEach _magazinesAmmo;
_magazinesAmmo = _magazinesAmmo - [-1];       
_loadedMagazines set [3, _magazines];
*/


// old method using selectWeapon, cycles and tries to selectWeapon all assigned items
if(!_isRepetitive) then {
        private ["_weaponHasChanged"];
        _weaponHasChanged = false;

        // get magazines of all assigned items
        _magazines = [];
        {
                _target selectWeapon _x;
                if(currentWeapon _target==_x) then {
                        _weaponHasChanged = true;
                        _magazine = currentMagazine _target;
                        if(_magazine != "") then {
                                if(_saveMagsAmmo) then {
                                        _magazines set[count _magazines, [_magazine, _target ammo _x]];
                                } else {
                                        _magazines set[count _magazines, _magazine];
                                };
                        };       
                };
        } forEach _assignedItems;
        _loadedMagazines set [3, _magazines];

        // select back originaly selected weapon and mode, only if weapon has changed
        if(_weaponHasChanged) then {
                if(_isOnFoot) then {
                        if(_currentWeapon != "" && _currentMode != "") then {
                                _muzzles = 0;
                                while{ (_currentWeapon != currentMuzzle _target || _currentMode != currentWeaponMode _target ) && _muzzles < 200 } do {
                                        _target action ["SWITCHWEAPON", _target, _target, _muzzles];
                                        _muzzles = _muzzles + 1;
                                };
                                if(_isFlashlightOn) then {
                                        _target action ["GunLightOn"];
                                } else {
                                        _target action ["GunLightOff"];
                                };
                                if(_isIRLaserOn) then {
                                        _target action ["IRLaserOn"];
                                } else {
                                        _target action ["IRLaserOff"];
                                };       
                        };
                } else {
                        _currentMode = "";
                };
                if(_currentMode == "") then {
                        if(_currentWeapon=="") then {
                                _target action ["SWITCHWEAPON", _target, _target, 0];                       
                        } else {
                                _target selectWeapon _currentWeapon;
                        };
                };
        };
};

 
_data = [
        _assignedItems, //0 []

        primaryWeapon _target, //1 ""
        primaryWeaponItems _target, //2 []

        handgunWeapon _target, //3 ""
        handgunItems _target, //4 []

        secondaryWeapon _target, //5 ""
        secondaryWeaponItems _target, //6 []

        uniform _target, //7 ""
        [uniformItems _target, "Uniform"] call _getMagsAmmo, //8 ["magazine without ammo count",["magazine with ammo count",30], ....]

        vest _target, //9 ""
        [vestItems _target, "Vest"] call _getMagsAmmo, //10

        backpack _target, //11  ""
        [_backPackItems, "Backpack"] call _getMagsAmmo, //12

        _loadedMagazines, //13 (optional) [[primary mags],[handgun mags],[secondary mags],[other mags]]
        _currentWeapon, //14 (optional) ""
        _currentMode //15 (optional) ""
];

// addAction support
if(count _this < 4) then {
        _data;
} else { 
        loadout = _data;
        //playSound3D ["A3\Sounds_F\sfx\ZoomOut.wav", _target];
};


set_loadout.sqf
Code:

/*

        AUTHOR: aeroson
        NAME: set_loadout.sqf
        VERSION: 4.3
       
        DOWNLOAD & PARTICIPATE:
        https://github.com/aeroson/a3-loadout
        http://forums.bistudio.com/showthread.php?148577-GET-SET-Loadout-(saves-and-loads-pretty-much-everything)
       
        DESCRIPTION:
        I guarantee backwards compatibility.
        These scripts allows you set/get (load/save) all of the unit's gear, including:
        uniform, vest, backpack, contents of it, all quiped items, all three weapons with their attachments, currently loaded magazines and number of ammo in magazines.
        All this while preserving order of items.
        Useful for saving/loading loadouts.
        Ideal for revive scripts where you have to set exactly the same loadout to newly created unit.
        Uses workaround with placeholders to add vest/backpack items, so items stay where you put them.
       
        PARAMETER(S):
        0 : target unit
        1 : array of strings/arrays containing desired target unit's loadout, obtained from get_loadout.sqf
        2 : (optional) array of options, default [] : ["ammo"]  will allow loading of partially emptied magazines, otherwise magazines will be full                 
       
        addAction support:
        Sets player's loadout from global var loadout
 
*/

private ["_target","_options","_loadMagsAmmo","_data","_loadedMagazines","_placeholderCount","_loadBeforeAdd","_add","_outfit","_addWeapon","_addPrimary","_addHandgun","_addSecondary","_addOrder","_currentWeapon","_currentMode"];

_options = [];

// addAction support
if(count _this < 4) then {
        #define PARAM_START private ["_PARAM_INDEX"]; _PARAM_INDEX=0;
        #define PARAM_REQ(A) if (count _this <= _PARAM_INDEX) exitWith { systemChat format["required param '%1' not supplied in file:'%2' at line:%3", #A ,__FILE__,__LINE__]; }; A = _this select _PARAM_INDEX; _PARAM_INDEX=_PARAM_INDEX+1;
        #define PARAM(A,B) A = B; if (count _this > _PARAM_INDEX) then { A = _this select _PARAM_INDEX; }; _PARAM_INDEX=_PARAM_INDEX+1;
        PARAM_START
        PARAM_REQ(_target)
        PARAM_REQ(_data)
        PARAM(_options,[])
} else {
        _target = player;
        _data = loadout;
        //playSound3D ["A3\Sounds_F\sfx\ZoomIn.wav", _target];
};

if(isNil{_data}) exitWith {
        systemChat "you are trying to set/load empty loadout";
};
if(count _data < 13) exitWith {
        systemChat "you are trying to set/load corrupted loadout";
};

#define QUOTE(A) #A
#define EL(A,B) ((A) select (B))
#define _THIS(A) EL(_this,A)

// placeholders
#define PLACEHOLDER_BACKPACK QUOTE(B_Kitbag_mcamo) // any backpack with capacity>0
#define PLACEHOLDER_ITEM QUOTE(ItemWatch) // addItem placeholder should be smallest item possible

_loadMagsAmmo = "ammo" in _options;
_loadedMagazines = [];
if(count _data > 13) then {
        if(typeName(_data select 13)=="ARRAY") then {
                _loadedMagazines = _data select 13;
        };
};

_currentWeapon = "";
if(count _data > 14) then {
        _currentWeapon = _data select 14;
};
_currentMode = "";
if(count _data > 15) then {
        _currentMode = _data select 15;
};       

_placeholderCount = 0;

// basic add function intended for use with uniform and vest
_add = {
        private ["_target","_item","_callback"];       
        _target = _this select 0;
        _item = _this select 1;
        _callback = _this select 2;
        if(typename _item == "ARRAY") then {
                if(_item select 0 != "") then {
                        if(_loadMagsAmmo) then {
                                _target addMagazine _item;
                        } else {
                                (_item select 0) call _callback;
                        };
                };
        } else {
                if(_item != "") then {
                        _item call _callback;
                };
        };
};

// remove clothes to prevent incorrect mag loading
removeUniform _target;
removeVest _target;
removeBackpack _target;


_outfit = PLACEHOLDER_BACKPACK; // we need to add items somewhere before we can assign them
_target addBackpack _outfit;
clearAllItemsFromBackpack _target;
removeAllAssignedItems _target;
removeHeadgear _target;
removeGoggles _target;

// add loaded magazines of assigned items
if(count _loadedMagazines>=3) then {
        {
                [_target, _x, { _target addItemToBackpack _x }] call _add;
        } forEach (_loadedMagazines select 3);
};

// add assigned items
{
        [_target, _x, { _target addItemToBackpack _x }] call _add;
        _target assignItem _x;
} forEach (_data select 0);

clearAllItemsFromBackpack _target;

// get assigned items, headgear and goggles is not part of assignedItems
private ["_assignedItems","_headgear","_goggles"];
_assignedItems = assignedItems _target;
_headgear = headgear _target;
_goggles = goggles _target;
if((_headgear != "") && !(_headgear in _assignedItems)) then {
        _assignedItems set [count _assignedItems, _headgear];
};
if((_goggles != "") && !(_goggles in _assignedItems)) then {
        _assignedItems set [count _assignedItems, _goggles];
};
// add asigned items that could not be added with assign item
// asuming each assigned item can be put only into one slot
{
        if(!(_x in _assignedItems)) then {
                _target addWeapon _x;
        }
} forEach (_data select 0);



// universal add weapon to hands
_addWeapon = {
        private ["_weapon","_magazines","_muzzles"];
        clearAllItemsFromBackpack _target;
        _target removeWeapon ([] call _THIS(0));
        _weapon = _data select _THIS(1);   
        if(_weapon != "") then {
                if(isClass(configFile>>"CfgWeapons">>_weapon)) then {
                        if (_currentWeapon == "") then {
                                _currentWeapon = _weapon;
                        };
                        if(count _loadedMagazines > 0) then {
                                _magazines = _loadedMagazines select _THIS(5); // get loaded magazines from saved loadout                               
                                if(typename _magazines != "ARRAY") then { // backwards compatibility, make sure _magazines is array
                                        if(_magazines=="") then {
                                                _magazines = [];
                                        } else {
                                                _magazines = [_magazines];
                                        };
                                };
                        } else {         
                                _magazines = [getArray(configFile>>"CfgWeapons">>_weapon>>"magazines") select 0]; // generate weapon magazine
                                _muzzles = configFile>>"CfgWeapons">>_weapon>>"muzzles";
                                if(isArray(_muzzles)) then { // generate magazine for each muzzle       
                                        {
                                                if (_x != "this") then {
                                                        _magazines set [count _magazines, toLower(getArray(configFile>>"CfgWeapons">>_weapon>>_x>>"magazines") select 0)];
                                                };
                                        } forEach getArray(_muzzles);       
                                };
                        };                 
                        {
                                [_target, _x, { _target addItemToBackpack _x }] call _add;
                        } forEach _magazines; // add magazines                                                       
                        _target addWeapon _weapon;                                                                                                               
                        {
                                if(_x!="" && !(_x in ([] call _THIS(3)))) then {
                                        _x call _THIS(4);
                                };
                        } forEach (_data select (1+_THIS(1))); // add weapon items
                } else {
                        systemchat format["%1 %2 doesn't exist",_THIS(2),_weapon];
                        if (_currentWeapon == _weapon) then {
                                _currentWeapon = "";
                                _currentMode = "";
                        };
                };                                                                                                                                                                                                                   
        };
};

// add primary weapon, add primary weapon loaded magazine, add primary weapon items
_addPrimary = {
        [
                { primaryWeapon _target }, // 0 // get current weapon
                1, // 1 //weapon classname index in _data
                "primary", // 2 // weapon debug type
                { primaryWeaponItems _target }, // 3 // weapon items
                { _target addPrimaryWeaponItem _this }, // 4 // add weapon item
                0 // 5 // index in _loadedMagazines
        ] call _addWeapon;
};

// add handgun weapon, add handgun weapon loaded magazine, add handgun weapon items
_addHandgun = {
        [
                { handgunWeapon _target }, // 0 // get current weapon
                3, // 1 //weapon classname index in _data
                "handgun", // 2 // weapon debug type
                { handgunItems _target }, // 3 // weapon items
                { _target addHandgunItem _this }, // 4 // add weapon item
                1 // 5 // index in _loadedMagazines
        ] call _addWeapon;
};
     
// add secondary weapon, add secondary weapon loaded magazine, add secondary weapon items
_addSecondary = {
        [
                { secondaryWeapon _target }, // 0 // get current weapon
                5, // 1 //weapon classname index in _data in _data
                "secondary", // 2 // weapon debug type
                { secondaryWeaponItems _target }, // 3 // weapon items
                { _target addSecondaryWeaponItem _this }, // 4 // add weapon item
                2 // 5 // index in _loadedMagazines
        ] call _addWeapon;
};


// first added weapon is selected weapon, order add functions to firstly add currently selected weapon
_addOrder=[_addPrimary,_addHandgun,_addSecondary];
if(_currentWeapon!="") then {
        _addOrder = switch _currentWeapon do {
                case (_data select 3): {[_addHandgun,_addPrimary,_addSecondary]};
                case (_data select 5): {[_addSecondary,_addPrimary,_addHandgun]};
                default {_addOrder}; 
        };                       
};
{
        [] call _x;
} forEach _addOrder;

// select weapon and firing mode
if(vehicle _target == _target && _currentWeapon != "" && _currentMode != "") then {
        _muzzles = 0;                                                                                                         
        while { (_currentWeapon != currentMuzzle _target || _currentMode != currentWeaponMode _target ) && _muzzles < 100 } do {
                _target action ["SWITCHWEAPON", _target, _target, _muzzles];
                _muzzles = _muzzles + 1;
        };
        if(_muzzles >= 100) then {
                systemchat format["mode %1 for %2 doesn't exist", _currentMode, _currentWeapon];
                _currentMode = "";               
        };
} else {
        _currentMode = "";
};
if(_currentMode == "" && _currentWeapon != "") then {
        _target selectWeapon _currentWeapon;
};

clearAllItemsFromBackpack _target;

// add uniform, add uniform items and fill uniform with item placeholders
_outfit = _data select 7; 
if(_outfit != "") then {
        if(isClass(configFile>>"CfgWeapons">>_outfit)) then {                       
                _target addUniform _outfit;
                _target addItem PLACEHOLDER_ITEM;
                if(loadUniform _target > 0) then {
                        _placeholderCount = _placeholderCount + 1;
                        {
                                [_target, _x, { _target addItemToUniform _x }] call _add;
                        } forEach (_data select 8);                       
                        while{true} do {
                                _loadBeforeAdd = loadUniform _target;
                                _target addItem PLACEHOLDER_ITEM;
                                if(loadUniform _target == _loadBeforeAdd) exitWith {};
                                _placeholderCount = _placeholderCount + 1;                                       
                        };               
                };
        } else {
                systemchat format["uniform %1 doesn't exist",_outfit];
        };               
};

// add vest, add vest items and fill vest with item placeholders
_outfit = _data select 9;
if(_outfit != "") then {
        if(isClass(configFile>>"CfgWeapons">>_outfit)) then {
                _target addVest _outfit;
                _target addItem PLACEHOLDER_ITEM;
                if(loadVest _target > 0) then {
                        _placeholderCount = _placeholderCount + 1;       
                        {
                                [_target, _x, { _target addItemToVest _x }] call _add;
                        } forEach (_data select 10);
                        while{true} do {
                                _loadBeforeAdd = loadVest _target;
                                _target addItem PLACEHOLDER_ITEM;
                                if(loadVest _target == _loadBeforeAdd) exitWith {};
                                _placeholderCount = _placeholderCount + 1;       
                        };                               
                };
        } else {
                systemchat format["vest %1 doesn't exist",_outfit];
        };
};     
 
// add backpack and add backpack items
removeBackpack _target;
_outfit = _data select 11;
if(_outfit != "") then {
        if(getNumber(configFile>>"CfgVehicles">>_outfit>>"isbackpack")==1) then {
                _target addBackpack _outfit;                                                                   
                clearAllItemsFromBackpack _target;
                _target addItem PLACEHOLDER_ITEM;
                _placeholderCount = _placeholderCount + 1;
                if(loadBackpack _target > 0) then {               
                        {
                                [_target, _x, { _target addItemToBackpack _x }] call _add;
                        } forEach (_data select 12);
                };
        } else {
                systemchat format["backpack %1 doesn't exist",_outfit];
        };
};

// remove item placeholders
for "_i" from 1 to _placeholderCount do {
        _target removeItem PLACEHOLDER_ITEM;
};


// make loadout visible fix?
if(vehicle _target == _target) then {
        //_target switchMove (getArray(configFile>>"CfgMovesMaleSdr">>"States">>animationState player>>"ConnectTo") select 0);
        _target setPosATL (getPosATL _target);
};


Vienna 13.04.2014 22:16

Skript zum Entfernen der Waffe. Es ist nur einmal aufzurufen!

Code:

while {true} do
 {
  waitUntil {alive player};
  _holders = player;
  waitUntil {sleep 3; !alive player};
  sleep 3;
  _holders removeWeapon "arifle_TRG20_F"
 }


Wolkenbeisser 14.04.2014 10:42

Liste der Anhänge anzeigen (Anzahl: 1)
Hallo Vienna. Danke für den Code. Leider funktioniert das nicht. Die Leiche meiner respawnten Spielerfigur hat die Waffe immer noch.

Ich habe versucht in Deinem Code removeWeapon mit removeWeaponCargo zu ersetzen. Das geht aber auch nicht. Und auch wenn ich vor dem Tod versucht habe alle an die Waffe angebauten Items abzubauen hat das nichts gebracht.

Machen mir hier vielleicht die Scripts, welche die Vortodesbewaffnung wieder herstellen (siehe mein erster Post) einen Strich durch die Rechnung? Ich denke zwar nicht, aber man weiss ja nie.

Im Anhang übrigens die 'Mission' (ist nur ein Testgebilde) im aktuellen Zustand. Die Einheit mit dem zu entfernenden Gewehr ist die derzeit als 'Spieler' definierte Einheit. Vielleicht hilft das...

Lester 14.04.2014 12:08

Das könnte daran liegen das tote A3 Einheiten ihre aktuelle Waffe von sich werfen.

Via Killed-EH ist man jedoch schnell genug dabei um die aktuelle Waffe zu entfernen, später wird man wohl nur etwas mit Weaponholdersuche in der Nähe der getöteten Unit etwas werden.

Vienna 14.04.2014 12:59

Versuche es einmal so:

Code:

while {true} do
 {
  waitUntil {alive player};
  _unit = player;
  waitUntil {sleep 3; !alive player};
  sleep 3;
  _waffe = nearestObject [_unit, "arifle_TRG20_F"];
  if (not isNull _waffe) then {deleteVehicle _waffe}
 }


Wolkenbeisser 14.04.2014 22:45

Nein, klappt leider auch nicht.

Auch ein weiterer Versuch damit...
Code:

while {true} do
 {
  waitUntil {alive player};
  _unit = player;
  _radius = 20;
  waitUntil {sleep 3; !alive player};
  sleep 3;
  _holders = nearestObjects [getPos _unit, ["WeaponHolderSimulated", "GroundWeaponHolder", "Default"], _radius];
  _holders removeWeaponCargo "arifle_TRG20_F";
 }

...scheiterte.

Es muss doch irgendwie möglich sein den WeaponholderSimulated (wenn es denn einer ist, der da zu Füssen der Leiche gefüllt wird) zu befüllen, bzw. zu leeren. Tut man das als Spieler während dem Spiel klappt der Zugriff ja auch (über die normale Inventar-Funktion). Ich versuche es weiter...

Leider findet man kaum etwas via SuFu Google....:(

Buliwyf 14.04.2014 23:22

Was wirft denn cursortarget aus, wenn man draufschaut?

Vienna 15.04.2014 07:36

Nimm den Vorschlag von Lester auf und schau ob unmittelbar nach dem Kill noch die Waffe beim Toten ist:

player addEventHandler ["killed", {hint str weapons _this select 0}];

Damit werden die Waffen angezeigt.


Oder gleich direkt testen:

player addEventHandler ["killed", {_this select 0 removeWeapon "arifle_TRG20_F"}];

Wolkenbeisser 15.04.2014 10:22

Ja, das funktioniert :daumen:

Und das auch noch ohne Script. Ich gebe den Spielern den Eventhandler einfach via Auslöser, 4 Sek. nach "alive Player".

P.S: Da ich auf diese Weise sowieso nur ein paar wenige Spezialwaffen entferne, fällt das im Kampfgetümmel kaum auf.

Das Ganze muss sich jetzt noch in einem echten Multiplayer-Spiel bewähren, aber ich glaube nicht, dass da noch Probleme auftauchen sollten.

Vielen Dank euch allen. Habt mir sehr geholfen.

Vienna 15.04.2014 13:04

Vielleicht wäre es besser für jeden Spieler nicht erlaubte Waffen festzulegen. So kann man verhindern, dass z.B. einem Mitspieler spezielle Waffen überlassen werden.

Das ist mit einmaligem Aufruf (z.B. in der Initzeile der Spielerfiguren) mit folgendem Skript möglich:

Skript: unerlaubteWaffen.sqf
Code:

//Aufruf: temp = ["Waffe1","Waffe2"] execVM "unerlaubteWaffen.sqf";

while {true} do
 {
  {
  if (player hasWeapon _x) then {player removeWeapon _x}
  } forEach _this;
 sleep 5 
 }


Lester 15.04.2014 14:41

Keine gute Idee, schließlich legt der Spieler immer seine bisherige Waffe üblicherweise automatisch ab, in Verbindung mit nem Leichenlöschscript kann der Spieler dann da ganz schnall mal ohne Waffe dastehen !

Das mit dem Killed-EH funktioniert doch zuverlässig. ;)

Vienna 15.04.2014 17:43

Der EH kann aber nicht verhindern, dass Spieler die Waffen tauschen. Wird getauscht, so gibt es nach dem Respawn zwei Soldaten mit einer besonderen Waffe.

Um das zu verhindern müsste man im EH-Code feststellen ob der Spieler diese Waffe hatte und nur dann beim Respawn eine neue solche zuweisen.

Wolkenbeisser 16.04.2014 08:49

In meinem Fall müsste der EH aber reichen, denke ich.

Wenn zu Beginn nur ein Scha-Schü-Gew. im Spiel ist und Spieler A hat es, dann ist es nach einem Tausch zwar beim Spieler B, aber A hat dann ja das Normalgewehr, welches er beim Respawn auch wieder hat (ich habe es ja so eingerichtet, dass jeder mit der Vortodesbewaffnung respawnt - siehe mein erster Post).


Alle Zeitangaben in WEZ +1. Es ist jetzt 21:28 Uhr.

Angetrieben durch vBulletin, Entwicklung von Philipp Dörner & Tobias


SEO by vBSEO 3.2.0 ©2008, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119