Xyberviri
Valued Member!
This thread is out of date and is only valid for DayZ version 1.7.5.1 on Bliss/Reality. Any other versions may not work as expected.
-X
Code:
CREATE DEFINER=`dayz`@`localhost` PROCEDURE `proc_saveVehicle`(IN `p_worldvehicleid` BIGINT(20))[/U][/S][/U][/S]
[S][U]BEGIN[/U][/S]
[S][U]INSERT INTO `instance_vehicle`(`world_vehicle_id`,`last_updated`, `created`) VALUES (p_worldvehicleid,CURRENT_TIMESTAMP,CURRENT_TIMESTAMP);[/U][/S]
[S][U]select LAST_INSERT_ID();[/U][/S]
[S][U]END
Code:
private ["_targetObj","_targetClass","_targetPos","_saveWorldVehicleID","_instanceVehicleID","_key","_data","_result","_status","_count"];[/U][/S][/U][/S]
[S][U]_targetObj = _this;[/U][/S]
[S][U]_targetClass = typeOf _targetObj;[/U][/S]
[S][U]_targetPos = getPos _targetObj;[/U][/S]
[S][U]_saveWorldVehicleID = 0;[/U][/S]
[S][U]_instanceVehicleID = 0;[/U][/S]
[S][U]diag_log("xSAVE: Attempting to save "+ str(_targetClass)+" at "+str(_targetPos));[/U][/S]
[S][U]//Wait for HIVE to be free[/U][/S]
[S][U]waitUntil{!hiveInUse};[/U][/S]
[S][U]hiveInUse = true;[/U][/S]
[S][U]//Send request[/U][/S]
[S][U]_key = format["CHILD:999:select world_vehicle.id from world_vehicle, vehicle where vehicle.id = world_vehicle.vehicle_id and vehicle.class_name = '?' and world_vehicle.world_id = '%2' LIMIT 1:[""%1""]:", _targetClass,1];[/U][/S]
[S][U]diag_log ("xSAVE: Query: " + str(_key));[/U][/S]
[S][U]_data = "HiveEXT" callExtension _key;[/U][/S]
[S][U]sleep 0.1;[/U][/S]
[S][U]hiveInUse = false;[/U][/S]
[S][U]//Release HIVE[/U][/S]
[S][U]_result = call compile format ["%1", _data];[/U][/S]
[S][U]diag_log ("xSAVE: STATUS: " + str(_result));[/U][/S]
[S][U] _status = _result select 0;[/U][/S]
[S][U] if (_status == "CustomStreamStart") then {[/U][/S]
[S][U] _count = _result select 1; //Number of Rows[/U][/S]
[S][U] waitUntil{!hiveInUse};[/U][/S]
[S][U] hiveInUse = true; [/U][/S]
[S][U] for "_i" from 1 to _count do { [/U][/S]
[S][U] //Loop though the results[/U][/S]
[S][U] diag_log ("xSAVE: Retreving World Vehicle ID with: " + str(_key));[/U][/S]
[S][U] _data = "HiveEXT" callExtension _key;[/U][/S]
[S][U] _result = call compile format ["%1", _data];[/U][/S]
[S][U] _saveWorldVehicleID = _result select 0;[/U][/S]
[S][U] };[/U][/S]
[S][U] sleep 0.1;[/U][/S]
[S][U] hiveInUse = false;[/U][/S]
[S][U] diag_log ("xSAVE: Found world_vehicle.id: " + str(_saveWorldVehicleID));[/U][/S]
[S][U] //Now we have the world vehicle id, we can save this to the database[/U][/S]
[S][U] if (_saveWorldVehicleID > 0 ) then {[/U][/S]
[S][U] waitUntil{!hiveInUse};[/U][/S]
[S][U] hiveInUse = true;[/U][/S]
[S][U] _key = format["CHILD:999:CALL `proc_saveVehicle` ('?'):[%1]:",_saveWorldVehicleID];[/U][/S]
[S][U] diag_log ("xSAVE: Attempting to write to hive with: " + str(_key));[/U][/S]
[S][U] _data = "HiveEXT" callExtension _key;[/U][/S]
[S][U] sleep 0.2; [/U][/S]
[S][U] hiveInUse = false;[/U][/S]
[S][U] _result = call compile format ["%1", _data];[/U][/S]
[S][U] diag_log ("xSAVE: STATUS: " + str(_result));[/U][/S]
[S][U] _status = _result select 0;[/U][/S]
[S][U] if (_status == "CustomStreamStart") then {[/U][/S]
[S][U] _count = _result select 1;[/U][/S]
[S][U] waitUntil{!hiveInUse};[/U][/S]
[S][U] hiveInUse = true;[/U][/S]
[S][U] for "_i" from 1 to _count do {[/U][/S]
[S][U] _data = "HiveEXT" callExtension _key;[/U][/S]
[S][U] _result = call compile format ["%1", _data];[/U][/S]
[S][U] diag_log ("Vehicle ID Result" + str(_result));[/U][/S]
[S][U] _instanceVehicleID = _result select 0;[/U][/S]
[S][U] };[/U][/S]
[S][U] sleep 0.1;[/U][/S]
[S][U] hiveInUse = false;[/U][/S]
[S][U] };[/U][/S]
[S][U] _targetObj setVariable ["lastUpdate",time];[/U][/S]
[S][U] _targetObj setVariable ["ObjectID", str(_instanceVehicleID), true];[/U][/S]
[S][U] _targetObj setVariable ["CharacterID", "0", true];[/U][/S]
[S][U] _targetObj setVariable ["ObjectUID", "0", true];[/U][/S]
[S][U] _hitpoints = _targetObj call vehicle_getHitpoints;[/U][/S]
[S][U] _dam = 0.5;[/U][/S]
[S][U] _targetObj setFuel 0.5;[/U][/S]
[S][U] {[/U][/S]
[S][U] _selection = getText(configFile >> "cfgVehicles" >> typeOf _targetObj >> "HitPoints" >> _x >> "name");[/U][/S]
[S][U] [_targetObj,_selection,_dam] call object_setFixServer;[/U][/S]
[S][U] } forEach _hitpoints;[/U][/S]
[S][U] _targetObj call fnc_vehicleEventHandler; [/U][/S]
[S][U] dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_targetObj];[/U][/S]
[S][U] [_targetObj,"all"] call server_updateObject;[/U][/S]
[S][U] };[/U][/S]
[S][U] //End Save [/U][/S]
[S][U] };
Code:
2013-01-22 01:22:05 Database: [Error] Error 2014 (Commands out of sync; you can't run this command now) in MySQLQuery SQL: 'select world_vehicle.id from world_vehicle, vehicle where vehicle.id = world_vehicle.vehicle_id and vehicle.class_name = 'UH1H_DZ' and world_vehicle.world_id = '1' LIMIT 1'