From 4ef35e44c18def7ca33214ed5ef3b20057e7c63e Mon Sep 17 00:00:00 2001 From: dom Date: Sat, 4 Jan 2020 12:58:56 +0000 Subject: [PATCH 1/6] Initial commit --- AL.ini | 14 +++++----- Altis_Life.Altis/config/Config_SpyGlass.hpp | 2 +- Altis_Life.Altis/core/configuration.sqf | 1 - Altis_Life.Altis/core/fn_initCiv.sqf | 8 +++--- .../core/medical/fn_onPlayerKilled.sqf | 6 +--- Altis_Life.Altis/core/medical/fn_revived.sqf | 1 - .../core/session/fn_requestReceived.sqf | 8 ++---- .../core/session/fn_updatePartial.sqf | 28 +++++++++---------- .../core/session/fn_updateRequest.sqf | 13 ++++----- altislife.sql | 1 - .../Functions/MySQL/fn_queryRequest.sqf | 5 ++-- .../Functions/MySQL/fn_updatePartial.sqf | 14 +++++----- .../Functions/MySQL/fn_updateRequest.sqf | 19 ++++++------- .../Functions/Systems/fn_clientDisconnect.sqf | 4 +-- 14 files changed, 54 insertions(+), 70 deletions(-) diff --git a/AL.ini b/AL.ini index b23904e72..2d241e2a7 100755 --- a/AL.ini +++ b/AL.ini @@ -52,9 +52,9 @@ SQL1_INPUTS = 1 OUTPUT = 1-STRING, 2-STRING, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 [selectCiv] -SQL1_1 = SELECT pid, name, cash, bankacc, adminlevel, donorlevel, civ_licenses, arrested, civ_gear, civ_stats, civ_alive, civ_position, playtime FROM players WHERE pid = ? +SQL1_1 = SELECT pid, name, cash, bankacc, adminlevel, donorlevel, civ_licenses, arrested, civ_gear, civ_stats, civ_position, playtime FROM players WHERE pid = ? SQL1_INPUTS = 1 -OUTPUT = 1-STRING, 2-STRING, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 +OUTPUT = 1-STRING, 2-STRING, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 [selectIndep] SQL1_1 = SELECT pid, name, cash, bankacc, adminlevel, donorlevel, med_licenses, mediclevel, med_gear, med_stats, playtime FROM players WHERE pid = ? @@ -66,8 +66,8 @@ SQL1_1 = UPDATE players SET name = ?, cash = ?, bankacc = ?, cop_gear = ?, cop_l SQL1_INPUTS = 1, 2, 3, 4, 5, 6, 7, 8 [updateCiv] -SQL1_1 = UPDATE players SET name = ?, cash = ?, bankacc = ?, civ_licenses = ?, civ_gear = ?, arrested = ?, civ_stats = ?, civ_alive = ?, civ_position = ?, playtime = ? WHERE pid = ? -SQL1_INPUTS = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 +SQL1_1 = UPDATE players SET name = ?, cash = ?, bankacc = ?, civ_licenses = ?, civ_gear = ?, arrested = ?, civ_stats = ?, civ_position = ?, playtime = ? WHERE pid = ? +SQL1_INPUTS = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 [updateIndep] SQL1_1 = UPDATE players SET name = ?, cash = ?, bankacc = ?, med_licenses = ?, med_gear = ?, med_stats = ?, playtime = ? WHERE pid = ? @@ -106,11 +106,11 @@ SQL1_1 = UPDATE players SET med_gear = ? WHERE pid = ? SQL1_INPUTS = 1, 2 [updateCivPosition] -SQL1_1 = UPDATE players SET civ_alive = ?, civ_position = ? WHERE pid = ? -SQL1_INPUTS = 1, 2, 3 +SQL1_1 = UPDATE players SET civ_position = ? WHERE pid = ? +SQL1_INPUTS = 1, 2 [updateCivAlive] -SQL1_1 = UPDATE players SET civ_alive = '0' WHERE civ_alive = '1' +SQL1_1 = UPDATE players SET civ_position = '[]' WHERE civ_alive != '[]' [updateArrested] SQL1_1 = UPDATE players SET arrested = ? WHERE pid = ? diff --git a/Altis_Life.Altis/config/Config_SpyGlass.hpp b/Altis_Life.Altis/config/Config_SpyGlass.hpp index cbd535760..70602804c 100644 --- a/Altis_Life.Altis/config/Config_SpyGlass.hpp +++ b/Altis_Life.Altis/config/Config_SpyGlass.hpp @@ -354,7 +354,7 @@ class SpyGlass { { "ggs_shop", "OBJECT" }, { "reb_helicopter_1", "OBJECT" }, { "reb_helicopter_2", "OBJECT" }, { "life_inv_spikestrip", "SCALAR" }, { "license_civ_heroin", "BOOL" }, { "life_inv_waterbottle", "SCALAR" }, { "bis_oldlifestate", "STRING" }, { "life_inv_ornateraw", "SCALAR" }, { "life_id_revealobjects", "STRING" }, { "h1_3", "OBJECT" }, { "bis_pp_burnparams", "ARRAY" }, { "life_session_completed", "BOOL" }, { "license_civ_gun", "BOOL" }, { "license_cop_cair", "BOOL" }, { "bis_stackedeventhandlers_oneachframe", "ARRAY" }, { "bis_teamswitched", "BOOL" }, { "life_inv_rabbitraw", "SCALAR" }, { "life_inv_defibrillator", "SCALAR" }, { "life_inv_toolkit", "SCALAR" }, { "life_gear", "ARRAY" }, { "life_istazed", "BOOL" }, { "life_net_dropped", "BOOL"}, { "life_shop_npc", "OBJECT" }, { "life_shop_type", "STRING" }, { "life_deathcamera", "OBJECT" }, { "life_corpse", "OBJECT" }, { "life_admin_debug", "BOOL" }, { "bis_fnc_camera_target", "OBJECT" }, { "bis_fnc_camera_cam", "OBJECT" }, { "bis_fnc_camera_acctime", "SCALAR" }, { "bis_fnc_shownotification_process", "SCRIPT" }, { "bis_fnc_shownotification_counter", "SCALAR" }, { "bis_fnc_shownotification_queue", "ARRAY" }, - { "life_action_spikestrippickup", "SCALAR" }, { "life_container_active", "BOOL" }, { "life_cur_task", "TASK" }, { "life_cur_task", "OBJECT" }, { "life_enablenewsbroadcast", "BOOL" }, { "life_enablesidechannel", "BOOL" }, { "life_fed_scam", "OBJECT" }, { "life_coprecieve", "OBJECT" }, { "life_chopshop", "STRING" }, {"life_civ_position","ARRAY"}, {"life_is_alive","BOOL"}, {"finishedloop","BOOL"}, {"life_fnc_wantedcrimes","CODE"}, + { "life_action_spikestrippickup", "SCALAR" }, { "life_container_active", "BOOL" }, { "life_cur_task", "TASK" }, { "life_cur_task", "OBJECT" }, { "life_enablenewsbroadcast", "BOOL" }, { "life_enablesidechannel", "BOOL" }, { "life_fed_scam", "OBJECT" }, { "life_coprecieve", "OBJECT" }, { "life_chopshop", "STRING" }, {"life_civ_position","ARRAY"}, {"finishedloop","BOOL"}, {"life_fnc_wantedcrimes","CODE"}, {"ton_fnc_vehicleupdate","CODE"}, {"ton_fnc_recupkeyforhc","CODE"}, {"ton_fnc_getplaytime","CODE"}, {"ton_fnc_sellhousecontainer","CODE"}, {"ton_fnc_setplaytime","CODE"}, {"life_fnc_wantedprofupdate","CODE"}, {"ton_fnc_deletedbcontainer","CODE"}, {"life_save_civilian_position","BOOL"}, {"ton_fnc_addcontainer","CODE"}, {"ton_fnc_requestclientid","CODE"}, {"life_hideoutbuildings","ARRAY"},{"bis_fnc_initmodules_combatpatrol","GROUP"}, {"deltatime","SCALAR"}, {"bis_deltatime","SCALAR"}, {"life_storageplacing", "SCRIPT"}, {"bis_fnc_randomposintersection","CODE"}, {"bis_fnc_modulevanguardfob","CODE"}, {"bis_fnc_animatedbriefing","CODE"}, {"bis_fnc_reviveisvalidsecure","CODE"}, {"bis_fnc_modulevanguardobjective","CODE"}, {"bis_fnc_animatedopening","CODE"}, {"bis_fnc_modulevanguardscorepersistence","CODE"}, {"bis_fnc_revivesecureunit","CODE"} }; diff --git a/Altis_Life.Altis/core/configuration.sqf b/Altis_Life.Altis/core/configuration.sqf index 5f70b0cc7..805722812 100644 --- a/Altis_Life.Altis/core/configuration.sqf +++ b/Altis_Life.Altis/core/configuration.sqf @@ -71,7 +71,6 @@ life_carryWeight = 0; //Represents the players current inventory weight (MUST ST life_net_dropped = false; life_use_atm = true; life_is_arrested = false; -life_is_alive = false; life_delivery_in_progress = false; life_thirst = 100; life_hunger = 100; diff --git a/Altis_Life.Altis/core/fn_initCiv.sqf b/Altis_Life.Altis/core/fn_initCiv.sqf index fa922a0ee..07a6f4ab6 100644 --- a/Altis_Life.Altis/core/fn_initCiv.sqf +++ b/Altis_Life.Altis/core/fn_initCiv.sqf @@ -16,11 +16,12 @@ civ_spawn_3 = nearestObjects[getMarkerPos "civ_spawn_3", _spawnBuildings,350]; civ_spawn_4 = nearestObjects[getMarkerPos "civ_spawn_4", _spawnBuildings,350]; waitUntil {!(isNull (findDisplay 46))}; -if (life_is_alive && !life_is_arrested) then { +private _alive = !(life_civ_position isEqualTo []); +if (_alive && !life_is_arrested) then { /* Spawn at our last position */ player setVehiclePosition [life_civ_position, [], 0, "CAN_COLLIDE"]; } else { - if (!life_is_alive && !life_is_arrested) then { + if (!_alive && !life_is_arrested) then { if (LIFE_SETTINGS(getNumber,"save_civilian_positionStrict") isEqualTo 1) then { [] call life_fnc_startLoadout; CASH = 0; @@ -35,5 +36,4 @@ if (life_is_alive && !life_is_arrested) then { [player,true] spawn life_fnc_jail; }; }; -}; -life_is_alive = true; \ No newline at end of file +}; \ No newline at end of file diff --git a/Altis_Life.Altis/core/medical/fn_onPlayerKilled.sqf b/Altis_Life.Altis/core/medical/fn_onPlayerKilled.sqf index 49e8d0c45..e92186d02 100644 --- a/Altis_Life.Altis/core/medical/fn_onPlayerKilled.sqf +++ b/Altis_Life.Altis/core/medical/fn_onPlayerKilled.sqf @@ -142,13 +142,9 @@ life_hunger = 100; life_thirst = 100; life_carryWeight = 0; CASH = 0; -life_is_alive = false; [] call life_fnc_hudUpdate; //Get our HUD updated. [player,life_settings_enableSidechannel,playerSide] remoteExecCall ["TON_fnc_manageSC",RSERV]; [0] call SOCK_fnc_updatePartial; -[3] call SOCK_fnc_updatePartial; -if (playerSide isEqualTo civilian) then { - [4] call SOCK_fnc_updatePartial; -}; +[3] call SOCK_fnc_updatePartial; \ No newline at end of file diff --git a/Altis_Life.Altis/core/medical/fn_revived.sqf b/Altis_Life.Altis/core/medical/fn_revived.sqf index b6927b774..0d06cbf2f 100644 --- a/Altis_Life.Altis/core/medical/fn_revived.sqf +++ b/Altis_Life.Altis/core/medical/fn_revived.sqf @@ -35,7 +35,6 @@ life_corpse setVariable ["name",nil,true]; deleteVehicle life_corpse; life_action_inUse = false; -life_is_alive = true; player setVariable ["Revive",nil,true]; player setVariable ["name",nil,true]; diff --git a/Altis_Life.Altis/core/session/fn_requestReceived.sqf b/Altis_Life.Altis/core/session/fn_requestReceived.sqf index 8a349d3c0..d562231c9 100755 --- a/Altis_Life.Altis/core/session/fn_requestReceived.sqf +++ b/Altis_Life.Altis/core/session/fn_requestReceived.sqf @@ -73,11 +73,9 @@ switch (playerSide) do { //Position if (LIFE_SETTINGS(getNumber,"save_civilian_position") isEqualTo 1) then { - life_is_alive = _this select 10; - life_civ_position = _this select 11; - if (life_is_alive) then { - if !(count life_civ_position isEqualTo 3) then {diag_log format ["[requestReceived] Bad position received. Data: %1",life_civ_position];life_is_alive =false;}; - if (life_civ_position distance (getMarkerPos "respawn_civilian") < 300) then {life_is_alive = false;}; + life_civ_position = _this select 10; + if !(life_civ_position isEqualTo []) then { + if (life_civ_position distance (getMarkerPos "respawn_civilian") < 300) then {life_civ_position = []}; }; }; diff --git a/Altis_Life.Altis/core/session/fn_updatePartial.sqf b/Altis_Life.Altis/core/session/fn_updatePartial.sqf index 8f8e6a1d3..a8c659abd 100644 --- a/Altis_Life.Altis/core/session/fn_updatePartial.sqf +++ b/Altis_Life.Altis/core/session/fn_updatePartial.sqf @@ -8,47 +8,47 @@ meant to keep the network traffic down with large sums of data flowing through remoteExec */ -private ["_mode","_packet","_array","_flag"]; -_mode = param [0,0,[0]]; -_packet = [getPlayerUID player,playerSide,nil,_mode]; -_array = []; -_flag = switch (playerSide) do {case west: {"cop"}; case civilian: {"civ"}; case independent: {"med"};}; +params [ + ["_mode",0,[0]] +]; +private _packet = [player,_mode]; switch (_mode) do { case 0: { - _packet set[2,CASH]; + _packet pushBack CASH; }; case 1: { - _packet set[2,BANK]; + _packet pushBack BANK; }; case 2: { + private _array = []; + private _flag = switch (playerSide) do {case west: {"cop"}; case civilian: {"civ"}; case independent: {"med"};}; { _varName = LICENSE_VARNAME(configName _x,_flag); _array pushBack [_varName,LICENSE_VALUE(configName _x,_flag)]; } forEach (format ["getText(_x >> 'side') isEqualTo '%1'",_flag] configClasses (missionConfigFile >> "Licenses")); - _packet set[2,_array]; + _packet pushBack _array; }; case 3: { [] call life_fnc_saveGear; - _packet set[2,life_gear]; + _packet pushBack life_gear; }; case 4: { - _packet set[2,life_is_alive]; - _packet set[4,getPosATL player]; + //old location }; case 5: { - _packet set[2,life_is_arrested]; + _packet pushBack life_is_arrested; }; case 6: { - _packet set[2,CASH]; - _packet set[4,BANK]; + _packet pushBack CASH; + _packet pushBack BANK; }; case 7: { diff --git a/Altis_Life.Altis/core/session/fn_updateRequest.sqf b/Altis_Life.Altis/core/session/fn_updateRequest.sqf index df40ceaad..61e485418 100644 --- a/Altis_Life.Altis/core/session/fn_updateRequest.sqf +++ b/Altis_Life.Altis/core/session/fn_updateRequest.sqf @@ -7,11 +7,10 @@ Passes ALL player information to the server to save player data to the database. */ private ["_packet","_array","_flag","_alive","_position"]; -_packet = [getPlayerUID player,(profileName),playerSide,CASH,BANK]; -_array = []; -_alive = alive player; -_position = getPosATL player; -_flag = switch (playerSide) do {case west: {"cop"}; case civilian: {"civ"}; case independent: {"med"};}; +private _packet = [player,CASH,BANK]; +private _array = []; + +private _flag = switch (playerSide) do {case west: {"cop"}; case civilian: {"civ"}; case independent: {"med"};}; { _varName = LICENSE_VARNAME(configName _x,_flag); @@ -29,11 +28,9 @@ _array pushBack life_thirst; _array pushBack (damage player); _packet pushBack _array; -switch (playerSide) do { +switch playerSide do { case civilian: { _packet pushBack life_is_arrested; - _packet pushBack _alive; - _packet pushBack _position; }; }; diff --git a/altislife.sql b/altislife.sql index 810f3e74e..9ffe33659 100755 --- a/altislife.sql +++ b/altislife.sql @@ -94,7 +94,6 @@ CREATE TABLE IF NOT EXISTS `players` ( `adminlevel` ENUM('0','1','2','3','4','5') NOT NULL DEFAULT '0', `donorlevel` ENUM('0','1','2','3','4','5') NOT NULL DEFAULT '0', `blacklist` TINYINT NOT NULL DEFAULT 0, - `civ_alive` TINYINT NOT NULL DEFAULT 0, `civ_position` VARCHAR(32) NOT NULL DEFAULT '[]', `playtime` VARCHAR(32) NOT NULL DEFAULT '[0,0,0]', `insert_time` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, diff --git a/life_server/Functions/MySQL/fn_queryRequest.sqf b/life_server/Functions/MySQL/fn_queryRequest.sqf index de92704f0..2ddabd9f2 100755 --- a/life_server/Functions/MySQL/fn_queryRequest.sqf +++ b/life_server/Functions/MySQL/fn_queryRequest.sqf @@ -24,7 +24,7 @@ _ownerID = owner _ownerID; private _query = switch (_side) do { // West - 11 entries returned case west: {format ["selectWest:%1", _uid];}; - // Civilian - 12 entries returned + // Civilian - 11 entries returned case civilian: {format ["selectCiv:%1", _uid];}; // Independent - 10 entries returned case independent: {format ["selectIndep:%1",_uid];}; @@ -57,9 +57,8 @@ private "_playTimes"; switch (_side) do { case civilian: { _queryResult set[7, [false, true] select (_queryResult select 7)]; - _queryResult set[10, [false, true] select (_queryResult select 10)]; - _playTimes = _queryResult select 12; + _playTimes = _queryResult select 11; [_uid, _playTimes select 2] call TON_fnc_setPlayTime; /* Make sure nothing else is added under here */ diff --git a/life_server/Functions/MySQL/fn_updatePartial.sqf b/life_server/Functions/MySQL/fn_updatePartial.sqf index 4c573ca66..92bd4d287 100755 --- a/life_server/Functions/MySQL/fn_updatePartial.sqf +++ b/life_server/Functions/MySQL/fn_updatePartial.sqf @@ -8,14 +8,15 @@ */ params [ - ["_uid", "", [""]], - ["_side", sideUnknown, [civilian]], - "_value", + ["_unit",objNull,[objNull]], ["_mode", -1, [0]], + "_value", "_value1" ]; -if (_uid isEqualTo "" || {_side isEqualTo sideUnknown}) exitWith {}; //Bad. +if (isNull _unit) exitWith {}; //Bad. +private _uid = getPlayerUID _unit; +private _side = side _unit; private _query = ""; switch (_mode) do { @@ -49,9 +50,8 @@ switch (_mode) do { }; case 4: { - _value = [0, 1] select _value; - _value1 = if (count _value1 isEqualTo 3) then {_value1} else {[0,0,0]}; - _query = format ["updateCivPosition:%1:%2:%3", _value, _value1, _uid]; + private _position = if (alive _unit) then {getPosATL _unit} else {[]}; + _query = format ["updateCivPosition:%1:%2", _position, _uid]; }; case 5: { diff --git a/life_server/Functions/MySQL/fn_updateRequest.sqf b/life_server/Functions/MySQL/fn_updateRequest.sqf index 7d0f11668..9ace1b317 100755 --- a/life_server/Functions/MySQL/fn_updateRequest.sqf +++ b/life_server/Functions/MySQL/fn_updateRequest.sqf @@ -8,26 +8,25 @@ */ params [ - ["_uid", "", [""]], - ["_name", "", [""]], - ["_side", sideUnknown, [civilian]], + ["_unit",objNull,[objNull]], ["_cash", 0, [0]], ["_bank", 5000, [0]], ["_licenses", [], [[]]], ["_gear", [], [[]]], ["_stats", [100,100],[[]]], - ["_arrested", false, [true]], - ["_alive", false, [true]], - ["_position", [], [[]]] + ["_arrested", false, [true]] ]; //Get to those error checks. -if (_uid isEqualTo "" || {_name isEqualTo ""}) exitWith {}; +if (isNull _unit) exitWith {}; //Setup some data. -_position = if (_side isEqualTo civilian) then {_position} else {[]}; +private _uid = getPlayerUID _unit; +private _name = name _unit; +private _side = side _unit; +private _alive = alive _unit; +private _position = if (_side isEqualTo civilian && {alive _unit}) then {getPosATL _unit} else {[]}; _arrested = [0, 1] select _arrested; -_alive = [0, 1] select _alive; for "_i" from 0 to (count _licenses) -1 do { (_licenses select _i) params ["_license", "_owned"]; @@ -52,7 +51,7 @@ switch (_side) do { private _query = switch (_side) do { case west: {format ["updateWest:%1:%2:%3:%4:%5:%6:%7:%8", _name, _cash, _bank, _gear, _licenses, _stats, _playtime_update, _uid];}; - case civilian: {format ["updateCiv:%1:%2:%3:%4:%5:%6:%7:%8:%9:%10:%11", _name, _cash, _bank, _licenses, _gear, _arrested, _stats, _alive, _position, _playtime_update, _uid];}; + case civilian: {format ["updateCiv:%1:%2:%3:%4:%5:%6:%7:%8:%9:%10", _name, _cash, _bank, _licenses, _gear, _arrested, _stats, _position, _playtime_update, _uid];}; case independent: {format ["updateIndep:%1:%2:%3:%4:%5:%6:%7:%8", _name, _cash, _bank, _licenses, _gear, _stats, _playtime_update, _uid];}; }; diff --git a/life_server/Functions/Systems/fn_clientDisconnect.sqf b/life_server/Functions/Systems/fn_clientDisconnect.sqf index f8edf4c17..6d66eadf3 100644 --- a/life_server/Functions/Systems/fn_clientDisconnect.sqf +++ b/life_server/Functions/Systems/fn_clientDisconnect.sqf @@ -17,10 +17,8 @@ if (isNull _unit) exitWith {}; //Save civilian position if (life_save_civilian_position && {side _unit isEqualTo civilian}) then { if (isNil "HC_UID" || {!(_uid isEqualTo HC_UID)}) then { - private _position = getPosATL _unit; if ((getMarkerPos "respawn_civilian" distance _position) > 300) then { - private _alive = alive _unit; - if (life_HC_isActive) then {[_uid,civilian,_alive,4,_position] remoteExec ["HC_fnc_updatePartial",HC_Life]} else {[_uid,civilian,_alive,4,_position] spawn DB_fnc_updatePartial}; + if (life_HC_isActive) then {[_unit,4] remoteExec ["HC_fnc_updatePartial",HC_Life]} else {[_unit,4] spawn DB_fnc_updatePartial}; }; }; }; From 358ccc7ee399d7d5261a59663f1f74e7fb1df40c Mon Sep 17 00:00:00 2001 From: dom Date: Sat, 4 Jan 2020 15:02:04 +0000 Subject: [PATCH 2/6] Query update --- AL.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AL.ini b/AL.ini index 2d241e2a7..ba06c7d36 100755 --- a/AL.ini +++ b/AL.ini @@ -110,7 +110,7 @@ SQL1_1 = UPDATE players SET civ_position = ? WHERE pid = ? SQL1_INPUTS = 1, 2 [updateCivAlive] -SQL1_1 = UPDATE players SET civ_position = '[]' WHERE civ_alive != '[]' +SQL1_1 = UPDATE players SET civ_position = '[]' WHERE civ_position != '[]' [updateArrested] SQL1_1 = UPDATE players SET arrested = ? WHERE pid = ? From 61ee5892684936d886047717efd020752d62287b Mon Sep 17 00:00:00 2001 From: dom Date: Sat, 4 Jan 2020 23:43:54 +0000 Subject: [PATCH 3/6] HC --- .../core/session/fn_updateRequest.sqf | 1 - life_hc/MySQL/General/fn_queryRequest.sqf | 5 ++--- life_hc/MySQL/General/fn_updatePartial.sqf | 14 +++++++------- life_hc/MySQL/General/fn_updateRequest.sqf | 19 +++++++++---------- 4 files changed, 18 insertions(+), 21 deletions(-) diff --git a/Altis_Life.Altis/core/session/fn_updateRequest.sqf b/Altis_Life.Altis/core/session/fn_updateRequest.sqf index 61e485418..4c74050a6 100644 --- a/Altis_Life.Altis/core/session/fn_updateRequest.sqf +++ b/Altis_Life.Altis/core/session/fn_updateRequest.sqf @@ -6,7 +6,6 @@ Description: Passes ALL player information to the server to save player data to the database. */ -private ["_packet","_array","_flag","_alive","_position"]; private _packet = [player,CASH,BANK]; private _array = []; diff --git a/life_hc/MySQL/General/fn_queryRequest.sqf b/life_hc/MySQL/General/fn_queryRequest.sqf index b70224edd..d210dd596 100755 --- a/life_hc/MySQL/General/fn_queryRequest.sqf +++ b/life_hc/MySQL/General/fn_queryRequest.sqf @@ -25,7 +25,7 @@ if (isNull _ownerID) exitWith {}; private _query = switch (_side) do { // West - 11 entries returned case west: {format ["selectWest:%1", _uid];}; - // Civilian - 12 entries returned + // Civilian - 11 entries returned case civilian: {format ["selectCiv:%1", _uid];}; // Independent - 10 entries returned case independent: {format ["selectIndep:%1",_uid];}; @@ -58,9 +58,8 @@ private "_playTimes"; switch (_side) do { case civilian: { _queryResult set[7, [false, true] select (_queryResult select 7)]; - _queryResult set[10, [false, true] select (_queryResult select 10)]; - _playTimes = _queryResult select 12; + _playTimes = _queryResult select 11; /* Make sure nothing else is added under here */ _houseData = _uid spawn TON_fnc_fetchPlayerHouses; diff --git a/life_hc/MySQL/General/fn_updatePartial.sqf b/life_hc/MySQL/General/fn_updatePartial.sqf index 498f05af3..5d96f8748 100755 --- a/life_hc/MySQL/General/fn_updatePartial.sqf +++ b/life_hc/MySQL/General/fn_updatePartial.sqf @@ -10,14 +10,15 @@ */ params [ - ["_uid", "", [""]], - ["_side", sideUnknown, [civilian]], - "_value", + ["_unit",objNull,[objNull]], ["_mode", -1, [0]], + "_value", "_value1" ]; -if (_uid isEqualTo "" || {_side isEqualTo sideUnknown}) exitWith {}; //Bad. +if (isNull _unit) exitWith {}; //Bad. +private _uid = getPlayerUID _unit; +private _side = side _unit; private _query = ""; switch (_mode) do { @@ -51,9 +52,8 @@ switch (_mode) do { }; case 4: { - _value = [0, 1] select _value; - _value1 = if (count _value1 isEqualTo 3) then {_value1} else {[0,0,0]}; - _query = format ["updateCivPosition:%1:%2:%3", _value, _value1, _uid]; + private _position = if (alive _unit) then {getPosATL _unit} else {[]}; + _query = format ["updateCivPosition:%1:%2", _position, _uid]; }; case 5: { diff --git a/life_hc/MySQL/General/fn_updateRequest.sqf b/life_hc/MySQL/General/fn_updateRequest.sqf index 67292ac1e..d3cc3bf57 100755 --- a/life_hc/MySQL/General/fn_updateRequest.sqf +++ b/life_hc/MySQL/General/fn_updateRequest.sqf @@ -10,26 +10,25 @@ */ params [ - ["_uid", "", [""]], - ["_name", "", [""]], - ["_side", sideUnknown, [civilian]], + ["_unit",objNull,[objNull]], ["_cash", 0, [0]], ["_bank", 5000, [0]], ["_licenses", [], [[]]], ["_gear", [], [[]]], ["_stats", [100,100],[[]]], - ["_arrested", false, [true]], - ["_alive", false, [true]], - ["_position", [], [[]]] + ["_arrested", false, [true]] ]; //Get to those error checks. -if (_uid isEqualTo "" || {_name isEqualTo ""}) exitWith {}; +if (isNull _unit) exitWith {}; //Setup some data. -_position = if (_side isEqualTo civilian) then {_position} else {[]}; +private _uid = getPlayerUID _unit; +private _name = name _unit; +private _side = side _unit; +private _alive = alive _unit; +private _position = if (_side isEqualTo civilian && {alive _unit}) then {getPosATL _unit} else {[]}; _arrested = [0, 1] select _arrested; -_alive = [0, 1] select _alive; for "_i" from 0 to (count _licenses) -1 do { (_licenses select _i) params ["_license", "_owned"]; @@ -54,7 +53,7 @@ switch (_side) do { private _query = switch (_side) do { case west: {format ["updateWest:%1:%2:%3:%4:%5:%6:%7:%8", _name, _cash, _bank, _gear, _licenses, _stats, _playtime_update, _uid];}; - case civilian: {format ["updateCiv:%1:%2:%3:%4:%5:%6:%7:%8:%9:%10:%11", _name, _cash, _bank, _licenses, _gear, _arrested, _stats, _alive, _position, _playtime_update, _uid];}; + case civilian: {format ["updateCiv:%1:%2:%3:%4:%5:%6:%7:%8:%9:%10", _name, _cash, _bank, _licenses, _gear, _arrested, _stats, _position, _playtime_update, _uid];}; case independent: {format ["updateIndep:%1:%2:%3:%4:%5:%6:%7:%8", _name, _cash, _bank, _licenses, _gear, _stats, _playtime_update, _uid];}; }; From 8f7db896ef3464d8e597f85429eb2c76981764bf Mon Sep 17 00:00:00 2001 From: Dom Date: Wed, 1 Apr 2020 10:31:48 +0100 Subject: [PATCH 4/6] Add back civ_alive --- AL.ini | 704 +++++++++--------- Altis_Life.Altis/core/fn_initCiv.sqf | 78 +- .../core/session/fn_requestReceived.sqf | 224 +++--- .../core/session/fn_updatePartial.sqf | 122 ++- altislife.sql | 497 +++++++------ life_hc/MySQL/General/fn_queryRequest.sqf | 207 ++--- life_hc/MySQL/General/fn_updatePartial.sqf | 151 ++-- life_hc/MySQL/General/fn_updateRequest.sqf | 122 +-- .../Functions/MySQL/fn_queryRequest.sqf | 199 ++--- .../Functions/MySQL/fn_updatePartial.sqf | 143 ++-- .../Functions/MySQL/fn_updateRequest.sqf | 116 +-- 11 files changed, 1280 insertions(+), 1283 deletions(-) diff --git a/AL.ini b/AL.ini index ba06c7d36..f9ecbfe20 100755 --- a/AL.ini +++ b/AL.ini @@ -1,352 +1,352 @@ -[Default] - -Version = 1 -;; Used incase there is ever a breaking change, or to inform user in log about a new feature. - -Strip Chars = ";[]" -;; List of characters to strip out -Strip Chars Mode = 0 -;; 0 = Strip Bad Chars, 1 = Strip + Log Bad Chars, 2 = Return Error & Log Bad Chars -;; Note: Logging on works when sending data to database. - -Input SQF Parser = false -;; Expermential -;; If enabled will use SQF Array Parser instead of : seperator for values -;; i.e 0:SQL:UpdatePlayer:["Joe",[1,2,0],0.22333,"PlayerBackpack",-3] -;; Advantage is that you don't need to strip : seperator from user inputted values - -[resetLifeVehicles] -SQL1_1 = CALL resetLifeVehicles - -[deleteOldHouses] -SQL1_1 = CALL deleteOldHouses - -[deleteDeadVehicles] -SQL1_1 = CALL deleteDeadVehicles - -[deleteOldGangs] -SQL1_1 = CALL deleteOldGangs - -[deleteOldContainers] -SQL1_1 = CALL deleteOldContainers - - - -[checkPlayerExists] -SQL1_1 = SELECT pid, name FROM players WHERE pid = ? -SQL1_INPUTS = 1 -OUTPUT = 1-STRING, 2-STRING - -[selectName] -SQL1_1 = SELECT name FROM players WHERE pid = ? -SQL1_INPUTS = 1 -OUTPUT = 1-STRING - -[insertNewPlayer] -SQL1_1 = INSERT INTO players (pid, name, cash, bankacc, aliases, cop_licenses, med_licenses, civ_licenses, civ_gear, cop_gear, med_gear) VALUES (?, ?, ?, ?, ?,'[]','[]','[]','[]','[]','[]') -SQL1_INPUTS = 1, 2, 3, 4, 5 - -[selectWest] -SQL1_1 = SELECT pid, name, cash, bankacc, adminlevel, donorlevel, cop_licenses, coplevel, cop_gear, blacklist, cop_stats, playtime FROM players WHERE pid = ? -SQL1_INPUTS = 1 -OUTPUT = 1-STRING, 2-STRING, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 - -[selectCiv] -SQL1_1 = SELECT pid, name, cash, bankacc, adminlevel, donorlevel, civ_licenses, arrested, civ_gear, civ_stats, civ_position, playtime FROM players WHERE pid = ? -SQL1_INPUTS = 1 -OUTPUT = 1-STRING, 2-STRING, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 - -[selectIndep] -SQL1_1 = SELECT pid, name, cash, bankacc, adminlevel, donorlevel, med_licenses, mediclevel, med_gear, med_stats, playtime FROM players WHERE pid = ? -SQL1_INPUTS = 1 -OUTPUT = 1-STRING, 2-STRING, 3, 4, 5, 6, 7, 8, 9, 10, 11 - -[updateWest] -SQL1_1 = UPDATE players SET name = ?, cash = ?, bankacc = ?, cop_gear = ?, cop_licenses = ?, cop_stats = ?, playtime = ? WHERE pid = ? -SQL1_INPUTS = 1, 2, 3, 4, 5, 6, 7, 8 - -[updateCiv] -SQL1_1 = UPDATE players SET name = ?, cash = ?, bankacc = ?, civ_licenses = ?, civ_gear = ?, arrested = ?, civ_stats = ?, civ_position = ?, playtime = ? WHERE pid = ? -SQL1_INPUTS = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 - -[updateIndep] -SQL1_1 = UPDATE players SET name = ?, cash = ?, bankacc = ?, med_licenses = ?, med_gear = ?, med_stats = ?, playtime = ? WHERE pid = ? -SQL1_INPUTS = 1, 2, 3, 4, 5, 6, 7, 8 - -[updateCash] -SQL1_1 = UPDATE players SET cash = ? WHERE pid = ? -SQL1_INPUTS = 1, 2 - -[updateBank] -SQL1_1 = UPDATE players SET bankacc = ? WHERE pid = ? -SQL1_INPUTS = 1, 2 - -[updateWestLicenses] -SQL1_1 = UPDATE players SET cop_licenses = ? WHERE pid = ? -SQL1_INPUTS = 1, 2 - -[updateCivLicenses] -SQL1_1 = UPDATE players SET civ_licenses = ? WHERE pid = ? -SQL1_INPUTS = 1, 2 - -[updateIndepLicenses] -SQL1_1 = UPDATE players SET med_licenses = ? WHERE pid = ? -SQL1_INPUTS = 1, 2 - -[updateWestGear] -SQL1_1 = UPDATE players SET cop_gear = ? WHERE pid = ? -SQL1_INPUTS = 1, 2 - -[updateCivGear] -SQL1_1 = UPDATE players SET civ_gear = ? WHERE pid = ? -SQL1_INPUTS = 1, 2 - -[updateIndepGear] -SQL1_1 = UPDATE players SET med_gear = ? WHERE pid = ? -SQL1_INPUTS = 1, 2 - -[updateCivPosition] -SQL1_1 = UPDATE players SET civ_position = ? WHERE pid = ? -SQL1_INPUTS = 1, 2 - -[updateCivAlive] -SQL1_1 = UPDATE players SET civ_position = '[]' WHERE civ_position != '[]' - -[updateArrested] -SQL1_1 = UPDATE players SET arrested = ? WHERE pid = ? -SQL1_INPUTS = 1, 2 - -[updateCashAndBank] -SQL1_1 = UPDATE players SET cash = ?, bankacc = ? WHERE pid = ? -SQL1_INPUTS = 1, 2, 3 - - - -[selectPlayerGang] -SQL1_1 = SELECT id, owner, name, maxmembers, bank, members FROM gangs WHERE active = '1' AND members LIKE ? -SQL1_INPUTS = 1 -OUTPUT = 1, 2-STRING, 3-STRING, 4, 5, 6 - -[selectGangID] -SQL1_1 = SELECT id FROM gangs WHERE name = ? AND active = '1' -SQL1_INPUTS = 1 - -[selectGangIDFromMembers] -SQL1_1 = SELECT id FROM gangs WHERE members LIKE ? AND active = '1' -SQL1_INPUTS = 1 - -[selectGangIDFromOwner] -SQL1_1 = SELECT id FROM gangs WHERE owner = ? AND active = '1' -SQL1_INPUTS = 1 - -[selectInactiveGang] -SQL1_1 = SELECT id, active FROM gangs WHERE name = ? AND active = '0' -SQL1_INPUTS = 1 - -[updateGang] -SQL1_1 = UPDATE gangs SET active = '1', owner = ?, members = ? WHERE id = ? -SQL1_INPUTS = 1, 2, 3 - -[updateGang1] -SQL1_1 = UPDATE gangs SET bank = ?, maxmembers = ?, owner = ? WHERE id = ? -SQL1_INPUTS = 1, 2, 3, 4 - -[updateGangBank] -SQL1_1 = UPDATE gangs SET bank = ? WHERE id = ? -SQL1_INPUTS = 1, 2 - -[updateGangMembers] -SQL1_1 = UPDATE gangs SET members = ? WHERE id = ? -SQL1_INPUTS = 1, 2 - -[updateGangMaxmembers] -SQL1_1 = UPDATE gangs SET maxmembers = ? WHERE id = ? -SQL1_INPUTS = 1, 2 - -[updateGangOwner] -SQL1_1 = UPDATE gangs SET owner = ? WHERE id = ? -SQL1_INPUTS = 1, 2 - -[insertGang] -SQL1_1 = INSERT INTO gangs (owner, name, members) VALUES (?, ?, ?) -SQL1_INPUTS = 1, 2, 3 - -[deleteGang] -SQL1_1 = UPDATE gangs SET active = '0' WHERE id = ? -SQL1_INPUTS = 1 - - - -[insertHouse] -SQL1_1 = INSERT INTO houses (pid, pos, owned) VALUES (?, ?, '1') -SQL1_INPUTS = 1, 2 - -[selectHouseID] -SQL1_1 = SELECT id FROM houses WHERE pos = ? AND pid = ? AND owned = '1' -SQL1_INPUTS = 1, 2 - -[selectAllHouses] -SQL1_1 = SELECT COUNT(*) FROM houses WHERE owned = '1' - -[selectPlayerHouses] -SQL1_1 = SELECT houses.id, houses.pid, houses.pos, players.name, houses.garage FROM houses INNER JOIN players WHERE houses.owned = '1' AND houses.pid = players.pid LIMIT ?, 10 -SQL1_INPUTS = 1 -OUTPUT = 1, 2-STRING, 3, 4-STRING, 5 - -[selectHousePositions] -SQL1_1 = SELECT pid, pos FROM houses WHERE pid = ? AND owned = '1' -SQL1_INPUTS = 1 -OUTPUT = 1-STRING, 2 - -[updateHouseTrunk] -SQL1_1 = UPDATE containers SET inventory = ? WHERE id = ? -SQL1_INPUTS = 1, 2 - -[deleteHouse] -SQL1_1 = UPDATE houses SET owned = '0', pos = '[]' WHERE pid = ? AND pos = ? AND owned = '1' -SQL1_INPUTS = 1, 2 - -[deleteHouse1] -SQL1_1 = UPDATE houses SET owned = '0', pos = '[]' WHERE id = ? -SQL1_INPUTS = 1 - -[updateGarage] -SQL1_1 = UPDATE houses SET garage = ? WHERE pid = ? AND pos = ? -SQL1_INPUTS = 1, 2, 3 - -[selectContainerPositions] -SQL1_1 = SELECT pid, pos FROM containers WHERE pid = ? AND owned = '1' -SQL1_INPUTS = 1 -OUTPUT = 1-STRING, 2 - -[selectContainers] -SQL1_1 = SELECT pid, pos, classname, inventory, gear, dir, id FROM containers WHERE pid = ? AND owned = '1' -SQL1_INPUTS = 1 -OUTPUT = 1-STRING, 2, 3-STRING, 4, 5, 6, 7 - -[selectContainerID] -SQL1_1 = SELECT id FROM containers WHERE pos = ? AND pid = ? AND owned = '1' -SQL1_INPUTS = 1, 2 - -[insertContainer] -SQL1_1 = INSERT INTO containers (pid, pos, classname, inventory, gear, owned, dir) VALUES (?, ?, ?, '[[],0]', '[]', '1', ?) -SQL1_INPUTS = 1, 2, 3, 4 - -[updateContainer] -SQL1_1 = UPDATE containers SET gear = ? WHERE id = ? -SQL1_INPUTS = 1, 2 - -[deleteContainer] -SQL1_1 = UPDATE containers SET owned = '0', pos = '[]' WHERE pid = ? AND pos = ? AND owned = '1' -SQL1_INPUTS = 1, 2 - -[deleteContainer1] -SQL1_1 = UPDATE containers SET owned = '0', pos = '[]' WHERE id = ? -SQL1_INPUTS = 1 - - - - -[selectVehicles] -SQL1_1 = SELECT id, side, classname, type, pid, alive, active, plate, color FROM vehicles WHERE pid = ? AND alive = '1' AND active = '0' AND side = ? AND type = ? -SQL1_INPUTS = 1, 2, 3 -OUTPUT = 1, 2-STRING, 3-STRING, 4-STRING, 5-STRING, 6, 7, 8, 9 - -[selectVehiclesMore] -SQL1_1 = SELECT id, side, classname, type, pid, alive, active, plate, color, inventory, gear, fuel, damage, blacklist FROM vehicles WHERE id = ? AND pid = ? -SQL1_INPUTS = 1, 2 -OUTPUT = 1, 2-STRING, 3-STRING, 4-STRING, 5-STRING, 6, 7, 8, 9, 10, 11, 12, 13, 14 - -[updateVehicle] -SQL1_1 = UPDATE vehicles SET active = '1' WHERE pid = ? AND id = ? -SQL1_INPUTS = 1, 2 - -[updateVehicleBlacklist] -SQL1_1 = UPDATE vehicles SET blacklist = '0' WHERE id = ? AND pid = ? -SQL1_INPUTS = 1, 2 - -[updateVehicleBlacklistPlate] -SQL1_1 = UPDATE vehicles SET blacklist = '1' WHERE pid = ? AND plate = ? -SQL1_INPUTS = 1, 2 - -[updateVehicleFuel] -SQL1_1 = UPDATE vehicles SET active = '0', fuel = ?, damage = ? WHERE pid = ? AND plate = ? -SQL1_INPUTS = 1, 2, 3, 4 - -[updateVehicleAll] -SQL1_1 = UPDATE vehicles SET active = '0', inventory = ?, gear = ?, fuel = ?, damage = ? WHERE pid = ? AND plate = ? -SQL1_INPUTS = 1, 2, 3, 4, 5, 6 - -[updateVehicleGear] -SQL1_1 = UPDATE vehicles SET gear = ? WHERE pid = ? AND plate = ? -SQL1_INPUTS = 1, 2, 3 - -[updateVehicleTrunk] -SQL1_1 = UPDATE vehicles SET inventory = ? WHERE pid = ? AND plate = ? -SQL1_INPUTS = 1, 2, 3 - -[insertVehicle] -SQL1_1 = INSERT INTO vehicles (side, classname, type, pid, alive, active, inventory, color, plate, gear, damage) VALUES (?, ?, ?, ?, '1','1','[[],0]', ?, ?,'[]','[]') -SQL1_INPUTS = 1, 2, 3, 4, 5, 6 - -[deleteVehicle] -SQL1_1 = UPDATE vehicles SET alive = '0' WHERE pid = ? AND plate = ? -SQL1_INPUTS = 1, 2 - -[deleteVehicleID] -SQL1_1 = UPDATE vehicles SET alive = '0' WHERE pid = ? AND id = ? -SQL1_INPUTS = 1, 2 - -[cleanupVehicle] -SQL1_1 = UPDATE vehicles SET active = '0', fuel = ? WHERE pid = ? AND plate = ? -SQL1_INPUTS = 1, 2, 3 - - -[selectWanted] -SQL1_1 = SELECT wantedID, wantedName, wantedCrimes, wantedBounty FROM wanted WHERE active = '1' AND wantedID = ? -SQL1_INPUTS = 1 -OUTPUT = 1-STRING, 2-STRING, 3, 4 - -[selectWantedID] -SQL1_1 = SELECT wantedID FROM wanted WHERE wantedID = ? -SQL1_INPUTS = 1 -OUTPUT = 1-STRING - -[selectWantedCrimes] -SQL1_1 = SELECT wantedCrimes, wantedBounty FROM wanted WHERE wantedID = ? -SQL1_INPUTS = 1 - -[selectWantedActive] -SQL1_1 = SELECT wantedCrimes, wantedBounty FROM wanted WHERE active = '1' AND wantedID = ? -SQL1_INPUTS = 1 - -[selectWantedActiveID] -SQL1_1 = SELECT wantedID, wantedName FROM wanted WHERE active = '1' AND wantedID in (?) -SQL1_INPUTS = 1 -OUTPUT = 1-STRING, 2-STRING - -[selectWantedBounty] -SQL1_1 = SELECT wantedID, wantedName, wantedBounty FROM wanted WHERE active = '1' AND wantedID = ? -SQL1_INPUTS = 1 -OUTPUT = 1-STRING, 2-STRING, 3 - -[selectWantedName] -SQL1_1 = SELECT wantedName FROM wanted WHERE wantedID = ? -SQL1_INPUTS = 1 -OUTPUT = 1-STRING - -[insertWanted] -SQL1_1 = INSERT INTO wanted (wantedID, wantedName, wantedCrimes, wantedBounty, active) VALUES (?, ?, ?, ?, '1') -SQL1_INPUTS = 1, 2, 3, 4 - -[updateWanted] -SQL1_1 = UPDATE wanted SET wantedCrimes = ?, wantedBounty = wantedBounty + ?, active = '1' WHERE wantedID = ? -SQL1_INPUTS = 1, 2, 3 - -[updateWantedName] -SQL1_1 = UPDATE wanted SET wantedName = ? WHERE wantedID = ? -SQL1_INPUTS = 1, 2 - -[deleteWanted] -SQL1_1 = UPDATE wanted SET active = '0', wantedCrimes = '[]', wantedBounty = 0 WHERE wantedID = ? -SQL1_INPUTS = 1 +[Default] + +Version = 1 +;; Used incase there is ever a breaking change, or to inform user in log about a new feature. + +Strip Chars = ";[]" +;; List of characters to strip out +Strip Chars Mode = 0 +;; 0 = Strip Bad Chars, 1 = Strip + Log Bad Chars, 2 = Return Error & Log Bad Chars +;; Note: Logging on works when sending data to database. + +Input SQF Parser = false +;; Expermential +;; If enabled will use SQF Array Parser instead of : seperator for values +;; i.e 0:SQL:UpdatePlayer:["Joe",[1,2,0],0.22333,"PlayerBackpack",-3] +;; Advantage is that you don't need to strip : seperator from user inputted values + +[resetLifeVehicles] +SQL1_1 = CALL resetLifeVehicles + +[deleteOldHouses] +SQL1_1 = CALL deleteOldHouses + +[deleteDeadVehicles] +SQL1_1 = CALL deleteDeadVehicles + +[deleteOldGangs] +SQL1_1 = CALL deleteOldGangs + +[deleteOldContainers] +SQL1_1 = CALL deleteOldContainers + + + +[checkPlayerExists] +SQL1_1 = SELECT pid, name FROM players WHERE pid = ? +SQL1_INPUTS = 1 +OUTPUT = 1-STRING, 2-STRING + +[selectName] +SQL1_1 = SELECT name FROM players WHERE pid = ? +SQL1_INPUTS = 1 +OUTPUT = 1-STRING + +[insertNewPlayer] +SQL1_1 = INSERT INTO players (pid, name, cash, bankacc, aliases, cop_licenses, med_licenses, civ_licenses, civ_gear, cop_gear, med_gear) VALUES (?, ?, ?, ?, ?,'[]','[]','[]','[]','[]','[]') +SQL1_INPUTS = 1, 2, 3, 4, 5 + +[selectWest] +SQL1_1 = SELECT pid, name, cash, bankacc, adminlevel, donorlevel, cop_licenses, coplevel, cop_gear, blacklist, cop_stats, playtime FROM players WHERE pid = ? +SQL1_INPUTS = 1 +OUTPUT = 1-STRING, 2-STRING, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 + +[selectCiv] +SQL1_1 = SELECT pid, name, cash, bankacc, adminlevel, donorlevel, civ_licenses, arrested, civ_gear, civ_stats, civ_alive, civ_position, playtime FROM players WHERE pid = ? +SQL1_INPUTS = 1 +OUTPUT = 1-STRING, 2-STRING, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 + +[selectIndep] +SQL1_1 = SELECT pid, name, cash, bankacc, adminlevel, donorlevel, med_licenses, mediclevel, med_gear, med_stats, playtime FROM players WHERE pid = ? +SQL1_INPUTS = 1 +OUTPUT = 1-STRING, 2-STRING, 3, 4, 5, 6, 7, 8, 9, 10, 11 + +[updateWest] +SQL1_1 = UPDATE players SET name = ?, cash = ?, bankacc = ?, cop_gear = ?, cop_licenses = ?, cop_stats = ?, playtime = ? WHERE pid = ? +SQL1_INPUTS = 1, 2, 3, 4, 5, 6, 7, 8 + +[updateCiv] +SQL1_1 = UPDATE players SET name = ?, cash = ?, bankacc = ?, civ_licenses = ?, civ_gear = ?, arrested = ?, civ_stats = ?, civ_alive = ?, civ_position = ?, playtime = ? WHERE pid = ? +SQL1_INPUTS = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 + +[updateIndep] +SQL1_1 = UPDATE players SET name = ?, cash = ?, bankacc = ?, med_licenses = ?, med_gear = ?, med_stats = ?, playtime = ? WHERE pid = ? +SQL1_INPUTS = 1, 2, 3, 4, 5, 6, 7, 8 + +[updateCash] +SQL1_1 = UPDATE players SET cash = ? WHERE pid = ? +SQL1_INPUTS = 1, 2 + +[updateBank] +SQL1_1 = UPDATE players SET bankacc = ? WHERE pid = ? +SQL1_INPUTS = 1, 2 + +[updateWestLicenses] +SQL1_1 = UPDATE players SET cop_licenses = ? WHERE pid = ? +SQL1_INPUTS = 1, 2 + +[updateCivLicenses] +SQL1_1 = UPDATE players SET civ_licenses = ? WHERE pid = ? +SQL1_INPUTS = 1, 2 + +[updateIndepLicenses] +SQL1_1 = UPDATE players SET med_licenses = ? WHERE pid = ? +SQL1_INPUTS = 1, 2 + +[updateWestGear] +SQL1_1 = UPDATE players SET cop_gear = ? WHERE pid = ? +SQL1_INPUTS = 1, 2 + +[updateCivGear] +SQL1_1 = UPDATE players SET civ_gear = ? WHERE pid = ? +SQL1_INPUTS = 1, 2 + +[updateIndepGear] +SQL1_1 = UPDATE players SET med_gear = ? WHERE pid = ? +SQL1_INPUTS = 1, 2 + +[updateCivPosition] +SQL1_1 = UPDATE players SET civ_alive = ?, civ_position = ? WHERE pid = ? +SQL1_INPUTS = 1, 2, 3 + +[updateCivAlive] +SQL1_1 = UPDATE players SET civ_alive = '0' WHERE civ_alive = '1' + +[updateArrested] +SQL1_1 = UPDATE players SET arrested = ? WHERE pid = ? +SQL1_INPUTS = 1, 2 + +[updateCashAndBank] +SQL1_1 = UPDATE players SET cash = ?, bankacc = ? WHERE pid = ? +SQL1_INPUTS = 1, 2, 3 + + + +[selectPlayerGang] +SQL1_1 = SELECT id, owner, name, maxmembers, bank, members FROM gangs WHERE active = '1' AND members LIKE ? +SQL1_INPUTS = 1 +OUTPUT = 1, 2-STRING, 3-STRING, 4, 5, 6 + +[selectGangID] +SQL1_1 = SELECT id FROM gangs WHERE name = ? AND active = '1' +SQL1_INPUTS = 1 + +[selectGangIDFromMembers] +SQL1_1 = SELECT id FROM gangs WHERE members LIKE ? AND active = '1' +SQL1_INPUTS = 1 + +[selectGangIDFromOwner] +SQL1_1 = SELECT id FROM gangs WHERE owner = ? AND active = '1' +SQL1_INPUTS = 1 + +[selectInactiveGang] +SQL1_1 = SELECT id, active FROM gangs WHERE name = ? AND active = '0' +SQL1_INPUTS = 1 + +[updateGang] +SQL1_1 = UPDATE gangs SET active = '1', owner = ?, members = ? WHERE id = ? +SQL1_INPUTS = 1, 2, 3 + +[updateGang1] +SQL1_1 = UPDATE gangs SET bank = ?, maxmembers = ?, owner = ? WHERE id = ? +SQL1_INPUTS = 1, 2, 3, 4 + +[updateGangBank] +SQL1_1 = UPDATE gangs SET bank = ? WHERE id = ? +SQL1_INPUTS = 1, 2 + +[updateGangMembers] +SQL1_1 = UPDATE gangs SET members = ? WHERE id = ? +SQL1_INPUTS = 1, 2 + +[updateGangMaxmembers] +SQL1_1 = UPDATE gangs SET maxmembers = ? WHERE id = ? +SQL1_INPUTS = 1, 2 + +[updateGangOwner] +SQL1_1 = UPDATE gangs SET owner = ? WHERE id = ? +SQL1_INPUTS = 1, 2 + +[insertGang] +SQL1_1 = INSERT INTO gangs (owner, name, members) VALUES (?, ?, ?) +SQL1_INPUTS = 1, 2, 3 + +[deleteGang] +SQL1_1 = UPDATE gangs SET active = '0' WHERE id = ? +SQL1_INPUTS = 1 + + + +[insertHouse] +SQL1_1 = INSERT INTO houses (pid, pos, owned) VALUES (?, ?, '1') +SQL1_INPUTS = 1, 2 + +[selectHouseID] +SQL1_1 = SELECT id FROM houses WHERE pos = ? AND pid = ? AND owned = '1' +SQL1_INPUTS = 1, 2 + +[selectAllHouses] +SQL1_1 = SELECT COUNT(*) FROM houses WHERE owned = '1' + +[selectPlayerHouses] +SQL1_1 = SELECT houses.id, houses.pid, houses.pos, players.name, houses.garage FROM houses INNER JOIN players WHERE houses.owned = '1' AND houses.pid = players.pid LIMIT ?, 10 +SQL1_INPUTS = 1 +OUTPUT = 1, 2-STRING, 3, 4-STRING, 5 + +[selectHousePositions] +SQL1_1 = SELECT pid, pos FROM houses WHERE pid = ? AND owned = '1' +SQL1_INPUTS = 1 +OUTPUT = 1-STRING, 2 + +[updateHouseTrunk] +SQL1_1 = UPDATE containers SET inventory = ? WHERE id = ? +SQL1_INPUTS = 1, 2 + +[deleteHouse] +SQL1_1 = UPDATE houses SET owned = '0', pos = '[]' WHERE pid = ? AND pos = ? AND owned = '1' +SQL1_INPUTS = 1, 2 + +[deleteHouse1] +SQL1_1 = UPDATE houses SET owned = '0', pos = '[]' WHERE id = ? +SQL1_INPUTS = 1 + +[updateGarage] +SQL1_1 = UPDATE houses SET garage = ? WHERE pid = ? AND pos = ? +SQL1_INPUTS = 1, 2, 3 + +[selectContainerPositions] +SQL1_1 = SELECT pid, pos FROM containers WHERE pid = ? AND owned = '1' +SQL1_INPUTS = 1 +OUTPUT = 1-STRING, 2 + +[selectContainers] +SQL1_1 = SELECT pid, pos, classname, inventory, gear, dir, id FROM containers WHERE pid = ? AND owned = '1' +SQL1_INPUTS = 1 +OUTPUT = 1-STRING, 2, 3-STRING, 4, 5, 6, 7 + +[selectContainerID] +SQL1_1 = SELECT id FROM containers WHERE pos = ? AND pid = ? AND owned = '1' +SQL1_INPUTS = 1, 2 + +[insertContainer] +SQL1_1 = INSERT INTO containers (pid, pos, classname, inventory, gear, owned, dir) VALUES (?, ?, ?, '[[],0]', '[]', '1', ?) +SQL1_INPUTS = 1, 2, 3, 4 + +[updateContainer] +SQL1_1 = UPDATE containers SET gear = ? WHERE id = ? +SQL1_INPUTS = 1, 2 + +[deleteContainer] +SQL1_1 = UPDATE containers SET owned = '0', pos = '[]' WHERE pid = ? AND pos = ? AND owned = '1' +SQL1_INPUTS = 1, 2 + +[deleteContainer1] +SQL1_1 = UPDATE containers SET owned = '0', pos = '[]' WHERE id = ? +SQL1_INPUTS = 1 + + + + +[selectVehicles] +SQL1_1 = SELECT id, side, classname, type, pid, alive, active, plate, color FROM vehicles WHERE pid = ? AND alive = '1' AND active = '0' AND side = ? AND type = ? +SQL1_INPUTS = 1, 2, 3 +OUTPUT = 1, 2-STRING, 3-STRING, 4-STRING, 5-STRING, 6, 7, 8, 9 + +[selectVehiclesMore] +SQL1_1 = SELECT id, side, classname, type, pid, alive, active, plate, color, inventory, gear, fuel, damage, blacklist FROM vehicles WHERE id = ? AND pid = ? +SQL1_INPUTS = 1, 2 +OUTPUT = 1, 2-STRING, 3-STRING, 4-STRING, 5-STRING, 6, 7, 8, 9, 10, 11, 12, 13, 14 + +[updateVehicle] +SQL1_1 = UPDATE vehicles SET active = '1' WHERE pid = ? AND id = ? +SQL1_INPUTS = 1, 2 + +[updateVehicleBlacklist] +SQL1_1 = UPDATE vehicles SET blacklist = '0' WHERE id = ? AND pid = ? +SQL1_INPUTS = 1, 2 + +[updateVehicleBlacklistPlate] +SQL1_1 = UPDATE vehicles SET blacklist = '1' WHERE pid = ? AND plate = ? +SQL1_INPUTS = 1, 2 + +[updateVehicleFuel] +SQL1_1 = UPDATE vehicles SET active = '0', fuel = ?, damage = ? WHERE pid = ? AND plate = ? +SQL1_INPUTS = 1, 2, 3, 4 + +[updateVehicleAll] +SQL1_1 = UPDATE vehicles SET active = '0', inventory = ?, gear = ?, fuel = ?, damage = ? WHERE pid = ? AND plate = ? +SQL1_INPUTS = 1, 2, 3, 4, 5, 6 + +[updateVehicleGear] +SQL1_1 = UPDATE vehicles SET gear = ? WHERE pid = ? AND plate = ? +SQL1_INPUTS = 1, 2, 3 + +[updateVehicleTrunk] +SQL1_1 = UPDATE vehicles SET inventory = ? WHERE pid = ? AND plate = ? +SQL1_INPUTS = 1, 2, 3 + +[insertVehicle] +SQL1_1 = INSERT INTO vehicles (side, classname, type, pid, alive, active, inventory, color, plate, gear, damage) VALUES (?, ?, ?, ?, '1','1','[[],0]', ?, ?,'[]','[]') +SQL1_INPUTS = 1, 2, 3, 4, 5, 6 + +[deleteVehicle] +SQL1_1 = UPDATE vehicles SET alive = '0' WHERE pid = ? AND plate = ? +SQL1_INPUTS = 1, 2 + +[deleteVehicleID] +SQL1_1 = UPDATE vehicles SET alive = '0' WHERE pid = ? AND id = ? +SQL1_INPUTS = 1, 2 + +[cleanupVehicle] +SQL1_1 = UPDATE vehicles SET active = '0', fuel = ? WHERE pid = ? AND plate = ? +SQL1_INPUTS = 1, 2, 3 + + +[selectWanted] +SQL1_1 = SELECT wantedID, wantedName, wantedCrimes, wantedBounty FROM wanted WHERE active = '1' AND wantedID = ? +SQL1_INPUTS = 1 +OUTPUT = 1-STRING, 2-STRING, 3, 4 + +[selectWantedID] +SQL1_1 = SELECT wantedID FROM wanted WHERE wantedID = ? +SQL1_INPUTS = 1 +OUTPUT = 1-STRING + +[selectWantedCrimes] +SQL1_1 = SELECT wantedCrimes, wantedBounty FROM wanted WHERE wantedID = ? +SQL1_INPUTS = 1 + +[selectWantedActive] +SQL1_1 = SELECT wantedCrimes, wantedBounty FROM wanted WHERE active = '1' AND wantedID = ? +SQL1_INPUTS = 1 + +[selectWantedActiveID] +SQL1_1 = SELECT wantedID, wantedName FROM wanted WHERE active = '1' AND wantedID in (?) +SQL1_INPUTS = 1 +OUTPUT = 1-STRING, 2-STRING + +[selectWantedBounty] +SQL1_1 = SELECT wantedID, wantedName, wantedBounty FROM wanted WHERE active = '1' AND wantedID = ? +SQL1_INPUTS = 1 +OUTPUT = 1-STRING, 2-STRING, 3 + +[selectWantedName] +SQL1_1 = SELECT wantedName FROM wanted WHERE wantedID = ? +SQL1_INPUTS = 1 +OUTPUT = 1-STRING + +[insertWanted] +SQL1_1 = INSERT INTO wanted (wantedID, wantedName, wantedCrimes, wantedBounty, active) VALUES (?, ?, ?, ?, '1') +SQL1_INPUTS = 1, 2, 3, 4 + +[updateWanted] +SQL1_1 = UPDATE wanted SET wantedCrimes = ?, wantedBounty = wantedBounty + ?, active = '1' WHERE wantedID = ? +SQL1_INPUTS = 1, 2, 3 + +[updateWantedName] +SQL1_1 = UPDATE wanted SET wantedName = ? WHERE wantedID = ? +SQL1_INPUTS = 1, 2 + +[deleteWanted] +SQL1_1 = UPDATE wanted SET active = '0', wantedCrimes = '[]', wantedBounty = 0 WHERE wantedID = ? +SQL1_INPUTS = 1 diff --git a/Altis_Life.Altis/core/fn_initCiv.sqf b/Altis_Life.Altis/core/fn_initCiv.sqf index 07a6f4ab6..829694dac 100644 --- a/Altis_Life.Altis/core/fn_initCiv.sqf +++ b/Altis_Life.Altis/core/fn_initCiv.sqf @@ -1,39 +1,39 @@ -#include "..\script_macros.hpp" -/* - File: fn_initCiv.sqf - Author: Bryan "Tonic" Boardwine - - Description: - Initializes the civilian. -*/ -private _altisArray = ["Land_i_Shop_01_V1_F","Land_i_Shop_01_V2_F","Land_i_Shop_01_V3_F","Land_i_Shop_02_V1_F","Land_i_Shop_02_V2_F","Land_i_Shop_02_V3_F"]; -private _tanoaArray = ["Land_House_Small_01_F"]; -private _spawnBuildings = [[["Altis", _altisArray], ["Tanoa", _tanoaArray]]] call TON_fnc_terrainSort; - -civ_spawn_1 = nearestObjects[getMarkerPos "civ_spawn_1", _spawnBuildings,350]; -civ_spawn_2 = nearestObjects[getMarkerPos "civ_spawn_2", _spawnBuildings,350]; -civ_spawn_3 = nearestObjects[getMarkerPos "civ_spawn_3", _spawnBuildings,350]; -civ_spawn_4 = nearestObjects[getMarkerPos "civ_spawn_4", _spawnBuildings,350]; - -waitUntil {!(isNull (findDisplay 46))}; -private _alive = !(life_civ_position isEqualTo []); -if (_alive && !life_is_arrested) then { - /* Spawn at our last position */ - player setVehiclePosition [life_civ_position, [], 0, "CAN_COLLIDE"]; -} else { - if (!_alive && !life_is_arrested) then { - if (LIFE_SETTINGS(getNumber,"save_civilian_positionStrict") isEqualTo 1) then { - [] call life_fnc_startLoadout; - CASH = 0; - [0] call SOCK_fnc_updatePartial; - }; - [] call life_fnc_spawnMenu; - waitUntil{!isNull (findDisplay 38500)}; //Wait for the spawn selection to be open. - waitUntil{isNull (findDisplay 38500)}; //Wait for the spawn selection to be done. - } else { - if (life_is_arrested) then { - life_is_arrested = false; - [player,true] spawn life_fnc_jail; - }; - }; -}; \ No newline at end of file +#include "..\script_macros.hpp" +/* + File: fn_initCiv.sqf + Author: Bryan "Tonic" Boardwine + + Description: + Initializes the civilian. +*/ +private _altisArray = ["Land_i_Shop_01_V1_F","Land_i_Shop_01_V2_F","Land_i_Shop_01_V3_F","Land_i_Shop_02_V1_F","Land_i_Shop_02_V2_F","Land_i_Shop_02_V3_F"]; +private _tanoaArray = ["Land_House_Small_01_F"]; +private _spawnBuildings = [[["Altis", _altisArray], ["Tanoa", _tanoaArray]]] call TON_fnc_terrainSort; + +civ_spawn_1 = nearestObjects[getMarkerPos "civ_spawn_1", _spawnBuildings,350]; +civ_spawn_2 = nearestObjects[getMarkerPos "civ_spawn_2", _spawnBuildings,350]; +civ_spawn_3 = nearestObjects[getMarkerPos "civ_spawn_3", _spawnBuildings,350]; +civ_spawn_4 = nearestObjects[getMarkerPos "civ_spawn_4", _spawnBuildings,350]; + +waitUntil {!(isNull (findDisplay 46))}; +life_civ_position params ["_alive","_position"]; +if (_alive && !life_is_arrested) then { + /* Spawn at our last position */ + player setVehiclePosition [_position, [], 0, "CAN_COLLIDE"]; +} else { + if (!_alive && !life_is_arrested) then { + if (LIFE_SETTINGS(getNumber,"save_civilian_positionStrict") isEqualTo 1) then { + [] call life_fnc_startLoadout; + CASH = 0; + [0] call SOCK_fnc_updatePartial; + }; + [] call life_fnc_spawnMenu; + waitUntil{!isNull (findDisplay 38500)}; //Wait for the spawn selection to be open. + waitUntil{isNull (findDisplay 38500)}; //Wait for the spawn selection to be done. + } else { + if (life_is_arrested) then { + life_is_arrested = false; + [player,true] spawn life_fnc_jail; + }; + }; +}; diff --git a/Altis_Life.Altis/core/session/fn_requestReceived.sqf b/Altis_Life.Altis/core/session/fn_requestReceived.sqf index d562231c9..f423184e1 100755 --- a/Altis_Life.Altis/core/session/fn_requestReceived.sqf +++ b/Altis_Life.Altis/core/session/fn_requestReceived.sqf @@ -1,112 +1,112 @@ -#include "..\..\script_macros.hpp" -/* - File: fn_requestReceived.sqf - Author: Bryan "Tonic" Boardwine - - Description: - Called by the server saying that we have a response so let's - sort through the information, validate it and if all valid - set the client up. -*/ - -private _count = count _this; -life_session_tries = life_session_tries + 1; -if (life_session_completed) exitWith {}; //Why did this get executed when the client already initialized? Fucking arma... -if (life_session_tries > 3) exitWith {cutText[localize "STR_Session_Error","BLACK FADED"]; 0 cutFadeOut 999999999;}; - -0 cutText [localize "STR_Session_Received","BLACK FADED"]; -0 cutFadeOut 9999999; - -//Error handling and junk.. -if (isNil "_this") exitWith {[] call SOCK_fnc_insertPlayerInfo;}; -if (_this isEqualType "") exitWith {[] call SOCK_fnc_insertPlayerInfo;}; -if (count _this isEqualTo 0) exitWith {[] call SOCK_fnc_insertPlayerInfo;}; -if ((_this select 0) isEqualTo "Error") exitWith {[] call SOCK_fnc_insertPlayerInfo;}; -if (!(getPlayerUID player isEqualTo (_this select 0))) exitWith {[] call SOCK_fnc_dataQuery;}; - -//Lets make sure some vars are not set before hand.. If they are get rid of them, hopefully the engine purges past variables but meh who cares. -if (!isServer && (!isNil "life_adminlevel" || !isNil "life_coplevel" || !isNil "life_donorlevel")) exitWith { - [profileName,getPlayerUID player,"VariablesAlreadySet"] remoteExecCall ["SPY_fnc_cookieJar",RSERV]; - [profileName,format ["Variables set before client initialization...\nlife_adminlevel: %1\nlife_coplevel: %2\nlife_donorlevel: %3",life_adminlevel,life_coplevel,life_donorlevel]] remoteExecCall ["SPY_fnc_notifyAdmins",RCLIENT]; - sleep 0.9; - failMission "SpyGlass"; -}; - -//Parse basic player information. -CASH = _this select 2; -BANK = _this select 3; -CONST(life_adminlevel,(_this select 4)); -if (LIFE_SETTINGS(getNumber,"donor_level") isEqualTo 1) then { - CONST(life_donorlevel,(_this select 5)); -} else { - CONST(life_donorlevel,0); -}; - -//Loop through licenses -if !((_this select 6) isEqualTo []) then { - {missionNamespace setVariable [(_x select 0),(_x select 1)];} forEach (_this select 6); -}; - -//Parse side specific information. -switch (playerSide) do { - case west: { - CONST(life_coplevel,(_this select 7)); - CONST(life_medicLevel,0); - life_blacklisted = _this select 9; - if (LIFE_SETTINGS(getNumber,"save_playerStats") isEqualTo 1) then { - life_hunger = ((_this select 10) select 0); - life_thirst = ((_this select 10) select 1); - player setDamage ((_this select 10) select 2); - }; - }; - - case civilian: { - life_is_arrested = _this select 7; - CONST(life_coplevel, 0); - CONST(life_medicLevel, 0); - life_houses = _this select (_count - 3); - if (LIFE_SETTINGS(getNumber,"save_playerStats") isEqualTo 1) then { - life_hunger = ((_this select 9) select 0); - life_thirst = ((_this select 9) select 1); - player setDamage ((_this select 9) select 2); - }; - - //Position - if (LIFE_SETTINGS(getNumber,"save_civilian_position") isEqualTo 1) then { - life_civ_position = _this select 10; - if !(life_civ_position isEqualTo []) then { - if (life_civ_position distance (getMarkerPos "respawn_civilian") < 300) then {life_civ_position = []}; - }; - }; - - { - _house = nearestObject [(call compile format ["%1",(_x select 0)]), "House"]; - life_vehicles pushBack _house; - } forEach life_houses; - - life_gangData = _this select (_count - 2); - if !(life_gangData isEqualTo []) then { - [] spawn life_fnc_initGang; - }; - [] spawn life_fnc_initHouses; - }; - - case independent: { - CONST(life_medicLevel,(_this select 7)); - CONST(life_coplevel,0); - if (LIFE_SETTINGS(getNumber,"save_playerStats") isEqualTo 1) then { - life_hunger = ((_this select 9) select 0); - life_thirst = ((_this select 9) select 1); - player setDamage ((_this select 9) select 2); - }; - }; -}; - -life_gear = _this select 8; -[true] call life_fnc_loadGear; - -if !((_this select (_count - 1)) isEqualTo []) then { - {life_vehicles pushBack _x;} forEach (_this select (_count - 1)); -}; - -life_session_completed = true; +#include "..\..\script_macros.hpp" +/* + File: fn_requestReceived.sqf + Author: Bryan "Tonic" Boardwine + + Description: + Called by the server saying that we have a response so let's + sort through the information, validate it and if all valid + set the client up. +*/ + +private _count = count _this; +life_session_tries = life_session_tries + 1; +if (life_session_completed) exitWith {}; //Why did this get executed when the client already initialized? Fucking arma... +if (life_session_tries > 3) exitWith {cutText[localize "STR_Session_Error","BLACK FADED"]; 0 cutFadeOut 999999999;}; + +0 cutText [localize "STR_Session_Received","BLACK FADED"]; +0 cutFadeOut 9999999; + +//Error handling and junk.. +if (isNil "_this") exitWith {[] call SOCK_fnc_insertPlayerInfo;}; +if (_this isEqualType "") exitWith {[] call SOCK_fnc_insertPlayerInfo;}; +if (count _this isEqualTo 0) exitWith {[] call SOCK_fnc_insertPlayerInfo;}; +if ((_this select 0) isEqualTo "Error") exitWith {[] call SOCK_fnc_insertPlayerInfo;}; +if (!(getPlayerUID player isEqualTo (_this select 0))) exitWith {[] call SOCK_fnc_dataQuery;}; + +//Lets make sure some vars are not set before hand.. If they are get rid of them, hopefully the engine purges past variables but meh who cares. +if (!isServer && (!isNil "life_adminlevel" || !isNil "life_coplevel" || !isNil "life_donorlevel")) exitWith { + [profileName,getPlayerUID player,"VariablesAlreadySet"] remoteExecCall ["SPY_fnc_cookieJar",RSERV]; + [profileName,format ["Variables set before client initialization...\nlife_adminlevel: %1\nlife_coplevel: %2\nlife_donorlevel: %3",life_adminlevel,life_coplevel,life_donorlevel]] remoteExecCall ["SPY_fnc_notifyAdmins",RCLIENT]; + sleep 0.9; + failMission "SpyGlass"; +}; + +//Parse basic player information. +CASH = _this select 2; +BANK = _this select 3; +CONST(life_adminlevel,(_this select 4)); +if (LIFE_SETTINGS(getNumber,"donor_level") isEqualTo 1) then { + CONST(life_donorlevel,(_this select 5)); +} else { + CONST(life_donorlevel,0); +}; + +//Loop through licenses +if !((_this select 6) isEqualTo []) then { + {missionNamespace setVariable [(_x select 0),(_x select 1)];} forEach (_this select 6); +}; + +//Parse side specific information. +switch (playerSide) do { + case west: { + CONST(life_coplevel,(_this select 7)); + CONST(life_medicLevel,0); + life_blacklisted = _this select 9; + if (LIFE_SETTINGS(getNumber,"save_playerStats") isEqualTo 1) then { + life_hunger = ((_this select 10) select 0); + life_thirst = ((_this select 10) select 1); + player setDamage ((_this select 10) select 2); + }; + }; + + case civilian: { + life_is_arrested = _this select 7; + CONST(life_coplevel, 0); + CONST(life_medicLevel, 0); + life_houses = _this select (_count - 3); + if (LIFE_SETTINGS(getNumber,"save_playerStats") isEqualTo 1) then { + life_hunger = ((_this select 9) select 0); + life_thirst = ((_this select 9) select 1); + player setDamage ((_this select 9) select 2); + }; + + //Position + if (LIFE_SETTINGS(getNumber,"save_civilian_position") isEqualTo 1) then { + life_civ_position = [_this select 10,_this select 11]; + if !(life_civ_position isEqualTo []) then { + if (life_civ_position distance (getMarkerPos "respawn_civilian") < 300) then {life_civ_position = []}; + }; + }; + + { + _house = nearestObject [(call compile format ["%1",(_x select 0)]), "House"]; + life_vehicles pushBack _house; + } forEach life_houses; + + life_gangData = _this select (_count - 2); + if !(life_gangData isEqualTo []) then { + [] spawn life_fnc_initGang; + }; + [] spawn life_fnc_initHouses; + }; + + case independent: { + CONST(life_medicLevel,(_this select 7)); + CONST(life_coplevel,0); + if (LIFE_SETTINGS(getNumber,"save_playerStats") isEqualTo 1) then { + life_hunger = ((_this select 9) select 0); + life_thirst = ((_this select 9) select 1); + player setDamage ((_this select 9) select 2); + }; + }; +}; + +life_gear = _this select 8; +[true] call life_fnc_loadGear; + +if !((_this select (_count - 1)) isEqualTo []) then { + {life_vehicles pushBack _x;} forEach (_this select (_count - 1)); +}; + +life_session_completed = true; diff --git a/Altis_Life.Altis/core/session/fn_updatePartial.sqf b/Altis_Life.Altis/core/session/fn_updatePartial.sqf index a8c659abd..b6b23aa7e 100644 --- a/Altis_Life.Altis/core/session/fn_updatePartial.sqf +++ b/Altis_Life.Altis/core/session/fn_updatePartial.sqf @@ -1,63 +1,59 @@ -#include "..\..\script_macros.hpp" -/* - File: fn_updatePartial.sqf - Author: Bryan "Tonic" Boardwine - - Description: - Sends specific information to the server to update on the player, - meant to keep the network traffic down with large sums of data flowing - through remoteExec -*/ -params [ - ["_mode",0,[0]] -]; -private _packet = [player,_mode]; - -switch (_mode) do { - case 0: { - _packet pushBack CASH; - }; - - case 1: { - _packet pushBack BANK; - }; - - case 2: { - private _array = []; - private _flag = switch (playerSide) do {case west: {"cop"}; case civilian: {"civ"}; case independent: {"med"};}; - { - _varName = LICENSE_VARNAME(configName _x,_flag); - _array pushBack [_varName,LICENSE_VALUE(configName _x,_flag)]; - } forEach (format ["getText(_x >> 'side') isEqualTo '%1'",_flag] configClasses (missionConfigFile >> "Licenses")); - - _packet pushBack _array; - }; - - case 3: { - [] call life_fnc_saveGear; - _packet pushBack life_gear; - }; - - case 4: { - //old location - }; - - case 5: { - _packet pushBack life_is_arrested; - }; - - case 6: { - _packet pushBack CASH; - _packet pushBack BANK; - }; - - case 7: { - // Tonic is using for keychain..? - }; -}; - -if (life_HC_isActive) then { - _packet remoteExecCall ["HC_fnc_updatePartial",HC_Life]; -} else { - _packet remoteExecCall ["DB_fnc_updatePartial",RSERV]; -}; +#include "..\..\script_macros.hpp" +/* + File: fn_updatePartial.sqf + Author: Bryan "Tonic" Boardwine + + Description: + Sends specific information to the server to update on the player, + meant to keep the network traffic down with large sums of data flowing + through remoteExec +*/ +params [ + ["_mode",0,[0]] +]; +private _packet = [player,_mode]; + +switch (_mode) do { + case 0: { + _packet pushBack CASH; + }; + + case 1: { + _packet pushBack BANK; + }; + + case 2: { + private _array = []; + private _flag = switch (playerSide) do {case west: {"cop"}; case civilian: {"civ"}; case independent: {"med"};}; + { + _varName = LICENSE_VARNAME(configName _x,_flag); + _array pushBack [_varName,LICENSE_VALUE(configName _x,_flag)]; + } forEach (format ["getText(_x >> 'side') isEqualTo '%1'",_flag] configClasses (missionConfigFile >> "Licenses")); + + _packet pushBack _array; + }; + + case 3: { + [] call life_fnc_saveGear; + _packet pushBack life_gear; + }; + + case 4: { + //used for location + }; + + case 5: { + _packet pushBack life_is_arrested; + }; + + case 6: { + _packet pushBack CASH; + _packet pushBack BANK; + }; +}; + +if (life_HC_isActive) then { + _packet remoteExecCall ["HC_fnc_updatePartial",HC_Life]; +} else { + _packet remoteExecCall ["DB_fnc_updatePartial",RSERV]; +}; diff --git a/altislife.sql b/altislife.sql index c462c688a..6529a6c04 100755 --- a/altislife.sql +++ b/altislife.sql @@ -1,248 +1,249 @@ -SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; -SET time_zone = "+00:00"; --- --- Compatible with newer MySQL versions. (After MySQL-5.5) --- This SQL uses utf8mb4 and has CURRENT_TIMESTAMP function. --- - - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8mb4 */; - --- --- Creates database `altislife` unless it already exists and uses `altislife` --- Default Schema --- -CREATE DATABASE IF NOT EXISTS `altislife` DEFAULT CHARACTER SET utf8mb4; -USE `altislife`; - --- --- Drop procedures to ensure no conflicts --- -DROP PROCEDURE IF EXISTS `resetLifeVehicles`; -DROP PROCEDURE IF EXISTS `deleteDeadVehicles`; -DROP PROCEDURE IF EXISTS `deleteOldHouses`; -DROP PROCEDURE IF EXISTS `deleteOldGangs`; -DROP PROCEDURE IF EXISTS `deleteOldContainers`; -DROP PROCEDURE IF EXISTS `deleteOldWanted`; - -DELIMITER $$ --- --- Procedures --- CURRENT_USER function returns the name of the current user in the SQL Server database. --- - -CREATE DEFINER=CURRENT_USER PROCEDURE `resetLifeVehicles`() -BEGIN - UPDATE `vehicles` SET `active`= 0; -END$$ - -CREATE DEFINER=CURRENT_USER PROCEDURE `deleteDeadVehicles`() -BEGIN - DELETE FROM `vehicles` WHERE `alive` = 0; -END$$ - -CREATE DEFINER=CURRENT_USER PROCEDURE `deleteOldHouses`() -BEGIN - DELETE FROM `houses` WHERE `owned` = 0; -END$$ - -CREATE DEFINER=CURRENT_USER PROCEDURE `deleteOldGangs`() -BEGIN - DELETE FROM `gangs` WHERE `active` = 0; -END$$ - -CREATE DEFINER=CURRENT_USER PROCEDURE `deleteOldContainers`() -BEGIN - DELETE FROM `containers` WHERE `owned` = 0; -END$$ - -CREATE DEFINER=CURRENT_USER PROCEDURE `deleteOldWanted`() -BEGIN - DELETE FROM `wanted` WHERE `active` = 0; -END$$ - -DELIMITER ; - --- -------------------------------------------------------- - --- --- Table structure for table `players` --- - -CREATE TABLE IF NOT EXISTS `players` ( - `uid` INT NOT NULL AUTO_INCREMENT, - `pid` VARCHAR(17) NOT NULL, - `name` VARCHAR(32) NOT NULL, - `aliases` TEXT NOT NULL, - `cash` INT NOT NULL DEFAULT 0, - `bankacc` INT NOT NULL DEFAULT 0, - `coplevel` ENUM('0','1','2','3','4','5','6','7') NOT NULL DEFAULT '0', - `mediclevel` ENUM('0','1','2','3','4','5') NOT NULL DEFAULT '0', - `civ_licenses` TEXT NOT NULL, - `cop_licenses` TEXT NOT NULL, - `med_licenses` TEXT NOT NULL, - `civ_gear` TEXT NOT NULL, - `cop_gear` TEXT NOT NULL, - `med_gear` TEXT NOT NULL, - `civ_stats` VARCHAR(25) NOT NULL DEFAULT '[100,100,0]', - `cop_stats` VARCHAR(25) NOT NULL DEFAULT '[100,100,0]', - `med_stats` VARCHAR(25) NOT NULL DEFAULT '[100,100,0]', - `arrested` TINYINT NOT NULL DEFAULT 0, - `adminlevel` ENUM('0','1','2','3','4','5') NOT NULL DEFAULT '0', - `donorlevel` ENUM('0','1','2','3','4','5') NOT NULL DEFAULT '0', - `blacklist` TINYINT NOT NULL DEFAULT 0, - `civ_position` VARCHAR(32) NOT NULL DEFAULT '[]', - `playtime` VARCHAR(32) NOT NULL DEFAULT '[0,0,0]', - `insert_time` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, - `last_seen` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - - PRIMARY KEY (`pid`), - UNIQUE KEY `unique_uid` (`uid`), - INDEX `index_name` (`name`), - INDEX `index_blacklist` (`blacklist`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; - - --- -------------------------------------------------------- - --- --- Table structure for table `vehicles` --- - -CREATE TABLE IF NOT EXISTS `vehicles` ( - `id` INT NOT NULL AUTO_INCREMENT, - `pid` VARCHAR(17) NOT NULL, - `side` VARCHAR(10) NOT NULL, - `classname` VARCHAR(64) NOT NULL, - `type` VARCHAR(16) NOT NULL, - `alive` TINYINT NOT NULL DEFAULT 1, - `blacklist` TINYINT NOT NULL DEFAULT 0, - `active` TINYINT NOT NULL DEFAULT 0, - `plate` MEDIUMINT NOT NULL, - `color` INT NOT NULL, - `inventory` TEXT NOT NULL, - `gear` TEXT NOT NULL, - `fuel` DOUBLE NOT NULL DEFAULT 1, - `damage` VARCHAR(256) NOT NULL, - `insert_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, - - PRIMARY KEY (`id`), - INDEX `fkIdx_players_vehicles` (`pid`), - CONSTRAINT `FK_players_vehicles` FOREIGN KEY `fkIdx_players_vehicles` (`pid`) - REFERENCES `players` (`pid`) - ON UPDATE CASCADE ON DELETE CASCADE, - INDEX `index_side` (`side`), - INDEX `index_type` (`type`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; - --- -------------------------------------------------------- - --- --- Table structure for table `houses` --- Needed for extDB latest update on git --- - -CREATE TABLE IF NOT EXISTS `houses` ( - `id` INT NOT NULL AUTO_INCREMENT, - `pid` VARCHAR(17) NOT NULL, - `pos` VARCHAR(32) DEFAULT NULL, - `owned` TINYINT DEFAULT 0, - `garage` TINYINT NOT NULL DEFAULT 0, - `insert_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, - - PRIMARY KEY (`id`), - INDEX `fkIdx_players_houses` (`pid`), - CONSTRAINT `FK_players_houses` FOREIGN KEY `fkIdx_players_houses` (`pid`) - REFERENCES `players` (`pid`) - ON UPDATE CASCADE ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; - --- -------------------------------------------------------- - --- --- Table structure for table `gangs` --- Needed for extDB latest update on git --- - -CREATE TABLE IF NOT EXISTS `gangs` ( - `id` INT NOT NULL AUTO_INCREMENT, - `owner` VARCHAR(17) NOT NULL, - `name` VARCHAR(32) DEFAULT NULL, - `members` TEXT, - `maxmembers` INT DEFAULT 8, - `bank` INT DEFAULT 0, - `active` TINYINT NOT NULL DEFAULT 1, - `insert_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, - - PRIMARY KEY (`id`), - UNIQUE KEY `unique_name` (`name`), - INDEX `fkIdx_players_gangs` (`owner`), - CONSTRAINT `FK_players_gangs` FOREIGN KEY `fkIdx_players_gangs` (`owner`) - REFERENCES `players` (`pid`) - ON UPDATE CASCADE ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; - --- -------------------------------------------------------- - --- --- Table structure for table `containers` --- Needed for extDB latest update on git --- - -CREATE TABLE IF NOT EXISTS `containers` ( - `id` INT NOT NULL AUTO_INCREMENT, - `pid` VARCHAR(17) NOT NULL, - `classname` VARCHAR(32) NOT NULL, - `pos` VARCHAR(32) DEFAULT NULL, - `inventory` TEXT NOT NULL, - `gear` TEXT NOT NULL, - `dir` VARCHAR(128) DEFAULT NULL, - `active` TINYINT NOT NULL DEFAULT 0, - `owned` TINYINT NOT NULL DEFAULT 0, - `insert_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, - - PRIMARY KEY (`id`), - INDEX `fkIdx_players_containers` (`pid`), - CONSTRAINT `FK_players_containers` FOREIGN KEY `fkIdx_players_containers` (`pid`) - REFERENCES `players` (`pid`) - ON UPDATE CASCADE ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; - --- -------------------------------------------------------- - --- --- Table structure for table `wanted` --- Needed for extDB latest update on git --- - -CREATE TABLE IF NOT EXISTS `wanted` ( - `wantedID` VARCHAR(17) NOT NULL, - `wantedName` VARCHAR(32) NOT NULL, - `wantedCrimes` TEXT NOT NULL, - `wantedBounty` INT NOT NULL, - `active` TINYINT NOT NULL DEFAULT 0, - `insert_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, - - PRIMARY KEY (`wantedID`), - CONSTRAINT `FK_players_wanted` FOREIGN KEY `fkIdx_players_wanted` (`wantedID`) - REFERENCES `players` (`pid`) - ON UPDATE CASCADE ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; - --- -------------------------------------------------------- --- --- Creates default user `arma3` with password `changeme` unless it already exists --- Granting permissions to user `arma3`, created below --- Reloads the privileges from the grant tables in the MySQL system database. --- - -CREATE USER IF NOT EXISTS `arma3`@`localhost` IDENTIFIED BY 'changeme'; -GRANT SELECT, UPDATE, INSERT, EXECUTE ON `altislife`.* TO 'arma3'@'localhost'; -FLUSH PRIVILEGES; - -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; +SET time_zone = "+00:00"; +-- +-- Compatible with newer MySQL versions. (After MySQL-5.5) +-- This SQL uses utf8mb4 and has CURRENT_TIMESTAMP function. +-- + + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8mb4 */; + +-- +-- Creates database `altislife` unless it already exists and uses `altislife` +-- Default Schema +-- +CREATE DATABASE IF NOT EXISTS `altislife` DEFAULT CHARACTER SET utf8mb4; +USE `altislife`; + +-- +-- Drop procedures to ensure no conflicts +-- +DROP PROCEDURE IF EXISTS `resetLifeVehicles`; +DROP PROCEDURE IF EXISTS `deleteDeadVehicles`; +DROP PROCEDURE IF EXISTS `deleteOldHouses`; +DROP PROCEDURE IF EXISTS `deleteOldGangs`; +DROP PROCEDURE IF EXISTS `deleteOldContainers`; +DROP PROCEDURE IF EXISTS `deleteOldWanted`; + +DELIMITER $$ +-- +-- Procedures +-- CURRENT_USER function returns the name of the current user in the SQL Server database. +-- + +CREATE DEFINER=CURRENT_USER PROCEDURE `resetLifeVehicles`() +BEGIN + UPDATE `vehicles` SET `active`= 0; +END$$ + +CREATE DEFINER=CURRENT_USER PROCEDURE `deleteDeadVehicles`() +BEGIN + DELETE FROM `vehicles` WHERE `alive` = 0; +END$$ + +CREATE DEFINER=CURRENT_USER PROCEDURE `deleteOldHouses`() +BEGIN + DELETE FROM `houses` WHERE `owned` = 0; +END$$ + +CREATE DEFINER=CURRENT_USER PROCEDURE `deleteOldGangs`() +BEGIN + DELETE FROM `gangs` WHERE `active` = 0; +END$$ + +CREATE DEFINER=CURRENT_USER PROCEDURE `deleteOldContainers`() +BEGIN + DELETE FROM `containers` WHERE `owned` = 0; +END$$ + +CREATE DEFINER=CURRENT_USER PROCEDURE `deleteOldWanted`() +BEGIN + DELETE FROM `wanted` WHERE `active` = 0; +END$$ + +DELIMITER ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `players` +-- + +CREATE TABLE IF NOT EXISTS `players` ( + `uid` INT NOT NULL AUTO_INCREMENT, + `pid` VARCHAR(17) NOT NULL, + `name` VARCHAR(32) NOT NULL, + `aliases` TEXT NOT NULL, + `cash` INT NOT NULL DEFAULT 0, + `bankacc` INT NOT NULL DEFAULT 0, + `coplevel` ENUM('0','1','2','3','4','5','6','7') NOT NULL DEFAULT '0', + `mediclevel` ENUM('0','1','2','3','4','5') NOT NULL DEFAULT '0', + `civ_licenses` TEXT NOT NULL, + `cop_licenses` TEXT NOT NULL, + `med_licenses` TEXT NOT NULL, + `civ_gear` TEXT NOT NULL, + `cop_gear` TEXT NOT NULL, + `med_gear` TEXT NOT NULL, + `civ_stats` VARCHAR(25) NOT NULL DEFAULT '[100,100,0]', + `cop_stats` VARCHAR(25) NOT NULL DEFAULT '[100,100,0]', + `med_stats` VARCHAR(25) NOT NULL DEFAULT '[100,100,0]', + `arrested` TINYINT NOT NULL DEFAULT 0, + `adminlevel` ENUM('0','1','2','3','4','5') NOT NULL DEFAULT '0', + `donorlevel` ENUM('0','1','2','3','4','5') NOT NULL DEFAULT '0', + `blacklist` TINYINT NOT NULL DEFAULT 0, + `civ_alive` TINYINT NOT NULL DEFAULT 0, + `civ_position` VARCHAR(32) NOT NULL DEFAULT '[]', + `playtime` VARCHAR(32) NOT NULL DEFAULT '[0,0,0]', + `insert_time` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + `last_seen` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + + PRIMARY KEY (`pid`), + UNIQUE KEY `unique_uid` (`uid`), + INDEX `index_name` (`name`), + INDEX `index_blacklist` (`blacklist`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `vehicles` +-- + +CREATE TABLE IF NOT EXISTS `vehicles` ( + `id` INT NOT NULL AUTO_INCREMENT, + `pid` VARCHAR(17) NOT NULL, + `side` VARCHAR(10) NOT NULL, + `classname` VARCHAR(64) NOT NULL, + `type` VARCHAR(16) NOT NULL, + `alive` TINYINT NOT NULL DEFAULT 1, + `blacklist` TINYINT NOT NULL DEFAULT 0, + `active` TINYINT NOT NULL DEFAULT 0, + `plate` MEDIUMINT NOT NULL, + `color` INT NOT NULL, + `inventory` TEXT NOT NULL, + `gear` TEXT NOT NULL, + `fuel` DOUBLE NOT NULL DEFAULT 1, + `damage` VARCHAR(256) NOT NULL, + `insert_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + + PRIMARY KEY (`id`), + INDEX `fkIdx_players_vehicles` (`pid`), + CONSTRAINT `FK_players_vehicles` FOREIGN KEY `fkIdx_players_vehicles` (`pid`) + REFERENCES `players` (`pid`) + ON UPDATE CASCADE ON DELETE CASCADE, + INDEX `index_side` (`side`), + INDEX `index_type` (`type`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `houses` +-- Needed for extDB latest update on git +-- + +CREATE TABLE IF NOT EXISTS `houses` ( + `id` INT NOT NULL AUTO_INCREMENT, + `pid` VARCHAR(17) NOT NULL, + `pos` VARCHAR(32) DEFAULT NULL, + `owned` TINYINT DEFAULT 0, + `garage` TINYINT NOT NULL DEFAULT 0, + `insert_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + + PRIMARY KEY (`id`), + INDEX `fkIdx_players_houses` (`pid`), + CONSTRAINT `FK_players_houses` FOREIGN KEY `fkIdx_players_houses` (`pid`) + REFERENCES `players` (`pid`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `gangs` +-- Needed for extDB latest update on git +-- + +CREATE TABLE IF NOT EXISTS `gangs` ( + `id` INT NOT NULL AUTO_INCREMENT, + `owner` VARCHAR(17) NOT NULL, + `name` VARCHAR(32) DEFAULT NULL, + `members` TEXT, + `maxmembers` INT DEFAULT 8, + `bank` INT DEFAULT 0, + `active` TINYINT NOT NULL DEFAULT 1, + `insert_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + + PRIMARY KEY (`id`), + UNIQUE KEY `unique_name` (`name`), + INDEX `fkIdx_players_gangs` (`owner`), + CONSTRAINT `FK_players_gangs` FOREIGN KEY `fkIdx_players_gangs` (`owner`) + REFERENCES `players` (`pid`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `containers` +-- Needed for extDB latest update on git +-- + +CREATE TABLE IF NOT EXISTS `containers` ( + `id` INT NOT NULL AUTO_INCREMENT, + `pid` VARCHAR(17) NOT NULL, + `classname` VARCHAR(32) NOT NULL, + `pos` VARCHAR(32) DEFAULT NULL, + `inventory` TEXT NOT NULL, + `gear` TEXT NOT NULL, + `dir` VARCHAR(128) DEFAULT NULL, + `active` TINYINT NOT NULL DEFAULT 0, + `owned` TINYINT NOT NULL DEFAULT 0, + `insert_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + + PRIMARY KEY (`id`), + INDEX `fkIdx_players_containers` (`pid`), + CONSTRAINT `FK_players_containers` FOREIGN KEY `fkIdx_players_containers` (`pid`) + REFERENCES `players` (`pid`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `wanted` +-- Needed for extDB latest update on git +-- + +CREATE TABLE IF NOT EXISTS `wanted` ( + `wantedID` VARCHAR(17) NOT NULL, + `wantedName` VARCHAR(32) NOT NULL, + `wantedCrimes` TEXT NOT NULL, + `wantedBounty` INT NOT NULL, + `active` TINYINT NOT NULL DEFAULT 0, + `insert_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + + PRIMARY KEY (`wantedID`), + CONSTRAINT `FK_players_wanted` FOREIGN KEY `fkIdx_players_wanted` (`wantedID`) + REFERENCES `players` (`pid`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +-- -------------------------------------------------------- +-- +-- Creates default user `arma3` with password `changeme` unless it already exists +-- Granting permissions to user `arma3`, created below +-- Reloads the privileges from the grant tables in the MySQL system database. +-- + +CREATE USER IF NOT EXISTS `arma3`@`localhost` IDENTIFIED BY 'changeme'; +GRANT SELECT, UPDATE, INSERT, EXECUTE ON `altislife`.* TO 'arma3'@'localhost'; +FLUSH PRIVILEGES; + +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; diff --git a/life_hc/MySQL/General/fn_queryRequest.sqf b/life_hc/MySQL/General/fn_queryRequest.sqf index d210dd596..63820d31f 100755 --- a/life_hc/MySQL/General/fn_queryRequest.sqf +++ b/life_hc/MySQL/General/fn_queryRequest.sqf @@ -1,103 +1,104 @@ -#include "\life_hc\hc_macros.hpp" -/* - File: fn_queryRequest.sqf - Author: Bryan "Tonic" Boardwine - - This file is for Nanou's HeadlessClient. - - Description: - Handles the incoming request and sends an asynchronous query - request to the database. - - Return: - ARRAY - If array has 0 elements it should be handled as an error in client-side files. - STRING - The request had invalid handles or an unknown error and is logged to the RPT. -*/ - -params [ - ["_uid", "", [""]], - ["_side", sideUnknown, [civilian]], - ["_ownerID", objNull, [objNull]] -]; - -if (isNull _ownerID) exitWith {}; - -private _query = switch (_side) do { - // West - 11 entries returned - case west: {format ["selectWest:%1", _uid];}; - // Civilian - 11 entries returned - case civilian: {format ["selectCiv:%1", _uid];}; - // Independent - 10 entries returned - case independent: {format ["selectIndep:%1",_uid];}; -}; - -private _tickTime = diag_tickTime; -private _queryResult = [_query,2] call DB_fnc_asyncCall; - -if (EXTDB_SETTING(getNumber,"DebugMode") isEqualTo 1) then { - diag_log "------------- Client Query Request -------------"; - diag_log format ["QUERY: %1",_query]; - diag_log format ["Time to complete: %1 (in seconds)",(diag_tickTime - _tickTime)]; - diag_log format ["Result: %1",_queryResult]; - diag_log "------------------------------------------------"; -}; - -if (_queryResult isEqualType "" || _queryResult isEqualTo []) exitWith { - [] remoteExecCall ["SOCK_fnc_insertPlayerInfo",_ownerID]; -}; - -private _licenses = _queryResult select 6; - -for "_i" from 0 to (count _licenses) -1 do { - (_licenses select _i) params ["_license", "_owned"]; - _licenses set[_i, [_license, [false, true] select _owned]]; -}; - -private "_playTimes"; - -switch (_side) do { - case civilian: { - _queryResult set[7, [false, true] select (_queryResult select 7)]; - - _playTimes = _queryResult select 11; - - /* Make sure nothing else is added under here */ - _houseData = _uid spawn TON_fnc_fetchPlayerHouses; - waitUntil {scriptDone _houseData}; - _queryResult pushBack (missionNamespace getVariable [format ["houses_%1",_uid],[]]); - _gangData = _uid spawn TON_fnc_queryPlayerGang; - waitUntil {scriptDone _gangData}; - _queryResult pushBack (missionNamespace getVariable [format ["gang_%1",_uid],[]]); - }; - - case west: { - _queryResult set[9, [false, true] select (_queryResult select 9)]; - _playTimes = _queryResult select 11; - }; - - case independent: { - _playTimes = _queryResult select 10; - }; -}; - -_index = TON_fnc_playtime_values_request find [_uid, _playTimes]; - -if (_index != -1) then { - TON_fnc_playtime_values_request set[_index,-1]; - TON_fnc_playtime_values_request = TON_fnc_playtime_values_request - [-1]; - TON_fnc_playtime_values_request pushBack [_uid, _playTimes]; -} else { - TON_fnc_playtime_values_request pushBack [_uid, _playTimes]; -}; - -[_uid, _playTimes select 2] call TON_fnc_setPlayTime; -publicVariable "TON_fnc_playtime_values_request"; - -life_keyreceived = false; -life_keyreceivedvar = []; -[_uid, _side] remoteExecCall ["TON_fnc_recupKeyForHC", RSERV]; -waitUntil {life_keyreceived}; -_keyArr = life_keyreceivedvar; -_queryResult pushBack _keyArr; - -_queryResult remoteExec ["SOCK_fnc_requestReceived",_ownerID]; +#include "\life_hc\hc_macros.hpp" +/* + File: fn_queryRequest.sqf + Author: Bryan "Tonic" Boardwine + + This file is for Nanou's HeadlessClient. + + Description: + Handles the incoming request and sends an asynchronous query + request to the database. + + Return: + ARRAY - If array has 0 elements it should be handled as an error in client-side files. + STRING - The request had invalid handles or an unknown error and is logged to the RPT. +*/ + +params [ + ["_uid", "", [""]], + ["_side", sideUnknown, [civilian]], + ["_ownerID", objNull, [objNull]] +]; + +if (isNull _ownerID) exitWith {}; + +private _query = switch (_side) do { + // West - 11 entries returned + case west: {format ["selectWest:%1", _uid];}; + // Civilian - 12 entries returned + case civilian: {format ["selectCiv:%1", _uid];}; + // Independent - 10 entries returned + case independent: {format ["selectIndep:%1",_uid];}; +}; + +private _tickTime = diag_tickTime; +private _queryResult = [_query,2] call DB_fnc_asyncCall; + +if (EXTDB_SETTING(getNumber,"DebugMode") isEqualTo 1) then { + diag_log "------------- Client Query Request -------------"; + diag_log format ["QUERY: %1",_query]; + diag_log format ["Time to complete: %1 (in seconds)",(diag_tickTime - _tickTime)]; + diag_log format ["Result: %1",_queryResult]; + diag_log "------------------------------------------------"; +}; + +if (_queryResult isEqualType "" || _queryResult isEqualTo []) exitWith { + [] remoteExecCall ["SOCK_fnc_insertPlayerInfo",_ownerID]; +}; + +private _licenses = _queryResult select 6; + +for "_i" from 0 to (count _licenses) -1 do { + (_licenses select _i) params ["_license", "_owned"]; + _licenses set[_i, [_license, [false, true] select _owned]]; +}; + +private "_playTimes"; + +switch (_side) do { + case civilian: { + _queryResult set[7, [false, true] select (_queryResult select 7)]; + _queryResult set[10, [false, true] select (_queryResult select 10)]; + + _playTimes = _queryResult select 12; + + /* Make sure nothing else is added under here */ + _houseData = _uid spawn TON_fnc_fetchPlayerHouses; + waitUntil {scriptDone _houseData}; + _queryResult pushBack (missionNamespace getVariable [format ["houses_%1",_uid],[]]); + _gangData = _uid spawn TON_fnc_queryPlayerGang; + waitUntil {scriptDone _gangData}; + _queryResult pushBack (missionNamespace getVariable [format ["gang_%1",_uid],[]]); + }; + + case west: { + _queryResult set[9, [false, true] select (_queryResult select 9)]; + _playTimes = _queryResult select 11; + }; + + case independent: { + _playTimes = _queryResult select 10; + }; +}; + +_index = TON_fnc_playtime_values_request find [_uid, _playTimes]; + +if (_index != -1) then { + TON_fnc_playtime_values_request set[_index,-1]; + TON_fnc_playtime_values_request = TON_fnc_playtime_values_request - [-1]; + TON_fnc_playtime_values_request pushBack [_uid, _playTimes]; +} else { + TON_fnc_playtime_values_request pushBack [_uid, _playTimes]; +}; + +[_uid, _playTimes select 2] call TON_fnc_setPlayTime; +publicVariable "TON_fnc_playtime_values_request"; + +life_keyreceived = false; +life_keyreceivedvar = []; +[_uid, _side] remoteExecCall ["TON_fnc_recupKeyForHC", RSERV]; +waitUntil {life_keyreceived}; +_keyArr = life_keyreceivedvar; +_queryResult pushBack _keyArr; + +_queryResult remoteExec ["SOCK_fnc_requestReceived",_ownerID]; diff --git a/life_hc/MySQL/General/fn_updatePartial.sqf b/life_hc/MySQL/General/fn_updatePartial.sqf index 5d96f8748..d0a20ddf5 100755 --- a/life_hc/MySQL/General/fn_updatePartial.sqf +++ b/life_hc/MySQL/General/fn_updatePartial.sqf @@ -1,75 +1,76 @@ -/* - File: fn_updatePartial.sqf - Author: Bryan "Tonic" Boardwine - - This file is for Nanou's HeadlessClient. - - Description: - Takes partial data of a player and updates it, this is meant to be - less network intensive towards data flowing through it for updates. -*/ - -params [ - ["_unit",objNull,[objNull]], - ["_mode", -1, [0]], - "_value", - "_value1" -]; - -if (isNull _unit) exitWith {}; //Bad. -private _uid = getPlayerUID _unit; -private _side = side _unit; -private _query = ""; - -switch (_mode) do { - case 0: { - _query = format ["updateCash:%1:%2", _value, _uid]; - }; - - case 1: { - _query = format ["updateBank:%1:%2",_value,_uid]; - }; - - case 2: { - for "_i" from 0 to (count _value) -1 do { - (_value select _i) params ["_license", "_owned"]; - _value set[_i, [_license, [0, 1] select _owned]]; - }; - - switch (_side) do { - case west: {_query = format ["updateWestLicenses:%1:%2", _value, _uid];}; - case civilian: {_query = format ["updateCivLicenses:%1:%2", _value, _uid];}; - case independent: {_query = format ["updateIndepLicenses:%1:%2", _value, _uid];}; - }; - }; - - case 3: { - switch (_side) do { - case west: {_query = format ["updateWestGear:%1:%2", _value, _uid];}; - case civilian: {_query = format ["updateCivGear:%1:%2", _value, _uid];}; - case independent: {_query = format ["updateIndepGear:%1:%2", _value, _uid];}; - }; - }; - - case 4: { - private _position = if (alive _unit) then {getPosATL _unit} else {[]}; - _query = format ["updateCivPosition:%1:%2", _position, _uid]; - }; - - case 5: { - _value = [0, 1] select _value; - _query = format ["updateArrested:%1:%2",_value,_uid]; - }; - - case 6: { - _query = format ["updateCashAndBank:%1:%2:%3", _value, _value1, _uid]; - }; - - case 7: { - [_uid, _side, _value, 0] call TON_fnc_keyManagement; - }; -}; - -if (_query isEqualTo "") exitWith {}; - -[_query, 1] call HC_fnc_asyncCall; +/* + File: fn_updatePartial.sqf + Author: Bryan "Tonic" Boardwine + + This file is for Nanou's HeadlessClient. + + Description: + Takes partial data of a player and updates it, this is meant to be + less network intensive towards data flowing through it for updates. +*/ + +params [ + ["_unit",objNull,[objNull]], + ["_mode", -1, [0]], + "_value", + "_value1" +]; + +if (isNull _unit) exitWith {}; //Bad. +private _uid = getPlayerUID _unit; +private _side = side _unit; +private _query = ""; + +switch (_mode) do { + case 0: { + _query = format ["updateCash:%1:%2", _value, _uid]; + }; + + case 1: { + _query = format ["updateBank:%1:%2",_value,_uid]; + }; + + case 2: { + for "_i" from 0 to (count _value) -1 do { + (_value select _i) params ["_license", "_owned"]; + _value set[_i, [_license, [0, 1] select _owned]]; + }; + + switch (_side) do { + case west: {_query = format ["updateWestLicenses:%1:%2", _value, _uid];}; + case civilian: {_query = format ["updateCivLicenses:%1:%2", _value, _uid];}; + case independent: {_query = format ["updateIndepLicenses:%1:%2", _value, _uid];}; + }; + }; + + case 3: { + switch (_side) do { + case west: {_query = format ["updateWestGear:%1:%2", _value, _uid];}; + case civilian: {_query = format ["updateCivGear:%1:%2", _value, _uid];}; + case independent: {_query = format ["updateIndepGear:%1:%2", _value, _uid];}; + }; + }; + + case 4: { + private _alive = alive _unit; + private _position = getPosATL _unit; + _query = format ["updateCivPosition:%1:%2:%3", _alive, _position, _uid]; + }; + + case 5: { + _value = [0, 1] select _value; + _query = format ["updateArrested:%1:%2",_value,_uid]; + }; + + case 6: { + _query = format ["updateCashAndBank:%1:%2:%3", _value, _value1, _uid]; + }; + + case 7: { + [_uid, _side, _value, 0] call TON_fnc_keyManagement; + }; +}; + +if (_query isEqualTo "") exitWith {}; + +[_query, 1] call HC_fnc_asyncCall; diff --git a/life_hc/MySQL/General/fn_updateRequest.sqf b/life_hc/MySQL/General/fn_updateRequest.sqf index d3cc3bf57..8217cd48c 100755 --- a/life_hc/MySQL/General/fn_updateRequest.sqf +++ b/life_hc/MySQL/General/fn_updateRequest.sqf @@ -1,61 +1,61 @@ -/* - File: fn_updateRequest.sqf - Author: Bryan "Tonic" Boardwine - - This file is for Nanou's HeadlessClient. - - Description: - Updates ALL player information in the database. - Information gets passed here from the client side file: core\session\fn_updateRequest.sqf -*/ - -params [ - ["_unit",objNull,[objNull]], - ["_cash", 0, [0]], - ["_bank", 5000, [0]], - ["_licenses", [], [[]]], - ["_gear", [], [[]]], - ["_stats", [100,100],[[]]], - ["_arrested", false, [true]] -]; - -//Get to those error checks. -if (isNull _unit) exitWith {}; - -//Setup some data. -private _uid = getPlayerUID _unit; -private _name = name _unit; -private _side = side _unit; -private _alive = alive _unit; -private _position = if (_side isEqualTo civilian && {alive _unit}) then {getPosATL _unit} else {[]}; -_arrested = [0, 1] select _arrested; - -for "_i" from 0 to (count _licenses) -1 do { - (_licenses select _i) params ["_license", "_owned"]; - _licenses set[_i, [_license, [0, 1] select _owned]]; -}; - -//PLAYTIME -_playtime = [_uid] call HC_fnc_getPlayTime; -_playtime_update = []; -{ - if ((_x select 0) isEqualTo _uid) exitWith - { - _playtime_update pushBack [_x select 1]; - }; -} forEach TON_fnc_playtime_values_request; -_playtime_update = (_playtime_update select 0) select 0; -switch (_side) do { - case west: {_playtime_update set[0,_playtime];}; - case civilian: {_playtime_update set[2,_playtime];}; - case independent: {_playtime_update set[1,_playtime];}; -}; - -private _query = switch (_side) do { - case west: {format ["updateWest:%1:%2:%3:%4:%5:%6:%7:%8", _name, _cash, _bank, _gear, _licenses, _stats, _playtime_update, _uid];}; - case civilian: {format ["updateCiv:%1:%2:%3:%4:%5:%6:%7:%8:%9:%10", _name, _cash, _bank, _licenses, _gear, _arrested, _stats, _position, _playtime_update, _uid];}; - case independent: {format ["updateIndep:%1:%2:%3:%4:%5:%6:%7:%8", _name, _cash, _bank, _licenses, _gear, _stats, _playtime_update, _uid];}; -}; - - -_queryResult = [_query, 1] call HC_fnc_asyncCall; +/* + File: fn_updateRequest.sqf + Author: Bryan "Tonic" Boardwine + + This file is for Nanou's HeadlessClient. + + Description: + Updates ALL player information in the database. + Information gets passed here from the client side file: core\session\fn_updateRequest.sqf +*/ + +params [ + ["_unit",objNull,[objNull]], + ["_cash", 0, [0]], + ["_bank", 5000, [0]], + ["_licenses", [], [[]]], + ["_gear", [], [[]]], + ["_stats", [100,100],[[]]], + ["_arrested", false, [true]] +]; + +//Get to those error checks. +if (isNull _unit) exitWith {}; + +//Setup some data. +private _uid = getPlayerUID _unit; +private _name = name _unit; +private _side = side _unit; +private _alive = alive _unit; +private _position = getPosATL _unit; +_arrested = [0, 1] select _arrested; + +for "_i" from 0 to (count _licenses) -1 do { + (_licenses select _i) params ["_license", "_owned"]; + _licenses set[_i, [_license, [0, 1] select _owned]]; +}; + +//PLAYTIME +_playtime = [_uid] call HC_fnc_getPlayTime; +_playtime_update = []; +{ + if ((_x select 0) isEqualTo _uid) exitWith + { + _playtime_update pushBack [_x select 1]; + }; +} forEach TON_fnc_playtime_values_request; +_playtime_update = (_playtime_update select 0) select 0; +switch (_side) do { + case west: {_playtime_update set[0,_playtime];}; + case civilian: {_playtime_update set[2,_playtime];}; + case independent: {_playtime_update set[1,_playtime];}; +}; + +private _query = switch (_side) do { + case west: {format ["updateWest:%1:%2:%3:%4:%5:%6:%7:%8", _name, _cash, _bank, _gear, _licenses, _stats, _playtime_update, _uid];}; + case civilian: {format ["updateCiv:%1:%2:%3:%4:%5:%6:%7:%8:%9:%10:%11", _name, _cash, _bank, _licenses, _gear, _arrested, _stats, _alive, _position, _playtime_update, _uid];}; + case independent: {format ["updateIndep:%1:%2:%3:%4:%5:%6:%7:%8", _name, _cash, _bank, _licenses, _gear, _stats, _playtime_update, _uid];}; +}; + + +_queryResult = [_query, 1] call HC_fnc_asyncCall; diff --git a/life_server/Functions/MySQL/fn_queryRequest.sqf b/life_server/Functions/MySQL/fn_queryRequest.sqf index 2ddabd9f2..93973272e 100755 --- a/life_server/Functions/MySQL/fn_queryRequest.sqf +++ b/life_server/Functions/MySQL/fn_queryRequest.sqf @@ -1,99 +1,100 @@ -#include "\life_server\script_macros.hpp" -/* - File: fn_queryRequest.sqf - Author: Bryan "Tonic" Boardwine - - Description: - Handles the incoming request and sends an asynchronous query - request to the database. - - Return: - ARRAY - If array has 0 elements it should be handled as an error in client-side files. - STRING - The request had invalid handles or an unknown error and is logged to the RPT. -*/ - -params [ - ["_uid", "", [""]], - ["_side", sideUnknown, [civilian]], - ["_ownerID", objNull, [objNull]] -]; - -if (isNull _ownerID) exitWith {}; -_ownerID = owner _ownerID; - -private _query = switch (_side) do { - // West - 11 entries returned - case west: {format ["selectWest:%1", _uid];}; - // Civilian - 11 entries returned - case civilian: {format ["selectCiv:%1", _uid];}; - // Independent - 10 entries returned - case independent: {format ["selectIndep:%1",_uid];}; -}; - -private _tickTime = diag_tickTime; -private _queryResult = [_query,2] call DB_fnc_asyncCall; - -if (EXTDB_SETTING(getNumber,"DebugMode") isEqualTo 1) then { - diag_log "------------- Client Query Request -------------"; - diag_log format ["QUERY: %1",_query]; - diag_log format ["Time to complete: %1 (in seconds)",(diag_tickTime - _tickTime)]; - diag_log format ["Result: %1",_queryResult]; - diag_log "------------------------------------------------"; -}; - -if (_queryResult isEqualType "" || _queryResult isEqualTo []) exitWith { - [] remoteExecCall ["SOCK_fnc_insertPlayerInfo",_ownerID]; -}; - -private _licenses = (_queryResult select 6); - -for "_i" from 0 to (count _licenses) -1 do { - (_licenses select _i) params ["_license", "_owned"]; - _licenses set[_i, [_license, [false, true] select _owned]]; -}; - -private "_playTimes"; - -switch (_side) do { - case civilian: { - _queryResult set[7, [false, true] select (_queryResult select 7)]; - - _playTimes = _queryResult select 11; - [_uid, _playTimes select 2] call TON_fnc_setPlayTime; - - /* Make sure nothing else is added under here */ - _houseData = _uid spawn TON_fnc_fetchPlayerHouses; - waitUntil {scriptDone _houseData}; - _queryResult pushBack (missionNamespace getVariable [format ["houses_%1",_uid],[]]); - _gangData = _uid spawn TON_fnc_queryPlayerGang; - waitUntil {scriptDone _gangData}; - _queryResult pushBack (missionNamespace getVariable [format ["gang_%1",_uid],[]]); - }; - - case west: { - _queryResult set[9, [false, true] select (_queryResult select 9)]; - _playTimes = _queryResult select 11; - [_uid, _playTimes select 0] call TON_fnc_setPlayTime; - }; - - case independent: { - _playTimes = _queryResult select 10; - [_uid, _playTimes select 1] call TON_fnc_setPlayTime; - }; -}; - -_index = TON_fnc_playtime_values_request find [_uid, _playTimes]; - -if !(_index isEqualTo -1) then { - TON_fnc_playtime_values_request set[_index,-1]; - TON_fnc_playtime_values_request = TON_fnc_playtime_values_request - [-1]; - TON_fnc_playtime_values_request pushBack [_uid, _playTimes]; -} else { - TON_fnc_playtime_values_request pushBack [_uid, _playTimes]; -}; - -publicVariable "TON_fnc_playtime_values_request"; - -_keyArr = missionNamespace getVariable [format ["%1_KEYS_%2",_uid,_side], []]; -_queryResult pushBack _keyArr; -_queryResult remoteExec ["SOCK_fnc_requestReceived", _ownerID]; +#include "\life_server\script_macros.hpp" +/* + File: fn_queryRequest.sqf + Author: Bryan "Tonic" Boardwine + + Description: + Handles the incoming request and sends an asynchronous query + request to the database. + + Return: + ARRAY - If array has 0 elements it should be handled as an error in client-side files. + STRING - The request had invalid handles or an unknown error and is logged to the RPT. +*/ + +params [ + ["_uid", "", [""]], + ["_side", sideUnknown, [civilian]], + ["_ownerID", objNull, [objNull]] +]; + +if (isNull _ownerID) exitWith {}; +_ownerID = owner _ownerID; + +private _query = switch (_side) do { + // West - 11 entries returned + case west: {format ["selectWest:%1", _uid];}; + // Civilian - 12 entries returned + case civilian: {format ["selectCiv:%1", _uid];}; + // Independent - 10 entries returned + case independent: {format ["selectIndep:%1",_uid];}; +}; + +private _tickTime = diag_tickTime; +private _queryResult = [_query,2] call DB_fnc_asyncCall; + +if (EXTDB_SETTING(getNumber,"DebugMode") isEqualTo 1) then { + diag_log "------------- Client Query Request -------------"; + diag_log format ["QUERY: %1",_query]; + diag_log format ["Time to complete: %1 (in seconds)",(diag_tickTime - _tickTime)]; + diag_log format ["Result: %1",_queryResult]; + diag_log "------------------------------------------------"; +}; + +if (_queryResult isEqualType "" || _queryResult isEqualTo []) exitWith { + [] remoteExecCall ["SOCK_fnc_insertPlayerInfo",_ownerID]; +}; + +private _licenses = (_queryResult select 6); + +for "_i" from 0 to (count _licenses) -1 do { + (_licenses select _i) params ["_license", "_owned"]; + _licenses set[_i, [_license, [false, true] select _owned]]; +}; + +private "_playTimes"; + +switch (_side) do { + case civilian: { + _queryResult set[7, [false, true] select (_queryResult select 7)]; + _queryResult set[10, [false, true] select (_queryResult select 10)]; + + _playTimes = _queryResult select 12; + [_uid, _playTimes select 2] call TON_fnc_setPlayTime; + + /* Make sure nothing else is added under here */ + _houseData = _uid spawn TON_fnc_fetchPlayerHouses; + waitUntil {scriptDone _houseData}; + _queryResult pushBack (missionNamespace getVariable [format ["houses_%1",_uid],[]]); + _gangData = _uid spawn TON_fnc_queryPlayerGang; + waitUntil {scriptDone _gangData}; + _queryResult pushBack (missionNamespace getVariable [format ["gang_%1",_uid],[]]); + }; + + case west: { + _queryResult set[9, [false, true] select (_queryResult select 9)]; + _playTimes = _queryResult select 11; + [_uid, _playTimes select 0] call TON_fnc_setPlayTime; + }; + + case independent: { + _playTimes = _queryResult select 10; + [_uid, _playTimes select 1] call TON_fnc_setPlayTime; + }; +}; + +_index = TON_fnc_playtime_values_request find [_uid, _playTimes]; + +if !(_index isEqualTo -1) then { + TON_fnc_playtime_values_request set[_index,-1]; + TON_fnc_playtime_values_request = TON_fnc_playtime_values_request - [-1]; + TON_fnc_playtime_values_request pushBack [_uid, _playTimes]; +} else { + TON_fnc_playtime_values_request pushBack [_uid, _playTimes]; +}; + +publicVariable "TON_fnc_playtime_values_request"; + +_keyArr = missionNamespace getVariable [format ["%1_KEYS_%2",_uid,_side], []]; +_queryResult pushBack _keyArr; +_queryResult remoteExec ["SOCK_fnc_requestReceived", _ownerID]; diff --git a/life_server/Functions/MySQL/fn_updatePartial.sqf b/life_server/Functions/MySQL/fn_updatePartial.sqf index 92bd4d287..e025bfd55 100755 --- a/life_server/Functions/MySQL/fn_updatePartial.sqf +++ b/life_server/Functions/MySQL/fn_updatePartial.sqf @@ -1,73 +1,70 @@ -/* - File: fn_updatePartial.sqf - Author: Bryan "Tonic" Boardwine - - Description: - Takes partial data of a player and updates it, this is meant to be - less network intensive towards data flowing through it for updates. -*/ - -params [ - ["_unit",objNull,[objNull]], - ["_mode", -1, [0]], - "_value", - "_value1" -]; - -if (isNull _unit) exitWith {}; //Bad. -private _uid = getPlayerUID _unit; -private _side = side _unit; -private _query = ""; - -switch (_mode) do { - case 0: { - _query = format ["updateCash:%1:%2", _value, _uid]; - }; - - case 1: { - _query = format ["updateBank:%1:%2",_value,_uid]; - }; - - case 2: { - for "_i" from 0 to (count _value) -1 do { - (_value select _i) params ["_license", "_owned"]; - _value set[_i, [_license, [0, 1] select _owned]]; - }; - - switch (_side) do { - case west: {_query = format ["updateWestLicenses:%1:%2", _value, _uid];}; - case civilian: {_query = format ["updateCivLicenses:%1:%2", _value, _uid];}; - case independent: {_query = format ["updateIndepLicenses:%1:%2", _value, _uid];}; - }; - }; - - case 3: { - switch (_side) do { - case west: {_query = format ["updateWestGear:%1:%2", _value, _uid];}; - case civilian: {_query = format ["updateCivGear:%1:%2", _value, _uid];}; - case independent: {_query = format ["updateIndepGear:%1:%2", _value, _uid];}; - }; - }; - - case 4: { - private _position = if (alive _unit) then {getPosATL _unit} else {[]}; - _query = format ["updateCivPosition:%1:%2", _position, _uid]; - }; - - case 5: { - _value = [0, 1] select _value; - _query = format ["updateArrested:%1:%2",_value,_uid]; - }; - - case 6: { - _query = format ["updateCashAndBank:%1:%2:%3", _value, _value1, _uid]; - }; - - case 7: { - [_uid, _side, _value, 0] call TON_fnc_keyManagement; - }; -}; - -if (_query isEqualTo "") exitWith {}; - -[_query, 1] call DB_fnc_asyncCall; +/* + File: fn_updatePartial.sqf + Author: Bryan "Tonic" Boardwine + + Description: + Takes partial data of a player and updates it, this is meant to be + less network intensive towards data flowing through it for updates. +*/ + +params [ + ["_unit",objNull,[objNull]], + ["_mode", -1, [0]], + "_value", + "_value1" +]; + +if (isNull _unit) exitWith {}; //Bad. +private _uid = getPlayerUID _unit; +private _side = side _unit; +private _query = ""; + +switch (_mode) do { + case 0: { + _query = format ["updateCash:%1:%2", _value, _uid]; + }; + + case 1: { + _query = format ["updateBank:%1:%2",_value,_uid]; + }; + + case 2: { + for "_i" from 0 to (count _value) -1 do { + (_value select _i) params ["_license", "_owned"]; + _value set[_i, [_license, [0, 1] select _owned]]; + }; + + switch (_side) do { + case west: {_query = format ["updateWestLicenses:%1:%2", _value, _uid];}; + case civilian: {_query = format ["updateCivLicenses:%1:%2", _value, _uid];}; + case independent: {_query = format ["updateIndepLicenses:%1:%2", _value, _uid];}; + }; + }; + + case 3: { + switch (_side) do { + case west: {_query = format ["updateWestGear:%1:%2", _value, _uid];}; + case civilian: {_query = format ["updateCivGear:%1:%2", _value, _uid];}; + case independent: {_query = format ["updateIndepGear:%1:%2", _value, _uid];}; + }; + }; + + case 4: { + private _alive = alive _unit; + private _position = getPosATL _unit; + _query = format ["updateCivPosition:%1:%2:%3", _alive, _position, _uid]; + }; + + case 5: { + _value = [0, 1] select _value; + _query = format ["updateArrested:%1:%2",_value,_uid]; + }; + + case 6: { + _query = format ["updateCashAndBank:%1:%2:%3", _value, _value1, _uid]; + }; +}; + +if (_query isEqualTo "") exitWith {}; + +[_query, 1] call DB_fnc_asyncCall; diff --git a/life_server/Functions/MySQL/fn_updateRequest.sqf b/life_server/Functions/MySQL/fn_updateRequest.sqf index 9ace1b317..7a2845ec6 100755 --- a/life_server/Functions/MySQL/fn_updateRequest.sqf +++ b/life_server/Functions/MySQL/fn_updateRequest.sqf @@ -1,58 +1,58 @@ -/* - File: fn_updateRequest.sqf - Author: Bryan "Tonic" Boardwine - - Description: - Updates ALL player information in the database. - Information gets passed here from the client side file: core\session\fn_updateRequest.sqf -*/ - -params [ - ["_unit",objNull,[objNull]], - ["_cash", 0, [0]], - ["_bank", 5000, [0]], - ["_licenses", [], [[]]], - ["_gear", [], [[]]], - ["_stats", [100,100],[[]]], - ["_arrested", false, [true]] -]; - -//Get to those error checks. -if (isNull _unit) exitWith {}; - -//Setup some data. -private _uid = getPlayerUID _unit; -private _name = name _unit; -private _side = side _unit; -private _alive = alive _unit; -private _position = if (_side isEqualTo civilian && {alive _unit}) then {getPosATL _unit} else {[]}; -_arrested = [0, 1] select _arrested; - -for "_i" from 0 to (count _licenses) -1 do { - (_licenses select _i) params ["_license", "_owned"]; - _licenses set[_i, [_license, [0, 1] select _owned]]; -}; - -//PLAYTIME -_playtime = [_uid] call TON_fnc_getPlayTime; -_playtime_update = []; -{ - if ((_x select 0) isEqualTo _uid) exitWith - { - _playtime_update pushBack [_x select 1]; - }; -} forEach TON_fnc_playtime_values_request; -_playtime_update = (_playtime_update select 0) select 0; -switch (_side) do { - case west: {_playtime_update set[0,_playtime];}; - case civilian: {_playtime_update set[2,_playtime];}; - case independent: {_playtime_update set[1,_playtime];}; -}; - -private _query = switch (_side) do { - case west: {format ["updateWest:%1:%2:%3:%4:%5:%6:%7:%8", _name, _cash, _bank, _gear, _licenses, _stats, _playtime_update, _uid];}; - case civilian: {format ["updateCiv:%1:%2:%3:%4:%5:%6:%7:%8:%9:%10", _name, _cash, _bank, _licenses, _gear, _arrested, _stats, _position, _playtime_update, _uid];}; - case independent: {format ["updateIndep:%1:%2:%3:%4:%5:%6:%7:%8", _name, _cash, _bank, _licenses, _gear, _stats, _playtime_update, _uid];}; -}; - -_queryResult = [_query, 1] call DB_fnc_asyncCall; +/* + File: fn_updateRequest.sqf + Author: Bryan "Tonic" Boardwine + + Description: + Updates ALL player information in the database. + Information gets passed here from the client side file: core\session\fn_updateRequest.sqf +*/ + +params [ + ["_unit",objNull,[objNull]], + ["_cash", 0, [0]], + ["_bank", 5000, [0]], + ["_licenses", [], [[]]], + ["_gear", [], [[]]], + ["_stats", [100,100],[[]]], + ["_arrested", false, [true]] +]; + +//Get to those error checks. +if (isNull _unit) exitWith {}; + +//Setup some data. +private _uid = getPlayerUID _unit; +private _name = name _unit; +private _side = side _unit; +private _alive = alive _unit; +private _position = getPosATL _unit; +_arrested = [0, 1] select _arrested; + +for "_i" from 0 to (count _licenses) -1 do { + (_licenses select _i) params ["_license", "_owned"]; + _licenses set[_i, [_license, [0, 1] select _owned]]; +}; + +//PLAYTIME +_playtime = [_uid] call TON_fnc_getPlayTime; +_playtime_update = []; +{ + if ((_x select 0) isEqualTo _uid) exitWith + { + _playtime_update pushBack [_x select 1]; + }; +} forEach TON_fnc_playtime_values_request; +_playtime_update = (_playtime_update select 0) select 0; +switch (_side) do { + case west: {_playtime_update set[0,_playtime];}; + case civilian: {_playtime_update set[2,_playtime];}; + case independent: {_playtime_update set[1,_playtime];}; +}; + +private _query = switch (_side) do { + case west: {format ["updateWest:%1:%2:%3:%4:%5:%6:%7:%8", _name, _cash, _bank, _gear, _licenses, _stats, _playtime_update, _uid];}; + case civilian: {format ["updateCiv:%1:%2:%3:%4:%5:%6:%7:%8:%9:%10:%11", _name, _cash, _bank, _licenses, _gear, _arrested, _stats, _alive, _position, _playtime_update, _uid];}; + case independent: {format ["updateIndep:%1:%2:%3:%4:%5:%6:%7:%8", _name, _cash, _bank, _licenses, _gear, _stats, _playtime_update, _uid];}; +}; + +_queryResult = [_query, 1] call DB_fnc_asyncCall; From 9fe1cd2e4f18a652cd92a589bdb3a68293232f77 Mon Sep 17 00:00:00 2001 From: Dom Date: Wed, 1 Apr 2020 10:40:05 +0100 Subject: [PATCH 5/6] Remove fn_cleanupRequest --- Altis_Life.Altis/CfgRemoteExec.hpp | 1 - Altis_Life.Altis/config/Config_SpyGlass.hpp | 2 +- .../core/functions/fn_onGameInterrupt.sqf | 6 ++--- BEFilters/remoteexec.txt | 2 +- .../Functions/Systems/fn_cleanupRequest.sqf | 27 ------------------- life_server/config.cpp | 1 - 6 files changed, 5 insertions(+), 34 deletions(-) delete mode 100644 life_server/Functions/Systems/fn_cleanupRequest.sqf diff --git a/Altis_Life.Altis/CfgRemoteExec.hpp b/Altis_Life.Altis/CfgRemoteExec.hpp index d08d6d4bb..77745582d 100644 --- a/Altis_Life.Altis/CfgRemoteExec.hpp +++ b/Altis_Life.Altis/CfgRemoteExec.hpp @@ -92,7 +92,6 @@ class CfgRemoteExec { F(TON_fnc_addContainer,SERVER) F(TON_fnc_addHouse,SERVER) F(TON_fnc_chopShopSell,SERVER) - F(TON_fnc_cleanupRequest,SERVER) F(TON_fnc_deleteDBContainer,SERVER) F(TON_fnc_getID,SERVER) F(TON_fnc_getVehicles,SERVER) diff --git a/Altis_Life.Altis/config/Config_SpyGlass.hpp b/Altis_Life.Altis/config/Config_SpyGlass.hpp index d72c0c20a..fb3d61267 100644 --- a/Altis_Life.Altis/config/Config_SpyGlass.hpp +++ b/Altis_Life.Altis/config/Config_SpyGlass.hpp @@ -286,7 +286,7 @@ class SpyGlass { SERVER_Functions[] = { "db_fnc_asynccall","db_fnc_bool","db_fnc_insertrequest","db_fnc_insertvehicle","db_fnc_mresarray","db_fnc_mresstring","db_fnc_mrestoarray","db_fnc_numbersafe","db_fnc_queryrequest","db_fnc_updatepartial","db_fnc_updaterequest","ton_fnc_addhouse","ton_fnc_addhouse_meta","ton_fnc_cell_adminmsg","ton_fnc_cell_adminmsgall","ton_fnc_cell_emsrequest","ton_fnc_cell_textadmin","ton_fnc_cell_textcop", - "ton_fnc_cell_textmsg","ton_fnc_chopshopsell","ton_fnc_chopshopsell_meta","ton_fnc_cleanup","ton_fnc_cleanup_meta","ton_fnc_cleanuprequest","ton_fnc_cleanuprequest_meta","ton_fnc_clientdisconnect","ton_fnc_clientdisconnect_meta","ton_fnc_clientgangkick","ton_fnc_clientgangleader","ton_fnc_clientgangleft","TON_fnc_clientGangLeft","ton_fnc_clientgetkey","ton_fnc_clientmessage","ton_fnc_federalupdate", + "ton_fnc_cell_textmsg","ton_fnc_chopshopsell","ton_fnc_chopshopsell_meta","ton_fnc_cleanup","ton_fnc_cleanup_meta","ton_fnc_clientdisconnect","ton_fnc_clientdisconnect_meta","ton_fnc_clientgangkick","ton_fnc_clientgangleader","ton_fnc_clientgangleft","TON_fnc_clientGangLeft","ton_fnc_clientgetkey","ton_fnc_clientmessage","ton_fnc_federalupdate", "ton_fnc_federalupdate_meta","ton_fnc_fetchplayerhouses","ton_fnc_fetchplayerhouses_meta","ton_fnc_getid","ton_fnc_getid_meta","ton_fnc_getvehicles","ton_fnc_getvehicles_meta","ton_fnc_housecleanup","ton_fnc_housecleanup_meta","ton_fnc_huntingzone","ton_fnc_huntingzone_meta","ton_fnc_index","ton_fnc_inithouses","ton_fnc_inithouses_meta","ton_fnc_insertgang","ton_fnc_insertgang_meta","ton_fnc_isnumber", "ton_fnc_keymanagement","ton_fnc_keymanagement_meta","ton_fnc_managesc","ton_fnc_managesc_meta","ton_fnc_pickupaction","ton_fnc_pickupaction_meta","ton_fnc_player_query","ton_fnc_queryplayergang","ton_fnc_queryplayergang_meta","ton_fnc_removegang","ton_fnc_removegang_meta","ton_fnc_sellhouse","ton_fnc_sellhouse_meta","ton_fnc_spawnvehicle", "ton_fnc_spawnvehicle_meta","ton_fnc_spikestrip","ton_fnc_spikestrip_meta","ton_fnc_terrainsort","ton_fnc_terrainsort_meta","ton_fnc_updategang","ton_fnc_updategang_meta","ton_fnc_updatehousecontainers","ton_fnc_updatehousecontainers_meta","ton_fnc_updatehousetrunk","ton_fnc_updatehousetrunk_meta","ton_fnc_vehiclecreate","ton_fnc_vehiclecreate_meta","ton_fnc_vehicledead","ton_fnc_vehicledead_meta", diff --git a/Altis_Life.Altis/core/functions/fn_onGameInterrupt.sqf b/Altis_Life.Altis/core/functions/fn_onGameInterrupt.sqf index 7506a4368..a4dcf4f2e 100644 --- a/Altis_Life.Altis/core/functions/fn_onGameInterrupt.sqf +++ b/Altis_Life.Altis/core/functions/fn_onGameInterrupt.sqf @@ -15,7 +15,7 @@ private _saveButton = _display displayCtrl 103; private _topButton = _display displayCtrl 2; _abortButton ctrlEnable false; -_abortButton buttonSetAction "call SOCK_fnc_updateRequest; [player] remoteExec [""TON_fnc_cleanupRequest"",2];"; +_abortButton buttonSetAction "call SOCK_fnc_updateRequest"; _fieldManual ctrlEnable false; _saveButton ctrlEnable false; @@ -43,5 +43,5 @@ if (_conditions) then { _abortButton ctrlEnable true; }; } else { - _respawnButton ctrlEnable false; -}; \ No newline at end of file + _respawnButton ctrlEnable false; +}; diff --git a/BEFilters/remoteexec.txt b/BEFilters/remoteexec.txt index f1aba0f4a..b026e4cf8 100644 --- a/BEFilters/remoteexec.txt +++ b/BEFilters/remoteexec.txt @@ -1,3 +1,3 @@ //regex 1 "" !="_this call fn_whoDoneIt" -5 "" !BIS_fnc_(effectKilled(AirDestruction|Secondaries)|execVM) !DB_fnc_(insertRequest|queryRequest|updatePartial|updateRequest) !HC_fnc_(addContainer|addHouse|chopShopSell|deleteDBContainer|getVehicles|insertGang|insertRequest|jailSys|queryRequest|receivekeyofServer) !HC_fnc_(removeGang|sellHouse(Container)?|spawnVehicle|spikeStrip) !HC_fnc_update(Gang|HouseContainers|HouseTrunk|Partial|Request) !HC_fnc_vehicle(Create|Delete|Store|Update) !HC_fnc_wanted(Add|Bounty|Crimes|Fetch|ProfUpdate|Remove) !life_fnc_(AAN|addVehicle2Chain|adminid|admininfo|animSync|bountyReceive|broadcast|colorVehicle|copLights) !life_fnc_(copSearch|CopSiren|corpse|demoChargeTimer|flashbang|freezePlayer|gangCreated|gangDisbanded|gangInvite) !life_fnc_(garageRefund|giveDiff|hideObj|impoundMenu|jail(Me|Sys)?) !life_fnc_(jumpFnc|knockedOut|licenseCheck|licensesRead|lightHouse|lockVehicle|medic(Lights|Request|Siren)) !life_fnc_(moveIn|pickupItem|pickupMoney|pulloutVeh|receiveItem|receiveMoney|removeLicenses|restrain|revived) !life_fnc_(robPerson|robReceive|say3D|searchClient|seizeClient|setFuel|simDisable|soundDevice|spikeStripEffect) !life_fnc_(tazeSound|ticketPaid|ticketPrompt|vehicleAnimate|gangBankResponse) !life_fnc_wanted(Add|Bounty|Crimes|Fetch|Info|List|ProfUpdate|Remove) !life_fnc_wireTransfer !SOCK_fnc_(dataQuery|insertPlayerInfo|updateRequest) !SPY_fnc_(cookieJar|notifyAdmins|observe) !TON_fnc_(addContainer|addHouse|chopShopSell|cleanupRequest|handleBlastingCharge) !TON_fnc_clientGang(Kick|Leader|Left) !TON_fnc_(clientGetKey|clientMessage) !TON_fnc_(deleteDBContainer|getID|getVehicles|insertGang|keyManagement|managesc|pickupAction|player_query|recupkeyforHC) !TON_fnc_(removeGang|sellHouse(Container)?|spawnVehicle|spikeStrip) !TON_fnc_update(Gang|HouseContainers|HouseTrunk) !TON_fnc_vehicle(Create|Delete|Store|Update) !="_this call fn_whoDoneIt" +5 "" !BIS_fnc_(effectKilled(AirDestruction|Secondaries)|execVM) !DB_fnc_(insertRequest|queryRequest|updatePartial|updateRequest) !HC_fnc_(addContainer|addHouse|chopShopSell|deleteDBContainer|getVehicles|insertGang|insertRequest|jailSys|queryRequest|receivekeyofServer) !HC_fnc_(removeGang|sellHouse(Container)?|spawnVehicle|spikeStrip) !HC_fnc_update(Gang|HouseContainers|HouseTrunk|Partial|Request) !HC_fnc_vehicle(Create|Delete|Store|Update) !HC_fnc_wanted(Add|Bounty|Crimes|Fetch|ProfUpdate|Remove) !life_fnc_(AAN|addVehicle2Chain|adminid|admininfo|animSync|bountyReceive|broadcast|colorVehicle|copLights) !life_fnc_(copSearch|CopSiren|corpse|demoChargeTimer|flashbang|freezePlayer|gangCreated|gangDisbanded|gangInvite) !life_fnc_(garageRefund|giveDiff|hideObj|impoundMenu|jail(Me|Sys)?) !life_fnc_(jumpFnc|knockedOut|licenseCheck|licensesRead|lightHouse|lockVehicle|medic(Lights|Request|Siren)) !life_fnc_(moveIn|pickupItem|pickupMoney|pulloutVeh|receiveItem|receiveMoney|removeLicenses|restrain|revived) !life_fnc_(robPerson|robReceive|say3D|searchClient|seizeClient|setFuel|simDisable|soundDevice|spikeStripEffect) !life_fnc_(tazeSound|ticketPaid|ticketPrompt|vehicleAnimate|gangBankResponse) !life_fnc_wanted(Add|Bounty|Crimes|Fetch|Info|List|ProfUpdate|Remove) !life_fnc_wireTransfer !SOCK_fnc_(dataQuery|insertPlayerInfo|updateRequest) !SPY_fnc_(cookieJar|notifyAdmins|observe) !TON_fnc_(addContainer|addHouse|chopShopSell|handleBlastingCharge) !TON_fnc_clientGang(Kick|Leader|Left) !TON_fnc_(clientGetKey|clientMessage) !TON_fnc_(deleteDBContainer|getID|getVehicles|insertGang|keyManagement|managesc|pickupAction|player_query|recupkeyforHC) !TON_fnc_(removeGang|sellHouse(Container)?|spawnVehicle|spikeStrip) !TON_fnc_update(Gang|HouseContainers|HouseTrunk) !TON_fnc_vehicle(Create|Delete|Store|Update) !="_this call fn_whoDoneIt" diff --git a/life_server/Functions/Systems/fn_cleanupRequest.sqf b/life_server/Functions/Systems/fn_cleanupRequest.sqf deleted file mode 100644 index 4101d6286..000000000 --- a/life_server/Functions/Systems/fn_cleanupRequest.sqf +++ /dev/null @@ -1,27 +0,0 @@ -/* - File: fn_cleanupRequest.sqf - Author: Bryan "Tonic" Boardwine - - Description: - Client sends a cleanup request when they hit Abort, - the server will then monitor when that client aborts and - delete the weapon holders. -*/ -private ["_client","_loops"]; -_client = [_this,0,objNull,[objNull]] call BIS_fnc_param; -if (isNull _client) exitWith {}; - -_loops = 0; -for "_i" from 0 to 1 step 0 do { - if (_loops >= 25) exitWith {}; - if (!alive _client) exitWith { - _containers = nearestObjects[(getPosATL _client),["WeaponHolderSimulated"],5]; - if (count _containers > 0) then { - {deleteVehicle _x;} forEach _containers; //Delete the containers. - }; - deleteVehicle _client; //Get rid of the corpse. - }; - - _loops = _loops + 1; - uiSleep 1; -}; diff --git a/life_server/config.cpp b/life_server/config.cpp index c4bc04dd3..891ce449b 100644 --- a/life_server/config.cpp +++ b/life_server/config.cpp @@ -67,7 +67,6 @@ class CfgFunctions { class clientDisconnect {}; class entityRespawned {}; class entityKilled {}; - class cleanupRequest {}; class keyManagement {}; class vehicleUpdate {}; class recupkeyforHC {}; From 62ab60121035e4bf84ad3e8a63a251da5cc4bd92 Mon Sep 17 00:00:00 2001 From: Dom Date: Sat, 4 Apr 2020 14:04:55 +0100 Subject: [PATCH 6/6] bool to tinyint --- life_hc/MySQL/General/fn_updatePartial.sqf | 4 + life_hc/MySQL/General/fn_updateRequest.sqf | 4 + .../Functions/MySQL/fn_updatePartial.sqf | 4 + .../Functions/MySQL/fn_updateRequest.sqf | 5 + .../Functions/Systems/fn_clientDisconnect.sqf | 92 +++++++++---------- 5 files changed, 62 insertions(+), 47 deletions(-) diff --git a/life_hc/MySQL/General/fn_updatePartial.sqf b/life_hc/MySQL/General/fn_updatePartial.sqf index d0a20ddf5..4c44a62a2 100755 --- a/life_hc/MySQL/General/fn_updatePartial.sqf +++ b/life_hc/MySQL/General/fn_updatePartial.sqf @@ -53,6 +53,10 @@ switch (_mode) do { case 4: { private _alive = alive _unit; + if ((getMarkerPos "respawn_civilian" distance _position) < 300) then { + _alive = false; + }; + _alive = [0, 1] select _alive; private _position = getPosATL _unit; _query = format ["updateCivPosition:%1:%2:%3", _alive, _position, _uid]; }; diff --git a/life_hc/MySQL/General/fn_updateRequest.sqf b/life_hc/MySQL/General/fn_updateRequest.sqf index 8217cd48c..4bba1ba23 100755 --- a/life_hc/MySQL/General/fn_updateRequest.sqf +++ b/life_hc/MySQL/General/fn_updateRequest.sqf @@ -27,6 +27,10 @@ private _uid = getPlayerUID _unit; private _name = name _unit; private _side = side _unit; private _alive = alive _unit; +if ((getMarkerPos "respawn_civilian" distance _position) < 300) then { + _alive = false; +}; +_alive = [0, 1] select _alive; private _position = getPosATL _unit; _arrested = [0, 1] select _arrested; diff --git a/life_server/Functions/MySQL/fn_updatePartial.sqf b/life_server/Functions/MySQL/fn_updatePartial.sqf index e025bfd55..9783fde04 100755 --- a/life_server/Functions/MySQL/fn_updatePartial.sqf +++ b/life_server/Functions/MySQL/fn_updatePartial.sqf @@ -51,6 +51,10 @@ switch (_mode) do { case 4: { private _alive = alive _unit; + if ((getMarkerPos "respawn_civilian" distance _position) < 300) then { + _alive = false; + }; + _alive = [0, 1] select _alive; private _position = getPosATL _unit; _query = format ["updateCivPosition:%1:%2:%3", _alive, _position, _uid]; }; diff --git a/life_server/Functions/MySQL/fn_updateRequest.sqf b/life_server/Functions/MySQL/fn_updateRequest.sqf index 7a2845ec6..3e578981f 100755 --- a/life_server/Functions/MySQL/fn_updateRequest.sqf +++ b/life_server/Functions/MySQL/fn_updateRequest.sqf @@ -25,6 +25,11 @@ private _uid = getPlayerUID _unit; private _name = name _unit; private _side = side _unit; private _alive = alive _unit; +private _alive = alive _unit; +if ((getMarkerPos "respawn_civilian" distance _position) < 300) then { + _alive = false; +}; +_alive = [0, 1] select _alive; private _position = getPosATL _unit; _arrested = [0, 1] select _arrested; diff --git a/life_server/Functions/Systems/fn_clientDisconnect.sqf b/life_server/Functions/Systems/fn_clientDisconnect.sqf index 6d66eadf3..a4171273d 100644 --- a/life_server/Functions/Systems/fn_clientDisconnect.sqf +++ b/life_server/Functions/Systems/fn_clientDisconnect.sqf @@ -1,47 +1,45 @@ -#include "\life_server\script_macros.hpp" -/* - File: fn_clientDisconnect.sqf - Author: Bryan "Tonic" Boardwine - - Description: - When a client disconnects this will remove their corpse and - clean up their storage boxes in their house. Also, saves player infos & position. -*/ -params [ - ["_unit",objNull,[objNull]], - "", - ["_uid","",[""]] -]; -if (isNull _unit) exitWith {}; - -//Save civilian position -if (life_save_civilian_position && {side _unit isEqualTo civilian}) then { - if (isNil "HC_UID" || {!(_uid isEqualTo HC_UID)}) then { - if ((getMarkerPos "respawn_civilian" distance _position) > 300) then { - if (life_HC_isActive) then {[_unit,4] remoteExec ["HC_fnc_updatePartial",HC_Life]} else {[_unit,4] spawn DB_fnc_updatePartial}; - }; - }; -}; - -if !(alive _unit) then { - diag_log format["%1 disconnected while dead.",_uid]; -} else { - { - _x params [ - ["_corpseUID","",[""]], - ["_corpse",objNull,[objNull]] - ]; - if (_corpseUID isEqualTo _uid) exitWith { - if (isNull _corpse) exitWith {server_corpses deleteAt _forEachIndex}; - [_corpse] remoteExecCall ["life_fnc_corpse",0]; - diag_log format["%1 disconnected while dead.",_corpseUID]; - server_corpses deleteAt _forEachIndex; - }; - } forEach server_corpses; -}; - -private _containers = nearestObjects[_unit,["WeaponHolderSimulated"],5]; -{deleteVehicle _x} forEach _containers; -deleteVehicle _unit; - -[_uid] spawn TON_fnc_houseCleanup; +#include "\life_server\script_macros.hpp" +/* + File: fn_clientDisconnect.sqf + Author: Bryan "Tonic" Boardwine + + Description: + When a client disconnects this will remove their corpse and + clean up their storage boxes in their house. Also, saves player infos & position. +*/ +params [ + ["_unit",objNull,[objNull]], + "", + ["_uid","",[""]] +]; +if (isNull _unit) exitWith {}; + +//Save civilian position +if (life_save_civilian_position && {side _unit isEqualTo civilian}) then { + if (isNil "HC_UID" || {!(_uid isEqualTo HC_UID)}) then { + if (life_HC_isActive) then {[_unit,4] remoteExec ["HC_fnc_updatePartial",HC_Life]} else {[_unit,4] spawn DB_fnc_updatePartial}; + }; +}; + +if !(alive _unit) then { + diag_log format["%1 disconnected while dead.",_uid]; +} else { + { + _x params [ + ["_corpseUID","",[""]], + ["_corpse",objNull,[objNull]] + ]; + if (_corpseUID isEqualTo _uid) exitWith { + if (isNull _corpse) exitWith {server_corpses deleteAt _forEachIndex}; + [_corpse] remoteExecCall ["life_fnc_corpse",0]; + diag_log format["%1 disconnected while dead.",_corpseUID]; + server_corpses deleteAt _forEachIndex; + }; + } forEach server_corpses; +}; + +private _containers = nearestObjects[_unit,["WeaponHolderSimulated"],5]; +{deleteVehicle _x} forEach _containers; +deleteVehicle _unit; + +[_uid] spawn TON_fnc_houseCleanup;