Thema: Kisten
Einzelnen Beitrag anzeigen
Alt 12.03.2013, 08:57   #4 (permalink)
Tajin
50 Beiträge100 Beiträge250 Beiträge
 
Benutzerbild von Tajin
 
Registriert seit: 17.01.2008
Beiträge: 267
Standard

Kannst es auch mal hiermit versuchen, da kannst du selber festlegen mit welchen Classnames oder Gegenstandskategorien das Script die Kiste befüllen soll.

PHP-Code:
/*
    Author: Tajin
    File: fillbytype.sqf
    Version: 0.2
    Desc: Fills a box/vehicle with Items of the desired SuperClass
    Syntax: [this,[ #parameters# ] execVM "fillbytype.sqf";
        Replace #parameters# with any of the following:
            Classname only: (this fills in the default number [10] of any type of Pistol)
                "Pistol"
            Classname and amount: (this fills in 5 silenced Rook40 Pistols)
                ["hgun_Rook40_snds_F",5] 
            Classname, amount and Configfile: (this fills in 5 of every type of Backpack)
                ["Bag_Base",5,"CfgVehicles"]
            Multiple selections are also possible:
                ["Pistol",5],["Bag_Base",5,"CfgVehicles"]
        # The script also adds 10 magazines of every available Magazinetype per Weapon #
*/

private ["_cfg","_box","_desired","_inherit","_list","_i","_sel","_arr","_dd","_d","_desire","_dcount","_class","_type","_scope","_object","_mags","_x","_kindof","_icon","_dconfig"];

if(!
isServerexitWith {};
_box _this select 0;
_desired = [];


FNC_kindOf = {
    
_inherit inheritsFrom _this;
    
_list = [configName _this];
    while { (
configName _inherit) != "" } do {
        
_list set[count _list,configName _inherit];    
        
_inherit inheritsFrom_inherit );
    }; 
    
_list
};

switch(
typeName (_this select 1)) do {
    case 
"ARRAY": {
        
_desired _this select 1
        for 
"_i" from 0 to (count _desired)-do {
            
_sel _desired select _i;
            if ( (
typeName _sel) == "STRING" then {
                
_arr = [_sel,10];
                
_desired set[_i,_arr];
            };
        };
        break;
    };
    
    case 
"STRING": {
        
_desired = [[_this select 1,10]];
        break;
    };
};

clearWeaponCargoGlobal _box;
clearMagazineCargoGlobal _box;
clearItemCargoGlobal _box;
clearBackpackCargoGlobal _box;

diag_log format["Starting: %1"_desired];
for 
"_d" from 0 to (count _desired)-do {
    
_dd _desired select _d;
    
_desire _dd select 0;
    
_dcount _dd select 1;
    if (
count _dd 2then {
        
_dconfig _dd select 2
    } else {
        
_dconfig "CfgWeapons"
    };
    
    
_cfg configFile >> _dconfig;    
    
    for 
"_i" from 0 to (count _cfg)-do {
        
_class _cfg select _i;
        if (
isClass _classthen {
            
_type getNumber(_class >> "type");
            
_scope getNumber(_class >> "scope");
            
_icon getText(_class >> "picture");
            if(
_scope == && _type != 65536 && _icon != "\A3\Weapons_F\Data\clear_empty.paa"then {
                
_kindof _class call FNC_kindOf;
                if ( 
_desire in _kindof then {
                    
_object configName _class;
                    
                    switch (
true) do {
                        case (
"Bag_Base" in _kindof): {
                            
_box addBackpackCargo [_object_dcount];
                        };
                        case (
"ItemCore" in _kindof): {
                            
_box addItemCargoGlobal [_object_dcount];
                        };
                        default {
                            
_box addWeaponCargoGlobal [_object_dcount];
                        };
                    };
                    
                    
diag_log format["%1 added (%2)"_object_icon];
                    
                    
_mags getArray(_class >> "magazines");
                    {
                        
_box addMagazineCargoGlobal [_x,_dcount 10];
                        
diag_log format["Magazines %1 added"_x];
                    } forEach 
_mags;
                };
            };
        };
    };
};
diag_log "finished"

Für Uniformen (5 von jeder Sorte) wäre das z.b:
[this,[ ["Uniform_Base",5] ] execVM "fillbytype.sqf";

( Classnames und deren Hierarchie findest du hier: http://browser.six-projects.net/cfg_...67&commit=Save )
__________________

Geändert von Tajin (12.03.2013 um 08:59 Uhr).
Tajin ist offline