Jump to content

Gwandoya

Member
  • Posts

    21
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by Gwandoya

  1. I'd like to suggest changing player_monitor.fsm in next release, if skin magazine class doesn't exist, model should be reverted to Survivor2_DZ to prevent spawning invisible players in Survivor1_DZ, if an incorrect skin name is defined in DZE_defaultSkin array. (or the checking of if _model=="Survovor1_DZ" should be after the random skin selection function.)

  2. Try this:

    {
        private["_temp"];
        _temp = _x;
        systemChat format["X = %1",getPos _temp];
        systemChat format["X=%1,Y=%2,Z=%3 = ",getPos _temp select 0,getPos _temp select 1,getPos _temp select 2];
    }forEach array1; 

    It's possible _x have a different value inside format[]. I didn't try it, I just remember on something like that.

  3. I forgot to delete the _initUnit define from the last version when i used it. Will do that right now for the next version.

     

    It was a good idea to hide the agent from all other players. However it will not work for servers using infiStart Antihack, because playableUnits array contains only self player object for players.

    If you make a new release you may could spawn the skin preview place randomly anywhere on the map, so there's very few chance one player can see the skin preview of another one.

     

    I tried it today, and yes, all spawned skin preview agents are visible for others too.

  4. I may have forgot to do a part but I'm sure I didn't, but basically it works perfectly fine, but when you exit it just shows a black screen, and when you press escape it shows the sky and you need to re-log to fix it, There is also no errors in my rpt log. Not sure if this is a known problem but I'm currently using Linux, so I'm not sure if that would make a difference 

     

    Do u use the new Amra 2 patch maybe where the deleteVehicle function is not working? Cause it works on all of my friends servers now perfectly on 103718 beta patch.

    The script waits until the preview vehicle is deleted before it goes back to player cam so maybe thats a point?

    else i dont know what but, scripts work good tested it again on a vanilla epoch.

     

    Yeah, it seems (some version of?) Arma 2 doesn't nulls the object out by the a deleteVehicle command.

    (Probably that's why you can see the lights, the gear option or can get in/out of a sold vehicle at trader.)

     

    Commenting the waitUntil lines out solves the problem and script works like a charm. :)

     

    /* Wait until all is deleted */

    //waitUntil {sleep 0.01; isNull previewVehicle};

     

    //waitUntil {sleep 0.01; isNull previewUnit};

     

    Thanks Otter for sharing this! :lol:

     

    One more suggestion:

    At the moment you can not preview bikes and boats, you could use this:

    if (["trade_any_",_item select 9] call fnc_inString) then {

     

    (_initUnit variable is not used, only defined. however, forEach playableUnits will not work for servers using infiStar AH, because playableUnits array contains only player object for players.

    I didn't test it, but probably if two players are previewing skins in the same time, both agents will be visible for them.)

  5. For the error in your RPT file, its quite usual error for this kinda hotkey call, but the call itself works fine.

    Never figured out why it shows that error sometimes, but will have a deeper look on it. But again it works fine, even if it shows that error.

     

    I'm not sure if I understood well, displayAddEventHandler have needed a return value true or false, but I applied this method on all keybinds in script, and errors disappeared from RPT log, while script calls run okay:

            PreviewAbortHotkey = (findDisplay 46) displayAddEventHandler ["KeyDown", "
                _handled = false;
                if (_this select 1 == 0x3F) then {
                    PreviewLoop = false;
                    (findDisplay 46) displayRemoveEventHandler ['KeyDown', PreviewAbortHotkey];
                    (findDisplay 46) displayRemoveEventHandler ['KeyDown', PreviewRotateHotkey];
                    (findDisplay 46) displayRemoveEventHandler ['KeyDown', PreviewZoomHotkey];
                    _handled = true;
                };
                _handled
            "];
  6. I may have forgot to do a part but I'm sure I didn't, but basically it works perfectly fine, but when you exit it just shows a black screen, and when you press escape it shows the sky and you need to re-log to fix it, There is also no errors in my rpt log. Not sure if this is a known problem but I'm currently using Linux, so I'm not sure if that would make a difference 

     

    I have the same problem.

    InfiStar Antihack is disabled - same, so it's not related to antihack.

     

    The error is the following in client RPT:

    Error in expression <if ((_this select 1) == 0x3F) then {[Veh>
      Error position: <if ((_this select 1) == 0x3F) then {[Veh>
      Error type Script, expected Bool

    It happens in player_traderMenuHive.sqf:

    VehiclePreviewHotkey = (findDisplay 46) displayAddEventHandler ["KeyDown", "if ((_this select 1) == 0x3F) then {[VehiclePreviewList,LastTraderSelectCategory,LastTraderSelectItem] spawn ON_fnc_VehiclePreview;};"];

    Spent some hours already trying to find a solution, but nothing so far.

    First I tried to disable serialization, because we use findDisplay... it's not the problem.

    Then I tried to change the format of displayAddEventHandler, removing ; at end or adding {} around " if ", but still error appeared in log.

    Then I created a separate function with spawning the ON_fnc_VehiclePreview for the event handler function and gave 'true' for return value.

    This caused no errors appear in RPT log, but destroying the preview camera still doesn't drop you back to your camera view and screen remains black.

     

    other issue:

    Does anyone have idea where infiStar disabled or changed using the F5 (maybe other keys too)?

    I already assigned the Map icons to F6 in AH, so pressing F5 in VASP works for admins.

    However it doesn't work for players; pressing F5 does nothing.

     

    Suggestion to OtterNas3:

     

    You could use

    AllAllowedSkins = [];
    {
        AllAllowedSkins = AllAllowedSkins + [format["Skin_%1",_x]];
    } forEach AllPlayers;

    to define the skin magazine list, instead of listing the names in an array in VASP script.

  7. Oki, if you wish to discuss :)

     

    Mission vehicles are created with ObjectID="0" and ObjectUID=call dayz_objectUID; they are in PVDZE_serverObjectMonitor, and Arma updates their positions correctly, but they will not be saved in DB.

    I don't need to use fnc_veh_ResetEH or server_updateObject, because these mission vehicles are not intended to be saved in db and will disappear after restart.

    However, with your great script players have the opportunity to claim and save mission vehicles as well. :) (I just need to update their positions after they are claimed.)

     

    Cheers,

    Gwan

  8. Yes, true, I checked the code several times.

    It's about adding the event handler for mission spawned vehicles, updating 'all' when player gets in or out of a vehicle.

    This event handler is added by epoch when loads the server spawned vehicles from database.

    But if I claim a mission spawned vehicle, which has no event handlers added (because it will not be saved in database), I need to add it, otherwise if player moves vehicle its position won't be updated in database, and he will find his vehicle after next server restart where mission spawned it.

     

    /***********************************************************
    ASSIGN DAMAGE HANDLER TO A UNIT
    - Function fnc_veh_ResetEH
    - unit call fnc_veh_ResetEH
    ************************************************************/

    _this removeAllEventHandlers "HandleDamage";
    _this removeAllEventHandlers "Killed";
    _this addeventhandler ["HandleDamage",{ _this call vehicle_handleDamage } ];
    _this addeventhandler ["Killed",{ _this call vehicle_handleKilled } ];

    if (isServer) then {
        _this removeAllEventHandlers "GetOut";
        _this removeAllEventHandlers "GetIn";
        _this addEventHandler ["GetOut", {[(_this select 0),"all"] call server_updateObject;}];
        _this addEventHandler ["GetIn", {[(_this select 0),"all"] call server_updateObject; _this call server_checkIfTowed;}];

    };

  9. Exactly, to claim a vehicle you need to have a key in your inventory.

     

    There're some conditions must be fulfilled before you can claim a vehicle or change a key.

    You need to have these in your inventory (payments depend on init settings, but I use these).

     

    1. to claim a vehicle which has no key:

    • 1 Keymakers Kit
    • 1 Key
    • 10oz GoldBar
    • 1 GoldBar

    2. to change the key of a vehicle to another key:

    • 1 Keymakers Kit
    • the key of the vehicle you want change key for ("KeyAlice")
    • an other key which will open the vehicle ("KeyBob")
    • 1 GoldBar

    As the author showed in his video when you change a key from "KeyAlice" to "KeyBob", you can calmly drop "KeyAlice", because that doesn't belong to the vehicle anymore.

    If you do that with several different "KeyAlices" you can have several vehicles with "KeyBob", that's why "KeyBob" is called "Master Key" :)

  10. I followed the and did the changes I posted.

    I wanted to upload my files, but somehow I can't do it here :huh:

     

    In the post you quite mixed codes up.

     

    server_updateObject.sqf

    /*
    [_object,_type] spawn server_updateObject;
    */
    /* Additional */
    /***********************************/ 	
    /* Vehicle Key Changer v1.3        */
    /* Written by OtterNas3            */
    /* January, 11, 2014               */
    /* Last update: 02/20/2014         */
    /***********************************/
    
    
    private ["_object","_type","_objectID","_uid","_lastUpdate","_needUpdate","_object_position","_object_inventory","_object_damage","_isNotOk","_parachuteWest","_firstTime","_object_killed","_object_repair","_isbuildable","_object_vehicleKey","_activatingPlayer","_vehicleClassname","_toKey","_toKeyName","_vehicle_ID","_vehicle_UID"];
    
    _object = 	_this select 0;
    
    if(isNull(_object)) exitWith {
    	diag_log format["Skipping Null Object: %1", _object];
    };
    
    _type = 	_this select 1;
    _parachuteWest = ((typeOf _object == "ParachuteWest") or (typeOf _object == "ParachuteC"));
    _isbuildable = (typeOf _object) in dayz_allowedObjects;
    _isNotOk = false;
    _firstTime = false;
    
    _objectID =	_object getVariable ["ObjectID","0"];
    _uid = 		_object getVariable ["ObjectUID","0"];
    
    if ((typeName _objectID != "string") || (typeName _uid != "string")) then
    { 
        diag_log(format["Non-string Object: ID %1 UID %2", _objectID, _uid]);
        //force fail
        _objectID = "0";
        _uid = "0";
    };
    
    if (!_parachuteWest and !(locked _object)) then {
    	if (_objectID == "0" && _uid == "0") then
    	{
    		_object_position = getPosATL _object;
        	_isNotOk = true;
    	};
    };
    
    // do not update if buildable and not ok
    if (_isNotOk and _isbuildable) exitWith {  };
    
    // delete if still not ok
    if (_isNotOk) exitWith { deleteVehicle _object; diag_log(format["Deleting object %1 with invalid ID at pos [%2,%3,%4]",typeOf _object,_object_position select 0,_object_position select 1, _object_position select 2]); };
    
    
    _lastUpdate = _object getVariable ["lastUpdate",time];
    _needUpdate = _object in needUpdate_objects;
    
    // TODO ----------------------
    _object_position = {
    	private["_position","_worldspace","_fuel","_key"];
    		_position = getPosATL _object;
    		_worldspace = [
    			round(direction _object),
    			_position
    		];
    		_fuel = 0;
    		if (_object isKindOf "AllVehicles") then {
    			_fuel = fuel _object;
    		};
    		_key = format["CHILD:305:%1:%2:%3:",_objectID,_worldspace,_fuel];
    		//diag_log ("HIVE: WRITE: "+ str(_key));
    		_key call server_hiveWrite;
    };
    
    _object_inventory = {
    	private["_inventory","_previous","_key"];
    		_inventory = [
    			getWeaponCargo _object,
    			getMagazineCargo _object,
    			getBackpackCargo _object
    		];
    		_previous = str(_object getVariable["lastInventory",[]]);
    		if (str(_inventory) != _previous) then {
    			_object setVariable["lastInventory",_inventory];
    			if (_objectID == "0") then {
    				_key = format["CHILD:309:%1:%2:",_uid,_inventory];
    			} else {
    				_key = format["CHILD:303:%1:%2:",_objectID,_inventory];
    			};
    			//diag_log ("HIVE: WRITE: "+ str(_key));
    			_key call server_hiveWrite;
    		};
    };
    
    _object_damage = {
    	private["_hitpoints","_array","_hit","_selection","_key","_damage"];
    		_hitpoints = _object call vehicle_getHitpoints;
    		_damage = damage _object;
    		_array = [];
    		{
    			_hit = [_object,_x] call object_getHit;
    			_selection = getText (configFile >> "CfgVehicles" >> (typeOf _object) >> "HitPoints" >> _x >> "name");
    			if (_hit > 0) then {_array set [count _array,[_selection,_hit]]};
    			_object setHit ["_selection", _hit]
    		} forEach _hitpoints;
    	
    		_key = format["CHILD:306:%1:%2:%3:",_objectID,_array,_damage];
    		//diag_log ("HIVE: WRITE: "+ str(_key));
    		_key call server_hiveWrite;
    	_object setVariable ["needUpdate",false,true];
    	};
    
    _object_killed = {
    	private["_hitpoints","_array","_hit","_selection","_key","_damage"];
    	_hitpoints = _object call vehicle_getHitpoints;
    	//_damage = damage _object;
    	_damage = 1;
    	_array = [];
    	{
    		_hit = [_object,_x] call object_getHit;
    		_selection = getText (configFile >> "CfgVehicles" >> (typeOf _object) >> "HitPoints" >> _x >> "name");
    		if (_hit > 0) then {_array set [count _array,[_selection,_hit]]};
    		_hit = 1;
    		_object setHit ["_selection", _hit]
    	} forEach _hitpoints;
    	
    	if (_objectID == "0") then {
    		_key = format["CHILD:306:%1:%2:%3:",_uid,_array,_damage];
    	} else {
    		_key = format["CHILD:306:%1:%2:%3:",_objectID,_array,_damage];
    	};
    	//diag_log ("HIVE: WRITE: "+ str(_key));
    	_key call server_hiveWrite;
    	_object setVariable ["needUpdate",false,true];
    };
    
    _object_repair = {
    	private["_hitpoints","_array","_hit","_selection","_key","_damage"];
    	_hitpoints = _object call vehicle_getHitpoints;
    	_damage = damage _object;
    	_array = [];
    	{
    		_hit = [_object,_x] call object_getHit;
    		_selection = getText (configFile >> "CfgVehicles" >> (typeOf _object) >> "HitPoints" >> _x >> "name");
    		if (_hit > 0) then {_array set [count _array,[_selection,_hit]]};
    		_object setHit ["_selection", _hit]
    	} forEach _hitpoints;
    	
    	_key = format["CHILD:306:%1:%2:%3:",_objectID,_array,_damage];
    	//diag_log ("HIVE: WRITE: "+ str(_key));
    	_key call server_hiveWrite;
    	_object setVariable ["needUpdate",false,true];
    };
    
    _object_vehicleKey = {
    	private["_hitpoints","_array","_hit","_selection","_key","_damage","_fuel","_inventory","_class","_position","_worldspace","_newKey","_newKeyName","_player","_oldVehicleID","_vehicleID","_vehicleUID","_result","_outcome","_retry","_gotcha"];
    	
    	/* Setting up variables */
    	_player = _this select 0;
    	_class = _this select 1;
    	_newKey = _this select 2;
    	_newKeyName = _this select 3;
    	_oldVehicleID = _this select 4;
    	_vehicleUID = _this select 5;
    
    	/* Get Damage of the Vehicle */
    	_hitpoints = _object call vehicle_getHitpoints;
    	_damage = damage _object;
    	_array = [];
    	{
    		_hit = [_object,_x] call object_getHit;
    		_selection = getText (configFile >> "CfgVehicles" >> (typeOf _object) >> "HitPoints" >> _x >> "name");
    		if (_hit > 0) then {_array set [count _array,[_selection,_hit]]};
    		_object setHit ["_selection", _hit]
    	} forEach _hitpoints;
    	
    	/* Get the Fuel of the Vehicle */
    	_fuel = 0;
    	if (_object isKindOf "AllVehicles") then {
    		_fuel = fuel _object;
    	};
    	
    	/* Get the Inventory of the Vehicle */
    	_inventory = [
    		getWeaponCargo _object,
    		getMagazineCargo _object,
    		getBackpackCargo _object
    	];
    	
    	/* Get the position of the Vehicle */
    	_position = getPosATL _object;
    	_worldspace = [
    		round(direction _object),
    		_position
    	];
    
    	/* Delete the current Database entry */
    	[_oldVehicleID,_vehicleUID,_player] call server_deleteObj;
    	sleep 1;
    	
    	/* Write the new Database entry and LOG the action*/
    	_key = format["CHILD:308:%1:%2:%3:%4:%5:%6:%7:%8:%9:",dayZ_instance, _class, _damage , _newKey, _worldspace, _inventory, _array, _fuel,_vehicleUID];
    	_key call server_hiveWrite;
    	diag_log ("HIVE: WRITE: VEHICLE KEY CHANGER: "+ str(_key)); 
    	diag_log format["HIVE: WRITE: VEHICLE KEY CHANGER: Vehicle:%1 NewKey:%2 BY %3(%4)", _object, _newKeyName, (name _player), (getPlayerUID _player)];
    
    	/* Get the ObjectID of the entry in the Database */
    	_retry = 0;
    	_gotcha = false;
    	while {!_gotcha && _retry < 10} do {
    		sleep 1;
    		
    		/* Send the request */
    		_key = format["CHILD:388:%1:",_vehicleUID];
    		diag_log ("HIVE: READ: VEHICLE KEY CHANGER: "+ str(_key));
    		_result = _key call server_hiveReadWrite;
    		_outcome = _result select 0;
    		
    		/* We got a answer */
    		if (_outcome == "PASS") then {
    			_vehicleID = _result select 1;
    			
    			/* Compare with old ObjectID to check if it not was deleted yet */
    			if (_oldVehicleID == _vehicleID) then {
    				/* Not good lets give it another try */
    				_gotcha = false;
    				_retry = _retry + 1;
    			} else {
    				/* GOTCHA! */
    				diag_log("CUSTOM: VEHICLE KEY CHANGER: Selected " + str(_vehicleID));
    				_gotcha = true;
    				_retry = 11;
    			};
    		} else {
    			/* Something went wrong on the request give it another try */
    			diag_log("CUSTOM: VEHICLE KEY CHANGER: trying again to get id for: " + str(_vehicleUID));
    			_gotcha = false;
    			_retry = _retry + 1;
    		};
    	};
    
    	/* Lock the Vehicle */
    	_object setVehicleLock "locked";
    	
    	/* Save the ObjectID to the vehicles variable and make it public */
    	_object setVariable ["ObjectID", _vehicleID, true];
    
    	/* Save the ObjectUID to the vehicles variable and make it public */
    	_object setVariable ["ObjectUID", _vehicleUID, true];
    
    	/* Set the lastUpdate time to current */
    	_object setVariable ["lastUpdate",time];
    	
    	/* Set the CharacterID to the new Key so we can access it! */
    	_object setVariable ["CharacterID", _newKey, true];
    	
    	/* Some other variables you might need for disallow lift/tow/cargo locked Vehicles and such */
    	/* Uncomment if you use this */
    	
    	/* R3F Arty and LOG block lift/tow/cargo locked vehicles*/
    	_object setVariable ["R3F_LOG_disabled",true,true];
    	
    	/* =BTC= Logistic block lift locked vehicles*/
    	_object setVariable ["BTC_Cannot_Lift",true,true];
    	
    	_object setVariable ["sidegundeployed",0,true];
    	_object setVariable ["reargundeployed",0,true];
    
    	_object call fnc_veh_ResetEH;
    };
    // TODO ----------------------
    
    _object setVariable ["lastUpdate",time,true];
    switch (_type) do {
    	case "all": {
    		call _object_position;
    		call _object_inventory;
    		call _object_damage;
    		};
    	case "position": {
    		if (!(_object in needUpdate_objects)) then {
    			//diag_log format["DEBUG Position: Added to NeedUpdate=%1",_object];
    			needUpdate_objects set [count needUpdate_objects, _object];
    		};
    	};
    	case "gear": {
    		call _object_inventory;
    			};
    	case "damage": {
    		if ( (time - _lastUpdate) > 5) then {
    			call _object_damage;
    		} else {
    			if (!(_object in needUpdate_objects)) then {
    				//diag_log format["DEBUG Damage: Added to NeedUpdate=%1",_object];
    				needUpdate_objects set [count needUpdate_objects, _object];
    			};
    		};
    	};
    	case "killed": {
    		call _object_killed;
    	};
    	case "repair": {
    		call _object_damage;
    	};
    	case "vehiclekey": {
    		_activatingPlayer = _this select 2;
    		_vehicleClassname = _this select 3;
    		_toKey = _this select 4;
    		_toKeyName = _this select 5;
    		_vehicle_ID = _this select 6;
    		_vehicle_UID = _this select 7;
    		[_activatingPlayer, _vehicleClassname, _toKey, _toKeyName, _vehicle_ID, _vehicle_UID] call _object_vehicleKey;
    	};
    };
    
    

    VehicleKeyChanger.sqf

    /***********************************/ 	
    /* Vehicle Key Changer v1.3        */
    /* Written by OtterNas3            */
    /* January, 11, 2014               */
    /* Last update: 02/20/2014         */
    /***********************************/
    
    
    /* Setup the private variables */
    private ["_magazinesPlayer","_max","_j","_actionArray","_targetVehicle","_targetVehicleID","_targetVehicleUID","_playerKeys","_playerKeysDisplayName","_targetVehicleKeyName","_itemKeyName","_targetVehicleClassname","_targetVehiclePos","_targetVehicleDir","_Price","_claimingPrice"];
    
    /* Remove the Action Menu entry */
    player removeAction s_player_copyToKey;
    s_player_copyToKey = 0;
    
    /* Get the array and setup the variables */
    _actionArray = _this select 3;
    _targetVehicle = _actionArray select 0;
    _targetVehicleID = _targetVehicle getVariable ["ObjectID","0"];
    _targetVehicleUID = _targetVehicle getVariable ["ObjectUID","0"];
    
    /* Check if the Vehicle is in the Database, if false exit */
    if (_targetVehicleID == "0" && _targetVehicleUID == "0") exitWith {s_player_copyToKey = -1;};
    
    /* Setup more variables */
    _playerKeys = _actionArray select 1;
    _playerKeysDisplayName = _actionArray select 3;
    _targetVehicleKeyName = _actionArray select 4;
    _itemKeyName = _actionArray select 5;
    _Price = _actionArray select 6;
    _claimingPrice = _actionArray select 7;
    _targetVehicleClassname = typeOf _targetVehicle;
    _targetVehiclePos = getPosATL _targetVehicle;
    _targetVehicleDir = getDir _targetVehicle;
    
    /* Setup the Key Names list to select from */
    keyNameList = [];
    for "_i" from 0 to (count _playerKeysDisplayName) -1 do {
    	keyNameList set [(count keyNameList), _playerKeysDisplayName select _i];
    };
    
    /* Setup the Key Numbers list to select from */
    keyNumberList = [];
    for "_i" from 0 to (count _playerKeys) -1 do {
    	keyNumberList set [(count keyNumberList), _playerKeys select _i];
    };
    
    /* Resetting menu variables*/
    keyNameSelect = "";
    exitscript = true;
    snext = false;
    
    /* Creating the menu */
    copyMenu =
    {
    	private ["_keyMenu","_keyArray"];
    	_keyMenu = [["",true], ["Change Vehicle to Key:", [-1], "", -5, [["expression", ""]], "1", "0"]];
    	for "_i" from (_this select 0) to (_this select 1) do
    	{
    		_keyArray = [format['%1', keyNameList select (_i)], [_i - (_this select 0) + 2], "", -5, [["expression", format ["keyNameSelect = keyNameList select %1; keyNumberSelect = keyNumberList select %1", _i]]], "1", "1"];
    		_keyMenu set [_i + 2, _keyArray];
    	};
    	_keyMenu set [(_this select 1) + 2, ["", [-1], "", -5, [["expression", ""]], "1", "0"]];
    	if (count keyNameList > (_this select 1)) then
    	{
    		_keyMenu set [(_this select 1) + 3, ["Next", [12], "", -5, [["expression", "snext = true;"]], "1", "1"]];
    	} else {
    		_keyMenu set [(_this select 1) + 3, ["", [-1], "", -5, [["expression", ""]], "1", "0"]];
    	};
    	_keyMenu set [(_this select 1) + 4, ["Exit", [13], "", -5, [["expression", "keyNameSelect = 'exitscript';"]], "1", "1"]];
    	showCommandingMenu "#USER:_keyMenu";
    };
    
    /* Wait for the player to select a Key from the list */
    _j = 0;
    _max = 10;
    if (_max > 9) then {_max = 10;};
    while {keyNameSelect == ""} do {
    	[_j, (_j + _max) min (count keyNameList)] call copyMenu;
    	_j = _j + _max;
    	waitUntil {keyNameSelect != "" || snext};
    	snext = false;
    };
    
    /* Player selected a Key, lets make the Vehicle update call */
    if (keyNameSelect != "exitscript") then {
    	
    	/* Check again for the needed TinBar or claiming price and remove em from the players inventory */
    	_magazinesPlayer = magazines player;
    	if (_Price != "0") then {
    		if (_Price in _magazinesPlayer) then {
    			[player, _Price, 1] call BIS_fnc_invRemove;
    			systemChat (format["Keychange costs 1 %1, thanks for your Payment!", _Price]);
    		} else {
    			systemChat (format["Keychange costs 1 %1, you had it and tried to trick the system - Keychange for this Vehicle disabled!", Price]);
    			_targetVehicle setVariable ["VKC_disabled", 1, true];
    			s_player_copyToKey = -1;
    			breakOut "exit";
    		};
    	};
    	if (_claimingPrice != "0") then {
    		if (_claimingPrice in _magazinesPlayer) then {
    			[player, _claimingPrice, 1] call BIS_fnc_invRemove;
    			systemChat (format["Claiming Vehicle costs 1 %1, thanks for your Payment!", _claimingPrice]);
    		} else {
    			systemChat (format["Claiming Vehicle costs 1 %1, you had it and tried to trick the system - Claiming for this Vehicle disabled!", Price]);
    			_targetVehicle setVariable ["VKC_claiming_disabled", 1, true];
    			s_player_copyToKey = -1;
    			breakOut "exit";
    		};
    	};
    	
    	/* We got the Money lets do our Job */
    	/* Lock the vehicle */
    	_targetVehicle setVehicleLock "LOCKED";
    	
    	/* The super duper OneForAllAnimation... */
    	player playActionNow "Medic";
    	
    	/* Remove the Key from the Toolbelt of the player and put it in the Backpack - No Backpack and the Key gets lost */
    	if (_itemKeyName != "0") then {
    		if (!isNull (unitBackpack player)) then {
    			[player, _itemKeyName, 1] call BIS_fnc_invRemove;
    			(unitBackpack (vehicle player)) addWeaponCargoGlobal [_itemKeyName, 1];
    			systemChat (format["%1 has been moved to your Backpack", _targetVehicleKeyName]);
    		};
    	};
    
    	/* Giving unique UID for claimed vehicles */
    	if (_targetVehicleUID=="0") then {
    		_targetVehicleUID = _targetVehicle call dayz_objectUID_vkc;
    		_targetVehicle setVariable ["ObjectUID",_targetVehicleUID,true];
    	};
    
    	/* This calls the custom update function which we put it in server_updateObject.sqf */
    	PVDZE_veh_Update = [_targetVehicle, "vehiclekey", player, _targetVehicleClassname, keyNumberSelect, keyNameSelect, _targetVehicleID, _targetVehicleUID]; 
    	publicVariableServer "PVDZE_veh_Update"; 
    
    	/* Inform the player about the success and tell him to check the Key */
    	systemChat (format["Changed Vehicle Key to %1", keyNameSelect]);
    	if (_targetVehicleKeyName != "0") then {
    		systemChat (format["Please check Vehicle function with %1 before you throw away %2!", keyNameSelect, _targetVehicleKeyName]);
    	};
    };
    
    /* Reset the action menu variable for a new run */
    s_player_copyToKey = -1;
    
    /**************************************/
    /* That's it, hope you enjoy this Mod */
    /*                                    */
    /* Yours sincerly,                    */
    /* Otter                              */
    /**************************************/
    

    VehicleKeyChanger_init.sqf

    /***********************************/ 	
    /* Vehicle Key Changer v1.3        */
    /* Written by OtterNas3            */
    /* January, 11, 2014               */
    /* Last update: 02/20/2014         */
    /***********************************/
    
    
    private ["_itemsPlayer","_magazinesPlayer","_temp_Keys","_temp_keysDisplayName","_temp_keysDisplayNameParse","_key_colors","_ownerKeyId","_carKey","_hasKey","_cTarget","_keyName","_carKeyName","_targetVehicleKey","_temp_keysParse"];
    
    /////////////////////////////////////////////////
    /////////////////////////////////////////////////
    // Edit these settings to fit your needs/likes //
    /////////////////////////////////////////////////
    /////////////////////////////////////////////////
    /// Claim Vehicles that does not yet need Key ///
    ///////// 0 = Not allowed | 1 = Allowed /////////
    vkc_claiming = 1;
    /////////////////////////////////////////////////
    //////// Claim Vehicles costs this Item /////////
    /// Any Item can be used here, some examples: ///
    //// ItemTinBar, ItemSilverBar, ItemGoldBar, ////
    ////// ItemSilverBar10oz, ItemGoldBar10oz, //////
    ///// ItemBriefcase20oz, ItemBriefcase100oz /////
    //////// set to "0" to disable the costs ////////
    vkc_claimingPrice = "ItemGoldBar10oz";
    /////////////////////////////////////////////////
    ////////// Change Key costs this Item// /////////
    ////////////// see above examples ///////////////
    //////// set to "0" to disable the costs ////////
    vkc_Price = "ItemGoldBar";
    /////////////////////////////////////////////////
    /////// Need KeyKit to use this function ////////
    ////////// 0 = Not needed | 1 = Needed //////////
    vkc_needKeykit = 1;
    /////////////////////////////////////////////////
    /////////////////////////////////////////////////
    /////////////// DONT EDIT BELOW ! ///////////////
    /////////////////////////////////////////////////
    
    /* Reset variables function */
    ON_fnc_vkc_reset = {
    	_cTarget = objNull;
    	_itemsPlayer = [];
    	_temp_keys = [];
    	_carKey = objNull;
    	_hasKey = false;
    	_temp_keysDisplayName = [];
    	_temp_keysDisplayNameParse = [];
    	_temp_keysParse = [];
    	_targetVehicleKey = objNull;
    	_carKeyName = "";
    	player removeAction s_player_copyToKey;
    	s_player_copyToKey = -1;
    };
    
    dayz_objectUID_vkc = {
    	private["_position","_dir","_key","_object"];
    	_object = _this;
    	_position = getPosATL _object;
    	_dir = direction _object;
    	_key = [_dir,_position] call dayz_objectUID2_vkc;
        _key
    };
    
    dayz_objectUID2_vkc = {
    	private["_position","_dir","_key"];
    	_dir = _this select 0;
    	_key = "";
    	_position = _this select 1;
    	{
    		_x = _x * 10;
    		if ( _x < 0 ) then { _x = _x * -10 };
    		_key = _key + str(round(_x));
    	} forEach _position;
    	_key = _key + str(round(_dir));
    	_key
    };
    
    /* Wait for player full ingame so we can access the action-menu */
    waitUntil {!isNil "dayz_animalCheck"};
    
    s_player_copyToKey=-1;
    lastKeyChangeCursorTarget = [objNull,objNull,objNull,objNull,objNull];
    
    /* Start the loop check */
    while{true} do {
    	sleep 3;
    	if (!isNull cursorTarget && speed player <= 1 && (vehicle player) == player && !isEngineOn cursorTarget && (cursorTarget isKindOf "Motorcycle" || cursorTarget isKindOf "Car" || cursorTarget isKindOf "Air" || cursorTarget isKindOf "Ship") && (cursorTarget distance player) <= 10 && cursorTarget getVariable ["VKC_disabled", 0] == 0 && cursorTarget getVariable ["VKC_claiming_disabled",0] == 0) then {
    		_cTarget = cursorTarget;
    		_itemsPlayer = items player;
    		_magazinesPlayer = magazines player;
    		if ((lastKeyChangeCursorTarget select 0) != _cTarget) then {
    			if (s_player_copyToKey >= 0) then {
    				player removeAction s_player_copyToKey;
    				s_player_copyToKey = -1;
    			};
    		};
    		lastKeyChangeCursorTarget set [0,_cTarget];
    		_carKey = _cTarget getVariable ["CharacterID","0"];
    		if (("ItemKeyKit" in _itemsPlayer || vkc_needKeykit == 0) && ((_carKey == "0" && vkc_claiming == 1 && (vkc_claimingPrice == "0" || vkc_claimingPrice in _magazinesPlayer)) || _carKey != "0") && (vkc_Price == "0" || vkc_Price in _magazinesPlayer)) then {
    			if (_carKey == "0") then {
    				_temp_keys = [];
    				_temp_keysDisplayName = [];
    				_temp_keysDisplayNameParse = [];
    				_key_colors = ["ItemKeyYellow","ItemKeyBlue","ItemKeyRed","ItemKeyGreen","ItemKeyBlack"];
    				{
    					if (configName(inheritsFrom(configFile >> "CfgWeapons" >> _x)) in _key_colors) then {
    						_ownerKeyId = getNumber(configFile >> "CfgWeapons" >> _x >> "keyid");
    						_keyName = getText(configFile >> "CfgWeapons" >> _x >> "displayName");
    						_temp_keysDisplayName set [count _temp_keysDisplayName,_keyName];
    						_temp_keys set [count _temp_keys,str(_ownerKeyId)];
    					};
    				} forEach _itemsPlayer;
    				if ((count _temp_keys) > 0) then {
    					if (s_player_copyToKey < 0) then {
    						lastKeyChangeCursorTarget set [0,_cTarget];
    						s_player_copyToKey = player addAction [("<t color=""#c03636"">" + ("Claim Vehicle") + "</t>"),"custom\VehicleKeyChanger\VehicleKeyChanger.sqf",[_cTarget, _temp_keys, "0", _temp_keysDisplayName, "0", "0", vkc_Price, vkc_claimingPrice],-1,false,false,"",""];
    					};
    				} else {
    					[] call ON_fnc_vkc_reset;
    				};
    			} else {
    				_temp_keys = [];
    				_temp_keysDisplayName = [];
    				_temp_keysDisplayNameParse = [];
    				_temp_keysParse = [];
    				_key_colors = ["ItemKeyYellow","ItemKeyBlue","ItemKeyRed","ItemKeyGreen","ItemKeyBlack"];
    				{
    					if (configName(inheritsFrom(configFile >> "CfgWeapons" >> _x)) in _key_colors) then {
    						_ownerKeyId = getNumber(configFile >> "CfgWeapons" >> _x >> "keyid");
    						_keyName = getText(configFile >> "CfgWeapons" >> _x >> "displayName");
    						_temp_keysDisplayName set [count _temp_keysDisplayName,_keyName];
    						_temp_keysDisplayNameParse set [_ownerKeyId,_keyName];
    						_temp_keys set [count _temp_keys,str(_ownerKeyId)];
    						_temp_keysParse set [_ownerKeyId, _x];
    					};
    				} forEach _itemsPlayer;
    				_hasKey = _carKey in _temp_keys;
    				if (_hasKey && (count _temp_keys) > 1) then {
    					_carKeyName = (_temp_keysDisplayNameParse select (parseNumber _carKey));
    					_targetVehicleKey = (_temp_keysParse select (parseNumber _carKey));
    					_temp_keys = _temp_keys - [_carKey];
    					_temp_keysDisplayName = _temp_keysDisplayName - [_carKeyName];
    					if (s_player_copyToKey < 0) then {
    						lastKeyChangeCursorTarget set [0,_cTarget];
    						s_player_copyToKey = player addAction [("<t color=""#c03636"">" + ("Change Vehicle Key") + "</t>"),"custom\VehicleKeyChanger\VehicleKeyChanger.sqf",[_cTarget, _temp_keys, _carKey, _temp_keysDisplayName, _carKeyName, _targetVehicleKey, vkc_Price, "0"],-1,false,false,"",""];
    					};
    				} else {
    					[] call ON_fnc_vkc_reset;
    				};
    			};
    		} else {
    			[] call ON_fnc_vkc_reset;
    		};
    	} else {
    		lastKeyChangeCursorTarget = [objNull,objNull,objNull,objNull,objNull];
    		[] call ON_fnc_vkc_reset;
    	};
    };
    
    
    

  11. Posted Today, 02:47 PM

    What has change in the version of BE? The log output has changed, is there any syntax difference in the filters?

     

    @maca134

     

    I noticed BattlEye now doesn't distinguish lower and upper case letters.

    Players were getting kicked because of a script restriction on "_box" but in script there was "_BOX".

    And the size of DLL changed from 200 to 600 KB, they definitely put something in it ;)

  12. Here's another update which allows you to claim vehicles which were not in database at server start but spawned by a mission script.

     

    Open your server_updateObject.sqf included in Vehicle Key Changer release and add after _object setVariable ["ObjectID", _vehicleID, true]; in line 244:

    	/* Save the ObjectUID to the vehicles variable and make it public */
    	_object setVariable ["ObjectUID", _vehicleUID, true];
    

    Add code after _object setVariable ["reargundeployed",0,true]; before the closing bracket to line 267:

    	_object call fnc_veh_ResetEH;
    

    This is important to add the event handlers to the mission vehicles, otherways Epoch won't update the position, gear and damage of your vehicle, and after server restart it will spawn at that place where you claimed the vehicle.

     

    And one small note:

    mission vehicles will not be saved correctly if your mission script sets ObjectID="1" (and ObjectUID="1"). The next claimed vehicle will always overwrite the previous one because both have ObjectID 1 in database.

    To solve this, you might need to modify your AI mission script: (replace "_vehicle" with the appropriate variable name.)

    _uid = _vehicle call dayz_objectUID;
    _vehicle setVariable ["ObjectID", "0", true];
    _vehicle setVariable ["ObjectUID", _uid, true];
    

    (It doesn't matter if ObjectID is zero, HiveWrite will add a new record to object_data table.)

     

    And of course, object has to be in PVDZE_serverObjectMonitor :)

    PVDZE_serverObjectMonitor set [count PVDZE_serverObjectMonitor, _vehicle];
    
  13. Hi!

     

    In first line thanks for the author for this great idea and code!

     

    To solve the problem with disappearing and replaced vehicles, open VehicleKeyChanger_init.sqf and place the following code after function ON_fnc_vkc_reset in line 56:

    dayz_objectUID_vkc = {
    	private["_position","_dir","_key","_object"];
    	_object = _this;
    	_position = getPosATL _object;
    	_dir = direction _object;
    	_key = [_dir,_position] call dayz_objectUID2_vkc;
        _key
    };
    
    dayz_objectUID2_vkc = {
    	private["_position","_dir","_key"];
    	_dir = _this select 0;
    	_key = "";
    	_position = _this select 1;
    	{
    		_x = _x * 10;
    		if ( _x < 0 ) then { _x = _x * -10 };
    		_key = _key + str(round(_x));
    	} forEach _position;
    	_key = _key + str(round(_dir));
    	_key
    };
    

    I suggest to reset some variables as well, place the following code after waitUntil {!isNil "dayz_animalCheck"}; in line 83:

    s_player_copyToKey=-1;
    lastKeyChangeCursorTarget = [objNull,objNull,objNull,objNull,objNull];
    

    I also changed the self action menu text in that case when you claim a vehicle without a key, text "Change Vehicle Key" changed to "Claim Vehicle" in line 118.

     

    And I got an odd 'general error' in some cases (probably when I had no key in my inventory but all other requirements were fullfilled)

    so, I changed

    if (_carKey != "0") then {
    

    to

    } else {
    

    Now open VehicleKeyChanger.sqf and add the following code to line 129:

    	/* Giving unique UID for claimed vehicles */
    	if (_targetVehicleUID=="0") then {
    		_targetVehicleUID = _targetVehicle call dayz_objectUID_vkc;
    		_targetVehicle setVariable ["ObjectUID",_targetVehicleUID,true]; // It does probably nothing and it's not needed :)
    	};
    

    With these modfifications you can Claim a server spawned vehicle which has only ObjectID (MySQL primary, autoincremented ID) but ObjectUID=0.

    On our server you can claim mission vehicles as well, because for mission vehicles we generate ObjectID="0" and ObjectUID=_vehicle call dayz_objectUID; (Server side call.)

    dayz_objectUID and dayz_objectUID2 are standard ObjectUID generator functions from server_functions.sqf, and we had to place them to client side (_vkc added to names).

    To fix objects stored in your database with ObjectUID=0 just run this MySQL command on object_data table:

    UPDATE object_data SET ObjectUID=ROUND(RAND(1)*1000000000000000) WHERE ObjectUID=0

     

    [ Modifications made for Vehicle Key Changer - For making Masterkey - V 1.3 (Updated 02/20/2014) ]

×
×
  • Create New...