infistar already made it. Just run this:
Generate key cursor target:
Code:
private ["_ct","_id","_result","_inventory","_backpack"];
_ct = cursorTarget;
if (!isNull _ct) then {
if (_ct distance player > 12) exitWith {cutText [format["%1 is to far away.",typeOF _ct], "PLAIN"];};
if !((_ct isKindOf "LandVehicle") || (_ct isKindOf "Air") || (_ct isKindOf "Ship")) exitWith {cutText [format["%1 is not a vehicle..",typeOF _ct], "PLAIN"];};
_id = _ct getVariable ["CharacterID","0"];
_id = parsenumber _id;
if (_id == 0) exitWith {cutText [format["%1 has ID 0 - No Key possible.",typeOF _ct], "PLAIN"];};
if ((_id > 0) && (_id <= 2500)) then {_result = format["ItemKeyGreen%1",_id];};
if ((_id > 2500) && (_id <= 5000)) then {_result = format["ItemKeyRed%1",_id-2500];};
if ((_id > 5000) && (_id <= 7500)) then {_result = format["ItemKeyBlue%1",_id-5000];};
if ((_id > 7500) && (_id <= 10000)) then {_result = format["ItemKeyYellow%1",_id-7500];};
if ((_id > 10000) && (_id <= 12500)) then {_result = format["ItemKeyRed%1",_id-10000];};
_inventory = (weapons player);
_backpack = ((getWeaponCargo unitbackpack player) select 0);
if (_result in (_inventory+_backpack)) then
{
if (_result in _inventory) then {cutText [format["Key [%1] already in your inventory!",_result], "PLAIN"];};
if (_result in _backpack) then {cutText [format["Key [%1] already in your backpack!",_result], "PLAIN"];};
}
else
{
player addweapon _result;
cutText [format["Key [%1] added to inventory!",_result], "PLAIN"];
};
};
And to save you guys making more threads:
Open/Unlock cursor target door/vehicle:
Code:
_ct = cursorTarget;
if (!isNull _ct) then
{
_obj = vehicle player;
if ((_ct isKindOf "AllVehicles") && (locked _ct)) then {_ct lock false;};
if ((_obj != player) && (_obj isKindOf "AllVehicles") && (locked _obj)) then {_obj lock false;};
{
_ct animate [_x,1];
} forEach ["Open_hinge","Open_latch","Lights_1","Lights_2","Open_door","DoorR","LeftShutter","RightShutter"];
};
Close/Lock cursor target door/vehicle
Code:
_ct = cursorTarget;
if (!isNull _ct) then
{
_obj = vehicle player;
if ((_ct isKindOf "AllVehicles") && (locked _ct)) then {_ct lock true;};
if ((_obj != player) && (_obj isKindOf "AllVehicles") && (locked _obj)) then {_obj lock true;};
{
_ct animate [_x,0];
} forEach ["Open_hinge","Open_latch","Lights_1","Lights_2","Open_door","DoorR","LeftShutter","RightShutter"];
};
all creds infistar