Jump to content
Sign in to follow this  
gallexme

Check if already got used one Time

Recommended Posts

What i already got:

The Object:

]class CustomAmmoBox : RUBasicAmmunitionBox{

	scope = 2;
	destrType = "DestructBuilding"; 
	//cost = 100;
	armor = 400;
	offset[] = {0,2.5,1.3};
	displayName = "AmmoBox";
	vehicleClass = "CustomAmmoBox";
	transportMaxMagazines = 500;
	transportMaxWeapons = 500;
	transportMaxBackpacks = 500;
	class TransportMagazines{}; 
       class TransportWeapons{}; 
	class EventHandlers
        {
              init = "(_this select 0) setVariable['opened',false,true]";

        };

};

and coded is:

	if(_isCrate and _cursorTarget getVariable["opened",false] == false and("ItemCrowbar" in _itemsPlayer) and _isAlive) then{
.....AddAction
and then inside of the Added Action(create is the object) _create setVariable["opened",true]

But if(_isCrate and _cursorTarget getVariable["opened",false] == false and("ItemCrowbar" in _itemsPlayer) and _isAlive) then

that part is not working, could someone help me?

Share this post


Link to post
Share on other sites

Please don't be offended but we can't do anything for you if all what you're doing is showing us some variables but not how they're getting their values :D

Expand your script to show us how all the local variables get their values, then we can help you ^^

(PS: It wouldn't hurt to describe the underlying scenario, we know that you want to check if your ammobox got used, but then again why checking the crowbar?^^)

I dont see any errors in your if-structure so I guess it has to do something with how you assign the values.

Share this post


Link to post
Share on other sites

breach_crate.sqf

private ["_box","_item","_config","_create","_qty","_type","_count","_itemTypes","_lootChance","_while_count"];
_qty = 10;
_box = _this select 3;
if (TradeInprogress or ((_box getVariable "opened") == "1") ) exitWith {};
diag_log _box;

TradeInprogress = true;


_config = 		configFile >> "CfgBuildingLoot" >> "MilitarySpecial";
_itemTypes = [] + getArray (_config >> "itemType");
_lootChance =	getNumber (_config >> "lootChance");
_count = -1;
_while_count= (_qty + 2);
diag_log format["Start While:  %1",_while_count];
while { _while_count >0} do
{
cutText [ format["Items:  %1",_while_count], "PLAIN DOWN"];
_while_count = _while_count -1;
_count = _count + 1;
_item = _itemTypes select (random (count itemTypes +1)) ;
_type = _item select 1;
_create = _item select 0;
if(_type == "magazine") then {

_box addMagazineCargoGlobal [_create,round(random _qty)];
cutText [ format["addMagazineCargoGlobal:  %1",_create], "PLAIN DOWN"];
diag_log format["addMagazineCargoGlobal:  %1",_create]; 
};
if(_type == "weapon") then {
_box addWeaponCargoGlobal [_create,round(random _qty)];
cutText [ format["addWeaponCargoGlobal:  %1",_create], "PLAIN DOWN"];
diag_log format["addWeaponCargoGlobal:  %1 + %2",_create,round(random _qty)] ;
};
if(_type == "backpack") then {
_box addBackpackCargoGlobal  [_create,round(random _qty)];
cutText [ format["addBackpackCargoGlobal:  %1",_create], "PLAIN DOWN"];
diag_log format["addBackpackCargoGlobal:  %1",_create];
};
};



_create setVariable["opened",'1',true];
player playActionNow "Medic";
sleep 6;
cutText ["Opened supply crate.", "PLAIN DOWN"];
TradeInprogress = false;
player reveal _box;

selfactions.sqf

_cursorTarget = cursorTarget;
_isCrate = _typeOfCursorTarget in ["CustomAmmoBox","Crate"];
if((_isCrate and (_cursorTarget getVariable "opened") == "0" and("ItemCrowbar" in _itemsPlayer) and _isAlive)) then{
	diag_log("Da wird sie Aktiviert") ;
	if(s_player_opencrate <0) then {
	s_player_opencrate = player addAction [localize "str_open_crate", "\z\addons\dayz_code\actions\breach_crate.sqf",_cursorTarget, 1, true, true, "", ""];

	};
}else{
	diag_log("Da fliegt die Action naus"); 
	player removeAction s_player_opencrate;
	s_player_opencrate = -1;
};



Share this post


Link to post
Share on other sites

_typeOfCursorTarget where does that come from shouldn't it be typeof _cursortarget

Share this post


Link to post
Share on other sites

okay, how about we do some flashlight debugging (the fav. sentence of my prof.):

Output all individual expressions of your if-clause and see if they're getting the value you hope for.

hint format ["is a crate: %1\nis opened: %2\nhas crowbar: %3\nis alive: %4", str _isCrate, _cursorTarget getVariable "opened", str("ItemCrowbar" in _itemsPlayer), str _isAlive];

If isCrate is false, try using

_cursorTarget isKindOf "CustomAmmoBox"

this will check for children in the config as well.

Share this post


Link to post
Share on other sites

Working now Thanks.

got a second question do u know where i could get a list of all objects with pictures? and i dont mean classes i just mean the p3d's

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×