How do i remove items (e.g. Matchbox)

Discussion in 'Scripting Discussions' started by Mamu1234, Apr 21, 2013.

  1. Mamu1234

    Mamu1234 Member

    Joined:
    Jan 2, 2013
    Messages:
    84
    Likes Received:
    24
    Simple Question :

    How do i remove items like Flashlight, Map, Toolbox etc. via script if some does a specific action ?

    "removeItem" does not work and on the official BIS wiki i get only "removeWeapon" / "removeMagazine" etc.

    Any ideas ?
     
  2. Sarge

    Sarge OpenDayZ Guru! Staff Member

    Joined:
    Feb 25, 2013
    Messages:
    1,003
    Likes Received:
    206
    you need to use removemagazine.
     
  3. Mamu1234

    Mamu1234 Member

    Joined:
    Jan 2, 2013
    Messages:
    84
    Likes Received:
    24
    Have used that and it didn´t work. I´m trying to remove the matchbox from the inventory. And ItemMatchbox is defined as an item, not a magazine. Guess this is why it doesn´t work.

    The ItemMatchbox has ItemCore defined in dayz_equip as it´s parent and ItemCore refers to an external class.....

    Here is the code-snippet :

    Code:
    if (_chance < 50) then {
                            player removeMagazine "ItemMatchbox";
                            cutText ["Text" , "PLAIN DOWN"];};
     
  4. Sarge

    Sarge OpenDayZ Guru! Staff Member

    Joined:
    Feb 25, 2013
    Messages:
    1,003
    Likes Received:
    206
    Code:
        _unit removeweapon "ItemMap";
        _unit removeweapon "ItemCompass";
        _unit removeweapon "ItemRadio";   
    
    thats what i use for map/compass etc. Try if that works for matches - if the parent class is Itemcore, it should work.

    I assume you are running your code on the client ?
     
  5. Mamu1234

    Mamu1234 Member

    Joined:
    Jan 2, 2013
    Messages:
    84
    Likes Received:
    24
    Confirmed, its working. Thank you Sarge. I´ve seen this yesterday but haven´t had the chance to test it, but now it´s working.

    For anyone who is maybe interested :

    I´ve added a chance of failure for the creation of a campfire. Here is the code of my player_makefire.sqf (located in dayz_code\actions)

    Code:
    private["_location","_isOk","_dir","_classname"];
    _location = player modeltoworld [0,0.3,0];
    if ((_location select 2) < 0) then {
        _location set [2,0];
    };
    //_location set [2,0];
    _isOk = true; //count (_location isFlatEmpty [0.3,0,0,4,0,false,player]) > 0;
    _hasWood =        "PartWoodPile" in magazines player;
    _chance = floor(random 100);
     
    if (_hasWood) then {
        if (_isOk) then {
                _dir = getDir player;
                _classname = "Land_Fire_DZ";
                player playActionNow "Medic";
                sleep 6;
                    if (_chance > 40) then {   
                        player removeMagazine "PartWoodPile";
                        dayz_hasFire = createVehicle [_classname, _location, [], 0, "CAN_COLLIDE"];
                        dayz_hasFire setDir _dir;
                        player reveal dayz_hasFire;
                        cutText [localize "str_fireplace_01", "PLAIN DOWN"];
                        _id = _fire spawn player_fireMonitor;
                    } else {
                        if (_chance < 15) then {
                            player removeWeapon "ItemMatchbox";
                            cutText ["The attempt to ignite the fire fails. The matches are no longer usable." , "PLAIN DOWN"];
                        } else {
                            cutText ["The match breaks. You are not able to ignite the fire." , "PLAIN DOWN"];
                        };
                    };
        } else {
            cutText [localize "str_fireplace_02", "PLAIN DOWN"];
        };
    } else {
        cutText [localize "str_player_22", "PLAIN DOWN"];
    };
    Now there is a chance of 40% that the match breaks and a chance of 15% that the matches are completely destroyed.
    Due to the current functionality of the script i had no idea how to solve this in a different way. If someone thinks he has a better way, feel free to modify the script.

    Due to the fact that i´m playing on my own heavily modified server, i can not give you any support on how to put the script in your specific server / mission file. There a serveral ways / tutorials on how to implementing something like this here at open-dayz. Please have a look around.
     

Share This Page