From 1e9f139bf20aae47b794b6b032d6eb81d0d1af83 Mon Sep 17 00:00:00 2001 From: Jason Hall Date: Mon, 30 Dec 2019 17:11:04 +0000 Subject: [PATCH 01/12] Add sql-custom back --- AL.ini | 356 ++++++++++++++++++ .../core/session/fn_requestReceived.sqf | 13 +- altislife.sql | 200 +++++----- life_hc/FSM/cleanup.fsm | 4 +- life_hc/MySQL/Gangs/fn_insertGang.sqf | 61 +-- life_hc/MySQL/Gangs/fn_queryPlayerGang.sqf | 14 +- life_hc/MySQL/Gangs/fn_removeGang.sqf | 17 +- life_hc/MySQL/Gangs/fn_updateGang.sqf | 72 +--- life_hc/MySQL/General/fn_bool.sqf | 26 -- life_hc/MySQL/General/fn_cleanup.sqf | 2 +- life_hc/MySQL/General/fn_insertRequest.sqf | 33 +- life_hc/MySQL/General/fn_insertVehicle.sqf | 9 +- life_hc/MySQL/General/fn_mresArray.sqf | 27 -- life_hc/MySQL/General/fn_mresString.sqf | 21 -- life_hc/MySQL/General/fn_mresToArray.sqf | 26 -- life_hc/MySQL/General/fn_numberSafe.sqf | 28 -- life_hc/MySQL/General/fn_queryRequest.sqf | 181 +++------ life_hc/MySQL/General/fn_updatePartial.sqf | 75 ++-- life_hc/MySQL/General/fn_updateRequest.sqf | 59 ++- life_hc/MySQL/Housing/fn_addContainer.sqf | 27 +- life_hc/MySQL/Housing/fn_addHouse.sqf | 20 +- .../MySQL/Housing/fn_deleteDBContainer.sqf | 25 +- .../MySQL/Housing/fn_fetchPlayerHouses.sqf | 22 +- life_hc/MySQL/Housing/fn_houseGarage.sqf | 20 +- life_hc/MySQL/Housing/fn_sellHouse.sqf | 32 +- .../MySQL/Housing/fn_sellHouseContainer.sqf | 25 +- .../Housing/fn_updateHouseContainers.sqf | 26 +- life_hc/MySQL/Housing/fn_updateHouseTrunk.sqf | 19 +- life_hc/MySQL/Vehicles/fn_chopShopSell.sqf | 36 +- life_hc/MySQL/Vehicles/fn_getVehicles.sqf | 30 +- life_hc/MySQL/Vehicles/fn_spawnVehicle.sqf | 68 ++-- life_hc/MySQL/Vehicles/fn_vehicleCreate.sqf | 25 +- life_hc/MySQL/Vehicles/fn_vehicleDelete.sqf | 20 +- life_hc/MySQL/Vehicles/fn_vehicleStore.sqf | 118 +++--- life_hc/MySQL/Vehicles/fn_vehicleUpdate.sqf | 57 +-- life_hc/MySQL/WantedSystem/fn_wantedAdd.sqf | 95 ++--- .../MySQL/WantedSystem/fn_wantedBounty.sqf | 29 +- .../MySQL/WantedSystem/fn_wantedCrimes.sqf | 76 +--- life_hc/MySQL/WantedSystem/fn_wantedFetch.sqf | 40 +- .../MySQL/WantedSystem/fn_wantedPerson.sqf | 14 +- .../WantedSystem/fn_wantedProfUpdate.sqf | 19 +- .../MySQL/WantedSystem/fn_wantedRemove.sqf | 11 +- life_hc/config.cpp | 6 +- life_hc/initHC.sqf | 10 +- life_server/FSM/cleanup.fsm | 4 +- life_server/Functions/Gangs/fn_insertGang.sqf | 61 +-- .../Functions/Gangs/fn_queryPlayerGang.sqf | 14 +- life_server/Functions/Gangs/fn_removeGang.sqf | 17 +- life_server/Functions/Gangs/fn_updateGang.sqf | 72 +--- .../Functions/Housing/fn_addContainer.sqf | 27 +- life_server/Functions/Housing/fn_addHouse.sqf | 19 +- .../Housing/fn_deleteDBContainer.sqf | 27 +- .../Housing/fn_fetchPlayerHouses.sqf | 28 +- .../Functions/Housing/fn_houseCleanup.sqf | 16 +- .../Functions/Housing/fn_houseGarage.sqf | 17 +- .../Functions/Housing/fn_initHouses.sqf | 29 +- .../Functions/Housing/fn_sellHouse.sqf | 33 +- .../Housing/fn_sellHouseContainer.sqf | 25 +- .../Housing/fn_updateHouseContainers.sqf | 26 +- .../Functions/Housing/fn_updateHouseTrunk.sqf | 18 +- life_server/Functions/MySQL/fn_asyncCall.sqf | 24 +- life_server/Functions/MySQL/fn_bool.sqf | 26 -- .../Functions/MySQL/fn_insertRequest.sqf | 31 +- .../Functions/MySQL/fn_insertVehicle.sqf | 10 +- life_server/Functions/MySQL/fn_mresArray.sqf | 27 -- life_server/Functions/MySQL/fn_mresString.sqf | 21 -- .../Functions/MySQL/fn_mresToArray.sqf | 26 -- life_server/Functions/MySQL/fn_numberSafe.sqf | 28 -- .../Functions/MySQL/fn_queryRequest.sqf | 177 +++------ .../Functions/MySQL/fn_updatePartial.sqf | 73 ++-- .../Functions/MySQL/fn_updateRequest.sqf | 59 ++- .../Functions/Systems/fn_chopShopSell.sqf | 35 +- life_server/Functions/Systems/fn_cleanup.sqf | 7 +- .../Functions/Systems/fn_getVehicles.sqf | 35 +- .../Functions/Systems/fn_spawnVehicle.sqf | 45 +-- .../Functions/Systems/fn_vehicleCreate.sqf | 24 +- .../Functions/Systems/fn_vehicleDelete.sqf | 20 +- .../Functions/Systems/fn_vehicleStore.sqf | 73 ++-- .../Functions/Systems/fn_vehicleUpdate.sqf | 58 +-- .../Functions/WantedSystem/fn_wantedAdd.sqf | 21 +- .../WantedSystem/fn_wantedBounty.sqf | 7 +- .../WantedSystem/fn_wantedCrimes.sqf | 11 +- .../Functions/WantedSystem/fn_wantedFetch.sqf | 12 +- .../WantedSystem/fn_wantedPerson.sqf | 9 +- .../WantedSystem/fn_wantedProfUpdate.sqf | 14 +- .../WantedSystem/fn_wantedRemove.sqf | 9 +- life_server/config.cpp | 5 - life_server/init.sqf | 12 +- 88 files changed, 1621 insertions(+), 1805 deletions(-) create mode 100755 AL.ini mode change 100644 => 100755 Altis_Life.Altis/core/session/fn_requestReceived.sqf mode change 100644 => 100755 altislife.sql mode change 100644 => 100755 life_hc/FSM/cleanup.fsm mode change 100644 => 100755 life_hc/MySQL/Gangs/fn_insertGang.sqf mode change 100644 => 100755 life_hc/MySQL/Gangs/fn_queryPlayerGang.sqf mode change 100644 => 100755 life_hc/MySQL/Gangs/fn_removeGang.sqf mode change 100644 => 100755 life_hc/MySQL/Gangs/fn_updateGang.sqf delete mode 100644 life_hc/MySQL/General/fn_bool.sqf mode change 100644 => 100755 life_hc/MySQL/General/fn_cleanup.sqf mode change 100644 => 100755 life_hc/MySQL/General/fn_insertRequest.sqf mode change 100644 => 100755 life_hc/MySQL/General/fn_insertVehicle.sqf delete mode 100644 life_hc/MySQL/General/fn_mresArray.sqf delete mode 100644 life_hc/MySQL/General/fn_mresString.sqf delete mode 100644 life_hc/MySQL/General/fn_mresToArray.sqf delete mode 100644 life_hc/MySQL/General/fn_numberSafe.sqf mode change 100644 => 100755 life_hc/MySQL/General/fn_queryRequest.sqf mode change 100644 => 100755 life_hc/MySQL/General/fn_updatePartial.sqf mode change 100644 => 100755 life_hc/MySQL/General/fn_updateRequest.sqf mode change 100644 => 100755 life_hc/MySQL/Housing/fn_addContainer.sqf mode change 100644 => 100755 life_hc/MySQL/Housing/fn_addHouse.sqf mode change 100644 => 100755 life_hc/MySQL/Housing/fn_deleteDBContainer.sqf mode change 100644 => 100755 life_hc/MySQL/Housing/fn_fetchPlayerHouses.sqf mode change 100644 => 100755 life_hc/MySQL/Housing/fn_houseGarage.sqf mode change 100644 => 100755 life_hc/MySQL/Housing/fn_sellHouse.sqf mode change 100644 => 100755 life_hc/MySQL/Housing/fn_sellHouseContainer.sqf mode change 100644 => 100755 life_hc/MySQL/Housing/fn_updateHouseContainers.sqf mode change 100644 => 100755 life_hc/MySQL/Housing/fn_updateHouseTrunk.sqf mode change 100644 => 100755 life_hc/MySQL/Vehicles/fn_chopShopSell.sqf mode change 100644 => 100755 life_hc/MySQL/Vehicles/fn_getVehicles.sqf mode change 100644 => 100755 life_hc/MySQL/Vehicles/fn_spawnVehicle.sqf mode change 100644 => 100755 life_hc/MySQL/Vehicles/fn_vehicleCreate.sqf mode change 100644 => 100755 life_hc/MySQL/Vehicles/fn_vehicleDelete.sqf mode change 100644 => 100755 life_hc/MySQL/Vehicles/fn_vehicleStore.sqf mode change 100644 => 100755 life_hc/MySQL/Vehicles/fn_vehicleUpdate.sqf mode change 100644 => 100755 life_hc/MySQL/WantedSystem/fn_wantedAdd.sqf mode change 100644 => 100755 life_hc/MySQL/WantedSystem/fn_wantedBounty.sqf mode change 100644 => 100755 life_hc/MySQL/WantedSystem/fn_wantedCrimes.sqf mode change 100644 => 100755 life_hc/MySQL/WantedSystem/fn_wantedFetch.sqf mode change 100644 => 100755 life_hc/MySQL/WantedSystem/fn_wantedPerson.sqf mode change 100644 => 100755 life_hc/MySQL/WantedSystem/fn_wantedProfUpdate.sqf mode change 100644 => 100755 life_hc/MySQL/WantedSystem/fn_wantedRemove.sqf mode change 100644 => 100755 life_hc/config.cpp mode change 100644 => 100755 life_server/FSM/cleanup.fsm mode change 100644 => 100755 life_server/Functions/Gangs/fn_insertGang.sqf mode change 100644 => 100755 life_server/Functions/Gangs/fn_queryPlayerGang.sqf mode change 100644 => 100755 life_server/Functions/Gangs/fn_removeGang.sqf mode change 100644 => 100755 life_server/Functions/Gangs/fn_updateGang.sqf mode change 100644 => 100755 life_server/Functions/Housing/fn_addContainer.sqf mode change 100644 => 100755 life_server/Functions/Housing/fn_addHouse.sqf mode change 100644 => 100755 life_server/Functions/Housing/fn_deleteDBContainer.sqf mode change 100644 => 100755 life_server/Functions/Housing/fn_fetchPlayerHouses.sqf mode change 100644 => 100755 life_server/Functions/Housing/fn_houseCleanup.sqf mode change 100644 => 100755 life_server/Functions/Housing/fn_houseGarage.sqf mode change 100644 => 100755 life_server/Functions/Housing/fn_initHouses.sqf mode change 100644 => 100755 life_server/Functions/Housing/fn_sellHouse.sqf mode change 100644 => 100755 life_server/Functions/Housing/fn_sellHouseContainer.sqf mode change 100644 => 100755 life_server/Functions/Housing/fn_updateHouseContainers.sqf mode change 100644 => 100755 life_server/Functions/Housing/fn_updateHouseTrunk.sqf mode change 100644 => 100755 life_server/Functions/MySQL/fn_asyncCall.sqf delete mode 100644 life_server/Functions/MySQL/fn_bool.sqf mode change 100644 => 100755 life_server/Functions/MySQL/fn_insertRequest.sqf mode change 100644 => 100755 life_server/Functions/MySQL/fn_insertVehicle.sqf delete mode 100644 life_server/Functions/MySQL/fn_mresArray.sqf delete mode 100644 life_server/Functions/MySQL/fn_mresString.sqf delete mode 100644 life_server/Functions/MySQL/fn_mresToArray.sqf delete mode 100644 life_server/Functions/MySQL/fn_numberSafe.sqf mode change 100644 => 100755 life_server/Functions/MySQL/fn_queryRequest.sqf mode change 100644 => 100755 life_server/Functions/MySQL/fn_updatePartial.sqf mode change 100644 => 100755 life_server/Functions/MySQL/fn_updateRequest.sqf mode change 100644 => 100755 life_server/Functions/Systems/fn_chopShopSell.sqf mode change 100644 => 100755 life_server/Functions/Systems/fn_cleanup.sqf mode change 100644 => 100755 life_server/Functions/Systems/fn_getVehicles.sqf mode change 100644 => 100755 life_server/Functions/Systems/fn_spawnVehicle.sqf mode change 100644 => 100755 life_server/Functions/Systems/fn_vehicleCreate.sqf mode change 100644 => 100755 life_server/Functions/Systems/fn_vehicleDelete.sqf mode change 100644 => 100755 life_server/Functions/Systems/fn_vehicleStore.sqf mode change 100644 => 100755 life_server/Functions/Systems/fn_vehicleUpdate.sqf mode change 100644 => 100755 life_server/Functions/WantedSystem/fn_wantedAdd.sqf mode change 100644 => 100755 life_server/Functions/WantedSystem/fn_wantedBounty.sqf mode change 100644 => 100755 life_server/Functions/WantedSystem/fn_wantedCrimes.sqf mode change 100644 => 100755 life_server/Functions/WantedSystem/fn_wantedFetch.sqf mode change 100644 => 100755 life_server/Functions/WantedSystem/fn_wantedPerson.sqf mode change 100644 => 100755 life_server/Functions/WantedSystem/fn_wantedProfUpdate.sqf mode change 100644 => 100755 life_server/Functions/WantedSystem/fn_wantedRemove.sqf diff --git a/AL.ini b/AL.ini new file mode 100755 index 000000000..3a1ad728b --- /dev/null +++ b/AL.ini @@ -0,0 +1,356 @@ +[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 + + + +[selectGang] +SQL1_1 = SELECT id FROM gangs WHERE active = '1' AND id = ? +SQL1_INPUTS = 1 + +[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/session/fn_requestReceived.sqf b/Altis_Life.Altis/core/session/fn_requestReceived.sqf old mode 100644 new mode 100755 index 08e7b211d..8a349d3c0 --- a/Altis_Life.Altis/core/session/fn_requestReceived.sqf +++ b/Altis_Life.Altis/core/session/fn_requestReceived.sqf @@ -8,6 +8,7 @@ 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... @@ -32,8 +33,8 @@ if (!isServer && (!isNil "life_adminlevel" || !isNil "life_coplevel" || !isNil " }; //Parse basic player information. -CASH = parseNumber (_this select 2); -BANK = parseNumber (_this select 3); +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)); @@ -42,7 +43,7 @@ if (LIFE_SETTINGS(getNumber,"donor_level") isEqualTo 1) then { }; //Loop through licenses -if (count (_this select 6) > 0) then { +if !((_this select 6) isEqualTo []) then { {missionNamespace setVariable [(_x select 0),(_x select 1)];} forEach (_this select 6); }; @@ -86,7 +87,7 @@ switch (playerSide) do { } forEach life_houses; life_gangData = _this select (_count - 2); - if !(count life_gangData isEqualTo 0) then { + if !(life_gangData isEqualTo []) then { [] spawn life_fnc_initGang; }; [] spawn life_fnc_initHouses; @@ -104,9 +105,9 @@ switch (playerSide) do { }; life_gear = _this select 8; -call life_fnc_loadGear; +[true] call life_fnc_loadGear; -if (count (_this select (_count - 1)) > 0) then { +if !((_this select (_count - 1)) isEqualTo []) then { {life_vehicles pushBack _x;} forEach (_this select (_count - 1)); }; diff --git a/altislife.sql b/altislife.sql old mode 100644 new mode 100755 index 1bcb7b96b..578b8d7ed --- a/altislife.sql +++ b/altislife.sql @@ -73,38 +73,37 @@ DELIMITER ; -- 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; + `uid` int(6) NOT NULL AUTO_INCREMENT, + `name` varchar(32) NOT NULL, + `aliases` text NOT NULL, + `pid` varchar(17) NOT NULL, + `cash` int(100) NOT NULL DEFAULT '0', + `bankacc` int(100) 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(32) NOT NULL DEFAULT '[100,100,0]', + `cop_stats` varchar(32) NOT NULL DEFAULT '[100,100,0]', + `med_stats` varchar(32) NOT NULL DEFAULT '[100,100,0]', + `arrested` tinyint(1) 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(1) NOT NULL DEFAULT '0', + `civ_alive` tinyint(1) NOT NULL DEFAULT '0', + `civ_position` varchar(64) 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 (`uid`), + UNIQUE KEY `pid` (`pid`), + KEY `name` (`name`), + KEY `blacklist` (`blacklist`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=12 ; -- -------------------------------------------------------- @@ -113,30 +112,26 @@ CREATE TABLE IF NOT EXISTS `players` ( -- 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; + `id` int(6) NOT NULL AUTO_INCREMENT, + `side` varchar(16) NOT NULL, + `classname` varchar(64) NOT NULL, + `type` varchar(16) NOT NULL, + `pid` varchar(17) NOT NULL, + `alive` tinyint(1) NOT NULL DEFAULT '1', + `blacklist` tinyint(1) NOT NULL DEFAULT '0', + `active` tinyint(1) NOT NULL DEFAULT '0', + `plate` int(20) NOT NULL, + `color` int(20) 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`), + KEY `side` (`side`), + KEY `pid` (`pid`), + KEY `type` (`type`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=2 ; -- -------------------------------------------------------- @@ -146,19 +141,14 @@ CREATE TABLE IF NOT EXISTS `vehicles` ( -- 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; + `id` int(6) NOT NULL AUTO_INCREMENT, + `pid` varchar(17) NOT NULL, + `pos` varchar(64) DEFAULT NULL, + `owned` tinyint(1) DEFAULT '0', + `garage` tinyint(1) NOT NULL DEFAULT '0', + `insert_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`,`pid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=4 ; -- -------------------------------------------------------- @@ -168,21 +158,16 @@ CREATE TABLE IF NOT EXISTS `houses` ( -- 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 + `id` int(6) NOT NULL AUTO_INCREMENT, + `owner` varchar(32) DEFAULT NULL, + `name` varchar(32) DEFAULT NULL, + `members` text, + `maxmembers` int(3) DEFAULT '8', + `bank` int(100) DEFAULT '0', + `active` tinyint(1) DEFAULT '1', + `insert_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + UNIQUE KEY `name_UNIQUE` (`name`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -------------------------------------------------------- @@ -193,23 +178,18 @@ CREATE TABLE IF NOT EXISTS `gangs` ( -- 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; + `id` int(6) NOT NULL AUTO_INCREMENT, + `pid` varchar(17) NOT NULL, + `classname` varchar(32) NOT NULL, + `pos` varchar(64) DEFAULT NULL, + `inventory` text NOT NULL, + `gear` text NOT NULL, + `dir` varchar(128) DEFAULT NULL, + `active` tinyint(1) NOT NULL DEFAULT '0', + `owned` tinyint(1) DEFAULT '0', + `insert_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`,`pid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=4; -- -------------------------------------------------------- @@ -219,17 +199,13 @@ CREATE TABLE IF NOT EXISTS `containers` ( -- 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 + `wantedID` varchar(64) NOT NULL, + `wantedName` varchar(32) NOT NULL, + `wantedCrimes` text NOT NULL, + `wantedBounty` int(100) NOT NULL, + `active` tinyint(1) NOT NULL DEFAULT '0', + `insert_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`wantedID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -------------------------------------------------------- diff --git a/life_hc/FSM/cleanup.fsm b/life_hc/FSM/cleanup.fsm old mode 100644 new mode 100755 index 9bcecd41d..04fea7c81 --- a/life_hc/FSM/cleanup.fsm +++ b/life_hc/FSM/cleanup.fsm @@ -81,7 +81,7 @@ class FSM " _uid = _dbInfo select 0;" \n " _plate = _dbInfo select 1;" \n "" \n - " _query = format [""UPDATE vehicles SET alive='0' WHERE pid='%1' AND plate='%2'"",_uid,_plate];" \n + " _query = format [""deleteVehicle:%1:%2"", _uid, _plate];" \n " _query spawn {" \n " " \n " _thread = [_this,1] call HC_fnc_asyncCall;" \n @@ -100,7 +100,7 @@ class FSM " _uid = _dbInfo select 0;" \n " _plate = _dbInfo select 1;" \n "" \n - " _query = format [""UPDATE vehicles SET alive='0' WHERE pid='%1' AND plate='%2'"",_uid,_plate];" \n + " _query = format [""deleteVehicle:%1:%2"", _uid, _plate];" \n " _query spawn {" \n " " \n " _thread = [_this,1] call HC_fnc_asyncCall;" \n diff --git a/life_hc/MySQL/Gangs/fn_insertGang.sqf b/life_hc/MySQL/Gangs/fn_insertGang.sqf old mode 100644 new mode 100755 index 951187662..bc4f48424 --- a/life_hc/MySQL/Gangs/fn_insertGang.sqf +++ b/life_hc/MySQL/Gangs/fn_insertGang.sqf @@ -8,31 +8,32 @@ Description: Inserts the gang into the database. */ -private ["_query","_queryResult","_gangMembers","_group"]; + params [ - ["_ownerID",objNull,[objNull]], - ["_uid","",[""]], - ["_gangName","",[""]] + ["_ownerID", objNull, [objNull]], + ["_uid", "", [""]], + ["_gangName", "", [""]] ]; -_group = group _ownerID; -if (isNull _ownerID || _uid isEqualTo "" || _gangName isEqualTo "") exitWith {}; //Fail +private _group = group _ownerID; + +if (isNull _ownerID || {_uid isEqualTo ""} || {_gangName isEqualTo ""}) exitWith {}; -_gangName = [_gangName] call HC_fnc_mresString; -_query = format ["SELECT id FROM gangs WHERE name='%1' AND active='1'",_gangName]; +private _query = format ["selectGangID:%1", _gangName]; -_queryResult = [_query,2] call HC_fnc_asyncCall; +private _queryResult = [_query, 2] call HC_fnc_asyncCall; //Check to see if the gang name already exists. -if (!(count _queryResult isEqualTo 0)) exitWith { - [1,"There is already a gang created with that name please pick another name."] remoteExecCall ["life_fnc_broadcast",_ownerID]; +if !(_queryResult isEqualTo []) exitWith { + [1, "There is already a gang created with that name please pick another name."] remoteExecCall ["life_fnc_broadcast",_ownerID]; life_action_gangInUse = nil; _ownerID publicVariableClient "life_action_gangInUse"; }; -_query = format ["SELECT id FROM gangs WHERE members LIKE '%2%1%2' AND active='1'",_uid,"%"]; +private _uidLike = format["%2%1%2", _uid, "%"]; +_query = format ["selectGangIDFromMembers:%1", _uidLike]; -_queryResult = [_query,2] call HC_fnc_asyncCall; +_queryResult = [_query, 2] call HC_fnc_asyncCall; //Check to see if this person already owns or belongs to a gang. if (!(count _queryResult isEqualTo 0)) exitWith { @@ -42,29 +43,29 @@ if (!(count _queryResult isEqualTo 0)) exitWith { }; //Check to see if a gang with that name already exists but is inactive. -_query = format ["SELECT id, active FROM gangs WHERE name='%1' AND active='0'",_gangName]; +_query = format ["selectInactiveGang:%1", _gangName]; -_queryResult = [_query,2] call HC_fnc_asyncCall; -_gangMembers = [[_uid]] call HC_fnc_mresArray; +_queryResult = [_query, 2] call HC_fnc_asyncCall; +private _gangMembers = [_uid]; -if (!(count _queryResult isEqualTo 0)) then { - _query = format ["UPDATE gangs SET active='1', owner='%1',members='%2' WHERE id='%3'",_uid,_gangMembers,(_queryResult select 0)]; +if !(_queryResult isEqualTo []) then { + _query = format ["updateGang:%1:%2:%3", (_queryResult select 0), _gangMembers, _uid]; } else { - _query = format ["INSERT INTO gangs (owner, name, members) VALUES('%1','%2','%3')",_uid,_gangName,_gangMembers]; + _query = format ["insertGang:%1:%2:%3", _uid, _gangName, _gangMembers]; }; -_queryResult = [_query,1] call HC_fnc_asyncCall; +_queryResult = [_query, 1] call HC_fnc_asyncCall; -_group setVariable ["gang_name",_gangName,true]; -_group setVariable ["gang_owner",_uid,true]; -_group setVariable ["gang_bank",0,true]; -_group setVariable ["gang_maxMembers",8,true]; -_group setVariable ["gang_members",[_uid],true]; -[_group] remoteExecCall ["life_fnc_gangCreated",_ownerID]; +_group setVariable ["gang_name", _gangName, true]; +_group setVariable ["gang_owner", _uid, true]; +_group setVariable ["gang_bank", 0, true]; +_group setVariable ["gang_maxMembers", 8, true]; +_group setVariable ["gang_members", [_uid], true]; +[_group] remoteExecCall ["life_fnc_gangCreated", _ownerID]; -sleep 0.35; -_query = format ["SELECT id FROM gangs WHERE owner='%1' AND active='1'",_uid]; +uiSleep 0.35; +_query = format ["selectGangIDFromOwner:%1", _uid]; -_queryResult = [_query,2] call HC_fnc_asyncCall; +_queryResult = [_query, 2] call HC_fnc_asyncCall; -_group setVariable ["gang_id",(_queryResult select 0),true]; +_group setVariable ["gang_id", (_queryResult select 0), true]; diff --git a/life_hc/MySQL/Gangs/fn_queryPlayerGang.sqf b/life_hc/MySQL/Gangs/fn_queryPlayerGang.sqf old mode 100644 new mode 100755 index e4492417f..ee9f00f82 --- a/life_hc/MySQL/Gangs/fn_queryPlayerGang.sqf +++ b/life_hc/MySQL/Gangs/fn_queryPlayerGang.sqf @@ -7,15 +7,9 @@ Description: Queries to see if the player belongs to any gang. */ -private ["_query","_queryResult"]; -_query = format ["SELECT id, owner, name, maxmembers, bank, members FROM gangs WHERE active='1' AND members LIKE '%2%1%2'",_this,"%"]; +private _pid = format ["%2%1%2", _this, "%"]; +private _query = format ["selectPlayerGang:%1", _pid]; +private _queryResult = [_query,2] call HC_fnc_asyncCall; -_queryResult = [_query,2] call HC_fnc_asyncCall; - -if !(count _queryResult isEqualTo 0) then { - _tmp = [_queryResult select 5] call HC_fnc_mresToArray; - if (_tmp isEqualType "") then {_tmp = call compile format ["%1",_tmp];}; - _queryResult set[5, _tmp]; -}; -missionNamespace setVariable [format ["gang_%1",_this],_queryResult]; +missionNamespace setVariable [format ["gang_%1", _this], _queryResult]; diff --git a/life_hc/MySQL/Gangs/fn_removeGang.sqf b/life_hc/MySQL/Gangs/fn_removeGang.sqf old mode 100644 new mode 100755 index 537e22808..213516045 --- a/life_hc/MySQL/Gangs/fn_removeGang.sqf +++ b/life_hc/MySQL/Gangs/fn_removeGang.sqf @@ -8,19 +8,22 @@ Description: Blah */ -private ["_group","_groupID"]; -_group = param [0,grpNull,[grpNull]]; + +params [ + ["_group", grpNull, [grpNull]] +]; + if (isNull _group) exitWith {}; -_groupID = _group getVariable ["gang_id",-1]; +private _groupID = _group getVariable ["gang_id",-1]; if (_groupID isEqualTo -1) exitWith {}; -[format ["UPDATE gangs SET active='0' WHERE id='%1'",_groupID],1] call HC_fnc_asyncCall; +[format ["deleteGang:%1", _groupID], 1] call HC_fnc_asyncCall; -_result = [format ["SELECT id FROM gangs WHERE active='1' AND id='%1'",_groupID],2] call HC_fnc_asyncCall; -if (count _result isEqualTo 0) then { +_result = [format ["selectGang:%1", _groupID], 2] call HC_fnc_asyncCall; +if (_result isEqualTo []) then { [_group] remoteExecCall ["life_fnc_gangDisbanded",(units _group)]; sleep 5; deleteGroup _group; }; -["CALL deleteOldGangs",1] call DB_fnc_asyncCall; +["deleteOldGangs", 1] call HC_fnc_asyncCall; diff --git a/life_hc/MySQL/Gangs/fn_updateGang.sqf b/life_hc/MySQL/Gangs/fn_updateGang.sqf old mode 100644 new mode 100755 index eef95d891..460435aec --- a/life_hc/MySQL/Gangs/fn_updateGang.sqf +++ b/life_hc/MySQL/Gangs/fn_updateGang.sqf @@ -1,4 +1,3 @@ -#include "\life_hc\hc_macros.hpp" /* File: fn_updateGang.sqf Author: Bryan "Tonic" Boardwine @@ -8,78 +7,48 @@ Description: Updates the gang information? */ -private ["_groupID","_bank","_maxMembers","_members","_membersFinal","_query","_owner"]; + params [ - ["_mode",0,[0]], - ["_group",grpNull,[grpNull]] + ["_mode", 0, [0]], + ["_group", grpNull, [grpNull]] ]; if (isNull _group) exitWith {}; //FAIL -_groupID = _group getVariable ["gang_id",-1]; +private _groupID = _group getVariable ["gang_id", -1]; if (_groupID isEqualTo -1) exitWith {}; +private "_query"; + switch (_mode) do { case 0: { - _bank = [(_group getVariable ["gang_bank",0])] call HC_fnc_numberSafe; - _maxMembers = _group getVariable ["gang_maxMembers",8]; - _members = [(_group getVariable "gang_members")] call HC_fnc_mresArray; - _owner = _group getVariable ["gang_owner",""]; + private _bank = _group getVariable ["gang_bank", 0]; + private _maxMembers = _group getVariable ["gang_maxMembers", 8]; + private _members = _group getVariable "gang_members"; + private _owner = _group getVariable ["gang_owner", ""]; if (_owner isEqualTo "") exitWith {}; - _query = format ["UPDATE gangs SET bank='%1', maxmembers='%2', owner='%3' WHERE id='%4'",_bank,_maxMembers,_owner,_groupID]; + _query = format ["updateGang1:%1:%2:%3:%4", _bank, _maxMembers, _owner, _groupID]; }; case 1: { - params [ - "", - "", - ["_deposit",false,[false]], - ["_value",0,[0]], - ["_unit",objNull,[objNull]], - ["_cash",0,[0]] - ]; - - private _funds = _group getVariable ["gang_bank",0]; - if (_deposit) then { - _funds = _funds + _value; - _group setVariable ["gang_bank",_funds,true]; - [1,"STR_ATM_DepositSuccessG",true,[_value]] remoteExecCall ["life_fnc_broadcast",remoteExecutedOwner]; - _cash = _cash - _value; - } else { - if (_value > _funds) exitWith { - [1,"STR_ATM_NotEnoughFundsG",true] remoteExecCall ["life_fnc_broadcast",remoteExecutedOwner]; - breakOut ""; - }; - _funds = _funds - _value; - _group setVariable ["gang_bank",_funds,true]; - [_value] remoteExecCall ["life_fnc_gangBankResponse",remoteExecutedOwner]; - _cash = _cash + _value; - }; - if (LIFE_SETTINGS(getNumber,"player_moneyLog") isEqualTo 1) then { - if (LIFE_SETTINGS(getNumber,"battlEye_friendlyLogging") isEqualTo 1) then { - diag_log (format [localize "STR_DL_ML_withdrewGang_BEF",_value,[_funds] call life_fnc_numberText,[0] call life_fnc_numberText,[_cash] call life_fnc_numberText]); - } else { - diag_log (format [localize "STR_DL_ML_withdrewGang",name _unit,(getPlayerUID _unit),_value,[_funds] call life_fnc_numberText,[0] call life_fnc_numberText,[_cash] call life_fnc_numberText]); - }; - }; - _query = format ["UPDATE gangs SET bank='%1' WHERE id='%2'",([_funds] call HC_fnc_numberSafe),_groupID]; - [getPlayerUID _unit,side _unit,_cash,0] call HC_fnc_updatePartial; + _query = format ["updateGangBank:%1:%2", _group getVariable ["gang_bank", 0], _groupID]; }; case 2: { - _query = format ["UPDATE gangs SET maxmembers='%1' WHERE id='%2'",(_group getVariable ["gang_maxMembers",8]),_groupID]; + _query = format ["updateGangMaxmembers:%1:%2", (_group getVariable ["gang_maxMembers", 8]), _groupID]; }; case 3: { - _owner = _group getVariable ["gang_owner",""]; + private _owner = _group getVariable ["gang_owner", ""]; if (_owner isEqualTo "") exitWith {}; - _query = format ["UPDATE gangs SET owner='%1' WHERE id='%2'",_owner,_groupID]; + _query = format ["updateGangOwner:%1:%2", _owner, _groupID]; }; case 4: { - _members = _group getVariable "gang_members"; - if (count _members > (_group getVariable ["gang_maxMembers",8])) then { + private _members = _group getVariable "gang_members"; + private "_membersFinal"; + if (count _members > (_group getVariable ["gang_maxMembers", 8])) then { _membersFinal = []; for "_i" from 0 to _maxMembers -1 do { _membersFinal pushBack (_members select _i); @@ -87,11 +56,10 @@ switch (_mode) do { } else { _membersFinal = _group getVariable "gang_members"; }; - _membersFinal = [_membersFinal] call HC_fnc_mresArray; - _query = format ["UPDATE gangs SET members='%1' WHERE id='%2'",_membersFinal,_groupID]; + _query = format ["updateGangMembers:%1:%2", _membersFinal, _groupID]; }; }; if (!isNil "_query") then { - [_query,1] call HC_fnc_asyncCall; + [_query, 1] call HC_fnc_asyncCall; }; diff --git a/life_hc/MySQL/General/fn_bool.sqf b/life_hc/MySQL/General/fn_bool.sqf deleted file mode 100644 index 2d9a70f23..000000000 --- a/life_hc/MySQL/General/fn_bool.sqf +++ /dev/null @@ -1,26 +0,0 @@ -/* - File: fn_bool.sqf - Author: TAW_Tonic - - Description: - Handles bool conversion for MySQL since MySQL doesn't support 'true' or 'false' - instead MySQL uses Tinyint for BOOLEAN (0 = false, 1 = true) -*/ -private ["_bool","_mode"]; -_bool = [_this,0,0,[false,0]] call BIS_fnc_param; -_mode = [_this,1,0,[0]] call BIS_fnc_param; - -switch (_mode) do { - case 0: { - if (_bool isEqualType 0) exitWith {0}; - if (_bool) then {1} else {0}; - }; - - case 1: { - if (!(_bool isEqualType 0)) exitWith {false}; - switch (_bool) do { - case 0: {false}; - case 1: {true}; - }; - }; -}; diff --git a/life_hc/MySQL/General/fn_cleanup.sqf b/life_hc/MySQL/General/fn_cleanup.sqf old mode 100644 new mode 100755 index 6afd87668..fb3735c71 --- a/life_hc/MySQL/General/fn_cleanup.sqf +++ b/life_hc/MySQL/General/fn_cleanup.sqf @@ -47,7 +47,7 @@ for "_i" from 0 to 1 step 0 do { _uid = _dbInfo select 0; _plate = _dbInfo select 1; - _query = format ["UPDATE vehicles SET active='0', fuel='%3' WHERE pid='%1' AND plate='%2'",_uid,_plate,_fuel]; + _query = format ["cleanupVehicle:%1:%2:%3", _fuel, _uid, _plate]; [_query,1] call HC_fnc_asyncCall; }; diff --git a/life_hc/MySQL/General/fn_insertRequest.sqf b/life_hc/MySQL/General/fn_insertRequest.sqf old mode 100644 new mode 100755 index 73d9422b7..0869f5a00 --- a/life_hc/MySQL/General/fn_insertRequest.sqf +++ b/life_hc/MySQL/General/fn_insertRequest.sqf @@ -6,10 +6,10 @@ This file is for Nanou's HeadlessClient. Description: - Does something with inserting... Don't have time for - descriptions... Need to write it... + Adds a player to the database upon first joining of the server. + Recieves information from core\sesison\fn_insertPlayerInfo.sqf */ -private ["_queryResult","_query","_alias"]; + params [ "_uid", "_name", @@ -19,26 +19,21 @@ params [ ]; //Error checks -if ((_uid isEqualTo "") || (_name isEqualTo "")) exitWith {}; -if (isNull _returnToSender) exitWith {}; - -_query = format ["SELECT pid, name FROM players WHERE pid='%1'",_uid]; +if (_uid isEqualTo "" || {_name isEqualTo ""}) exitWith {systemChat "Bad UID or name";}; //Let the client be 'lost' in 'transaction' +if (isNull _returnToSender) exitWith {systemChat "ReturnToSender is Null!";}; //No one to send this to! -_tickTime = diag_tickTime; -_queryResult = [_query,2] call HC_fnc_asyncCall; +private _query = format ["checkPlayerExists:%1", _uid]; +private _queryResult = [_query, 2] call HC_fnc_asyncCall; //Double check to make sure the client isn't in the database... -if (_queryResult isEqualType "") exitWith {[] remoteExecCall ["SOCK_fnc_dataQuery",_returnToSender];}; //There was an entry! -if !(count _queryResult isEqualTo 0) exitWith {[] remoteExecCall ["SOCK_fnc_dataQuery",_returnToSender];}; +if (_queryResult isEqualType "" || {!(_queryResult isEqualTo [])}) exitWith { + [] remoteExecCall ["SOCK_fnc_dataQuery", _returnToSender]; +}; -//Clense and prepare some information. -_name = [_name] call HC_fnc_mresString; //Clense the name of bad chars. -_alias = [[_name]] call HC_fnc_mresArray; -_money = [_money] call HC_fnc_numberSafe; -_bank = [_bank] call HC_fnc_numberSafe; +private _alias = [_name]; //Prepare the query statement.. -_query = format ["INSERT INTO players (pid, name, cash, bankacc, aliases, cop_licenses, med_licenses, civ_licenses, civ_gear, cop_gear, med_gear) VALUES('%1', '%2', '%3', '%4', '%5','""[]""','""[]""','""[]""','""[]""','""[]""','""[]""')", +_query = format ["insertNewPlayer:%1:%2:%3:%4:%5", _uid, _name, _money, @@ -46,5 +41,5 @@ _query = format ["INSERT INTO players (pid, name, cash, bankacc, aliases, cop_li _alias ]; -[_query,1] call HC_fnc_asyncCall; -[] remoteExecCall ["SOCK_fnc_dataQuery",_returnToSender]; +[_query, 1] call HC_fnc_asyncCall; +[] remoteExecCall ["SOCK_fnc_dataQuery", _returnToSender]; diff --git a/life_hc/MySQL/General/fn_insertVehicle.sqf b/life_hc/MySQL/General/fn_insertVehicle.sqf old mode 100644 new mode 100755 index 8706d734a..0a049b5fa --- a/life_hc/MySQL/General/fn_insertVehicle.sqf +++ b/life_hc/MySQL/General/fn_insertVehicle.sqf @@ -7,7 +7,7 @@ Description: Inserts the vehicle into the database */ -private ["_query","_sql"]; + params [ "_uid", "_side", @@ -18,8 +18,7 @@ params [ ]; //Stop bad data being passed. -if (_uid isEqualTo "" || _side isEqualTo "" || _type isEqualTo "" || _className isEqualTo "" || _color isEqualTo -1 || _plate isEqualTo -1) exitWith {}; - -_query = format ["INSERT INTO vehicles (side, classname, type, pid, alive, active, inventory, color, plate, gear, damage) VALUES ('%1', '%2', '%3', '%4', '1','1','""[[],0]""', '%5', '%6','""[]""','""[]""')",_side,_className,_type,_uid,_color,_plate]; +if (_uid isEqualTo "" || {_side isEqualTo ""} || {_type isEqualTo ""} || {_className isEqualTo ""} || {_color isEqualTo -1} || {_plate isEqualTo -1}) exitWith {}; -[_query,1] call HC_fnc_asyncCall; +private _query = format ["insertVehicle:%1:%2:%3:%4:%5:%6", _side, _className, _type, _uid, _color, _plate]; +[_query, 1] call HC_fnc_asyncCall; diff --git a/life_hc/MySQL/General/fn_mresArray.sqf b/life_hc/MySQL/General/fn_mresArray.sqf deleted file mode 100644 index d8433f26a..000000000 --- a/life_hc/MySQL/General/fn_mresArray.sqf +++ /dev/null @@ -1,27 +0,0 @@ -/* - File: fn_mresArray.sqf - Author: Bryan "Tonic" Boardwine"; - - Description: - Acts as a mres (MySQL Real Escape) for arrays so they - can be properly inserted into the database without causing - any problems. The return method is 'hacky' but it's effective. -*/ -private ["_array"]; -_array = [_this,0,[],[[]]] call BIS_fnc_param; -_array = str _array; -_array = toArray(_array); - -for "_i" from 0 to (count _array)-1 do -{ - _sel = _array select _i; - if (!(_i isEqualTo 0) && !(_i isEqualTo ((count _array)-1))) then - { - if (_sel isEqualTo 34) then - { - _array set[_i,96]; - }; - }; -}; - -str(toString(_array)); diff --git a/life_hc/MySQL/General/fn_mresString.sqf b/life_hc/MySQL/General/fn_mresString.sqf deleted file mode 100644 index 584a8e7bd..000000000 --- a/life_hc/MySQL/General/fn_mresString.sqf +++ /dev/null @@ -1,21 +0,0 @@ -/* - File: fn_mresString.sqf - Author: Bryan "Tonic" Boardwine - - Description: - Makes the string safe to be passed to MySQL (strips various stuff). -*/ -private ["_string","_filter"]; -_string = [_this,0,"",[""]] call BIS_fnc_param; -_filter = "'/\`:|;,{}-""<>"; - -_string = toArray _string; //Blow it up to an array -_filter = toArray _filter; //Blow it up to an array - -{ - if (_x in _filter) then { - _string deleteAt _forEachIndex; - }; -} forEach _string; - -toString _string; diff --git a/life_hc/MySQL/General/fn_mresToArray.sqf b/life_hc/MySQL/General/fn_mresToArray.sqf deleted file mode 100644 index e93e75d67..000000000 --- a/life_hc/MySQL/General/fn_mresToArray.sqf +++ /dev/null @@ -1,26 +0,0 @@ -/* - File: fn_mresToArray.sqf - Author: Bryan "Tonic" Boardwine"; - - Description: - Acts as a mres (MySQL Real Escape) for arrays so they - can be properly inserted into the database without causing - any problems. The return method is 'hacky' but it's effective. -*/ -private ["_array"]; -_array = [_this,0,"",[""]] call BIS_fnc_param; -if (_array isEqualTo "") exitWith {[]}; -_array = toArray(_array); - -for "_i" from 0 to (count _array)-1 do -{ - _sel = _array select _i; - if (_sel == 96) then - { - _array set[_i,39]; - }; -}; - -_array = toString(_array); -_array = call compile format ["%1", _array]; -_array; \ No newline at end of file diff --git a/life_hc/MySQL/General/fn_numberSafe.sqf b/life_hc/MySQL/General/fn_numberSafe.sqf deleted file mode 100644 index 0fc534d88..000000000 --- a/life_hc/MySQL/General/fn_numberSafe.sqf +++ /dev/null @@ -1,28 +0,0 @@ -/* - File: fn_numberSafe.sqf - Author: Karel Moricky - - Description: - Convert a number into string (avoiding scientific notation) - - Parameter(s): - _this: NUMBER - - Returns: - STRING -*/ -private ["_number","_mod","_digots","_digitsCount","_modBase","_numberText"]; - -_number = [_this,0,0,[0]] call bis_fnc_param; -_mod = [_this,1,3,[0]] call bis_fnc_param; - -_digits = _number call bis_fnc_numberDigits; -_digitsCount = count _digits - 1; - -_modBase = _digitsCount % _mod; -_numberText = ""; -{ - _numberText = _numberText + str _x; - if ((_foreachindex - _modBase) % (_mod) isEqualTo 0 && !(_foreachindex isEqualTo _digitsCount)) then {_numberText = _numberText + "";}; -} forEach _digits; -_numberText diff --git a/life_hc/MySQL/General/fn_queryRequest.sqf b/life_hc/MySQL/General/fn_queryRequest.sqf old mode 100644 new mode 100755 index 1ce62f7b5..b70224edd --- a/life_hc/MySQL/General/fn_queryRequest.sqf +++ b/life_hc/MySQL/General/fn_queryRequest.sqf @@ -2,7 +2,7 @@ /* File: fn_queryRequest.sqf Author: Bryan "Tonic" Boardwine - + This file is for Nanou's HeadlessClient. Description: @@ -13,149 +13,90 @@ 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. */ -private ["_uid","_side","_query","_queryResult","_tickTime","_tmp"]; -_uid = [_this,0,"",[""]] call BIS_fnc_param; -_side = [_this,1,sideUnknown,[civilian]] call BIS_fnc_param; -_ownerID = [_this,2,objNull,[objNull]] call BIS_fnc_param; -if (isNull _ownerID) exitWith {}; +params [ + ["_uid", "", [""]], + ["_side", sideUnknown, [civilian]], + ["_ownerID", objNull, [objNull]] +]; -if (LIFE_SETTINGS(getNumber,"player_deathLog") isEqualTo 1) then { - _ownerID addMPEventHandler ["MPKilled", {_this call fn_whoDoneIt}]; -}; +if (isNull _ownerID) exitWith {}; -_query = switch (_side) do { +private _query = switch (_side) do { // West - 11 entries returned - case west: {format ["SELECT pid, name, cash, bankacc, adminlevel, donorlevel, cop_licenses, coplevel, cop_gear, blacklist, cop_stats, playtime FROM players WHERE pid='%1'",_uid];}; + case west: {format ["selectWest:%1", _uid];}; // Civilian - 12 entries returned - case civilian: {format ["SELECT pid, name, cash, bankacc, adminlevel, donorlevel, civ_licenses, arrested, civ_gear, civ_stats, civ_alive, civ_position, playtime FROM players WHERE pid='%1'",_uid];}; + case civilian: {format ["selectCiv:%1", _uid];}; // Independent - 10 entries returned - case independent: {format ["SELECT pid, name, cash, bankacc, adminlevel, donorlevel, med_licenses, mediclevel, med_gear, med_stats, playtime FROM players WHERE pid='%1'",_uid];}; + case independent: {format ["selectIndep:%1",_uid];}; }; +private _tickTime = diag_tickTime; +private _queryResult = [_query,2] call DB_fnc_asyncCall; -_tickTime = diag_tickTime; -_queryResult = [_query,2] call HC_fnc_asyncCall; - -if (_queryResult isEqualType "") exitWith { - [] remoteExecCall ["SOCK_fnc_insertPlayerInfo",_ownerID]; +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 isEqualTo []) exitWith { +if (_queryResult isEqualType "" || _queryResult isEqualTo []) exitWith { [] remoteExecCall ["SOCK_fnc_insertPlayerInfo",_ownerID]; }; -//Blah conversion thing from a2net->extdb -_tmp = _queryResult select 2; -_queryResult set[2,[_tmp] call HC_fnc_numberSafe]; -_tmp = _queryResult select 3; -_queryResult set[3,[_tmp] call HC_fnc_numberSafe]; - -//Parse licenses (Always index 6) -_new = [(_queryResult select 6)] call HC_fnc_mresToArray; -if (_new isEqualType "") then {_new = call compile format ["%1", _new];}; -_queryResult set[6,_new]; - -//Convert tinyint to boolean -_old = _queryResult select 6; -for "_i" from 0 to (count _old)-1 do { - _data = _old select _i; - _old set[_i,[_data select 0, ([_data select 1,1] call HC_fnc_bool)]]; +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]]; }; -_queryResult set[6,_old]; +private "_playTimes"; -_new = [(_queryResult select 8)] call HC_fnc_mresToArray; -if (_new isEqualType "") then {_new = call compile format ["%1", _new];}; -_queryResult set[8,_new]; -//Parse data for specific side. switch (_side) do { - case west: { - _queryResult set[9,([_queryResult select 9,1] call HC_fnc_bool)]; - - //Parse Stats - _new = [(_queryResult select 10)] call HC_fnc_mresToArray; - if (_new isEqualType "") then {_new = call compile format ["%1", _new];}; - _queryResult set[10,_new]; - - //Playtime - _new = [(_queryResult select 11)] call HC_fnc_mresToArray; - if (_new isEqualType "") then {_new = call compile format ["%1", _new];}; - _index = TON_fnc_playtime_values_request find [_uid, _new]; - 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, _new]; - } else { - TON_fnc_playtime_values_request pushBack [_uid, _new]; - }; - _new = _new select 0; - [_uid, _new] call HC_fnc_setPlayTime; - }; - - case civilian: { - _queryResult set[7,([_queryResult select 7,1] call HC_fnc_bool)]; - - //Parse Stats - _new = [(_queryResult select 9)] call HC_fnc_mresToArray; - if (_new isEqualType "") then {_new = call compile format ["%1", _new];}; - _queryResult set[9,_new]; - - //Position - _queryResult set[10,([_queryResult select 10,1] call HC_fnc_bool)]; - _new = [(_queryResult select 11)] call HC_fnc_mresToArray; - if (_new isEqualType "") then {_new = call compile format ["%1", _new];}; - _queryResult set[11,_new]; - - //Playtime - _new = [(_queryResult select 12)] call HC_fnc_mresToArray; - if (_new isEqualType "") then {_new = call compile format ["%1", _new];}; - _index = TON_fnc_playtime_values_request find [_uid, _new]; - 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, _new]; - } else { - TON_fnc_playtime_values_request pushBack [_uid, _new]; - }; - _new = _new select 2; - [_uid, _new] call HC_fnc_setPlayTime; - - _houseData = _uid spawn HC_fnc_fetchPlayerHouses; - waitUntil {scriptDone _houseData}; - _queryResult pushBack (missionNamespace getVariable [format ["houses_%1",_uid],[]]); - _gangData = _uid spawn HC_fnc_queryPlayerGang; - waitUntil{scriptDone _gangData}; - _queryResult pushBack (missionNamespace getVariable [format ["gang_%1",_uid],[]]); - }; - - case independent: { - //Parse Stats - _new = [(_queryResult select 9)] call HC_fnc_mresToArray; - if (_new isEqualType "") then {_new = call compile format ["%1", _new];}; - _queryResult set[9,_new]; - - //Playtime - _new = [(_queryResult select 10)] call HC_fnc_mresToArray; - if (_new isEqualType "") then {_new = call compile format ["%1", _new];}; - _index = TON_fnc_playtime_values_request find [_uid, _new]; - 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, _new]; - } else { - TON_fnc_playtime_values_request pushBack [_uid, _new]; - }; - _new = _new select 1; - [_uid, _new] call HC_fnc_setPlayTime; - }; + 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]; +[_uid, _side] remoteExecCall ["TON_fnc_recupKeyForHC", RSERV]; waitUntil {life_keyreceived}; _keyArr = life_keyreceivedvar; _queryResult pushBack _keyArr; diff --git a/life_hc/MySQL/General/fn_updatePartial.sqf b/life_hc/MySQL/General/fn_updatePartial.sqf old mode 100644 new mode 100755 index 494c0af4c..498f05af3 --- a/life_hc/MySQL/General/fn_updatePartial.sqf +++ b/life_hc/MySQL/General/fn_updatePartial.sqf @@ -8,81 +8,68 @@ Takes partial data of a player and updates it, this is meant to be less network intensive towards data flowing through it for updates. */ -private ["_uid","_side","_value","_value1","_value2","_mode","_query"]; -_uid = [_this,0,"",[""]] call BIS_fnc_param; -_side = [_this,1,sideUnknown,[civilian]] call BIS_fnc_param; -_mode = [_this,3,-1,[0]] call BIS_fnc_param; -if (_uid isEqualTo "" || _side isEqualTo sideUnknown) exitWith {}; //Bad. -_query = ""; +params [ + ["_uid", "", [""]], + ["_side", sideUnknown, [civilian]], + "_value", + ["_mode", -1, [0]], + "_value1" +]; + +if (_uid isEqualTo "" || {_side isEqualTo sideUnknown}) exitWith {}; //Bad. +private _query = ""; switch (_mode) do { case 0: { - _value = [_this,2,0,[0]] call BIS_fnc_param; - _value = [_value] call HC_fnc_numberSafe; - _query = format ["UPDATE players SET cash='%1' WHERE pid='%2'",_value,_uid]; + _query = format ["updateCash:%1:%2", _value, _uid]; }; case 1: { - _value = [_this,2,0,[0]] call BIS_fnc_param; - _value = [_value] call HC_fnc_numberSafe; - _query = format ["UPDATE players SET bankacc='%1' WHERE pid='%2'",_value,_uid]; + _query = format ["updateBank:%1:%2",_value,_uid]; }; case 2: { - _value = [_this,2,[],[[]]] call BIS_fnc_param; - //Does something license related but I can't remember I only know it's important? - for "_i" from 0 to count(_value)-1 do { - _bool = [(_value select _i) select 1] call HC_fnc_bool; - _value set[_i,[(_value select _i) select 0,_bool]]; - }; - _value = [_value] call HC_fnc_mresArray; + 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 ["UPDATE players SET cop_licenses='%1' WHERE pid='%2'",_value,_uid];}; - case civilian: {_query = format ["UPDATE players SET civ_licenses='%1' WHERE pid='%2'",_value,_uid];}; - case independent: {_query = format ["UPDATE players SET med_licenses='%1' WHERE pid='%2'",_value,_uid];}; + 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: { - _value = [_this,2,[],[[]]] call BIS_fnc_param; - _value = [_value] call HC_fnc_mresArray; switch (_side) do { - case west: {_query = format ["UPDATE players SET cop_gear='%1' WHERE pid='%2'",_value,_uid];}; - case civilian: {_query = format ["UPDATE players SET civ_gear='%1' WHERE pid='%2'",_value,_uid];}; - case independent: {_query = format ["UPDATE players SET med_gear='%1' WHERE pid='%2'",_value,_uid];}; + 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: { - _value = [_this,2,false,[true]] call BIS_fnc_param; - _value = [_value] call HC_fnc_bool; - _value2 = [_this,4,[],[[]]] call BIS_fnc_param; - _value2 = if (count _value2 isEqualTo 3) then {_value2} else {[0,0,0]}; - _value2 = [_value2] call HC_fnc_mresArray; - _query = format ["UPDATE players SET civ_alive='%1', civ_position='%2' WHERE pid='%3'",_value,_value2,_uid]; + _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]; }; case 5: { - _value = [_this,2,false,[true]] call BIS_fnc_param; - _value = [_value] call HC_fnc_bool; - _query = format ["UPDATE players SET arrested='%1' WHERE pid='%2'",_value,_uid]; + _value = [0, 1] select _value; + _query = format ["updateArrested:%1:%2",_value,_uid]; }; case 6: { - _value1 = [_this,2,0,[0]] call BIS_fnc_param; - _value2 = [_this,4,0,[0]] call BIS_fnc_param; - _value1 = [_value1] call HC_fnc_numberSafe; - _value2 = [_value2] call HC_fnc_numberSafe; - _query = format ["UPDATE players SET cash='%1', bankacc='%2' WHERE pid='%3'",_value1,_value2,_uid]; + _query = format ["updateCashAndBank:%1:%2:%3", _value, _value1, _uid]; }; case 7: { - _array = [_this,2,[],[[]]] call BIS_fnc_param; - [_uid,_side,_array,0] remoteExecCall ["TON_fnc_keyManagement",RSERV]; + [_uid, _side, _value, 0] call TON_fnc_keyManagement; }; }; if (_query isEqualTo "") exitWith {}; -[_query,1] call HC_fnc_asyncCall; +[_query, 1] call HC_fnc_asyncCall; diff --git a/life_hc/MySQL/General/fn_updateRequest.sqf b/life_hc/MySQL/General/fn_updateRequest.sqf old mode 100644 new mode 100755 index b3cc164fe..67292ac1e --- a/life_hc/MySQL/General/fn_updateRequest.sqf +++ b/life_hc/MySQL/General/fn_updateRequest.sqf @@ -8,37 +8,34 @@ Updates ALL player information in the database. Information gets passed here from the client side file: core\session\fn_updateRequest.sqf */ -private ["_uid","_side","_cash","_bank","_licenses","_gear","_stats","_name","_alive","_position","_query"]; -_uid = [_this,0,"",[""]] call BIS_fnc_param; -_name = [_this,1,"",[""]] call BIS_fnc_param; -_side = [_this,2,sideUnknown,[civilian]] call BIS_fnc_param; -_cash = [_this,3,0,[0]] call BIS_fnc_param; -_bank = [_this,4,5000,[0]] call BIS_fnc_param; -_licenses = [_this,5,[],[[]]] call BIS_fnc_param; -_gear = [_this,6,[],[[]]] call BIS_fnc_param; -_stats = [_this,7,[100,100],[[]]] call BIS_fnc_param; -_alive = [_this,9,false,[true]] call BIS_fnc_param; -_position = [_this,10,[],[[]]] call BIS_fnc_param; + +params [ + ["_uid", "", [""]], + ["_name", "", [""]], + ["_side", sideUnknown, [civilian]], + ["_cash", 0, [0]], + ["_bank", 5000, [0]], + ["_licenses", [], [[]]], + ["_gear", [], [[]]], + ["_stats", [100,100],[[]]], + ["_arrested", false, [true]], + ["_alive", false, [true]], + ["_position", [], [[]]] +]; //Get to those error checks. -if ((_uid isEqualTo "") || (_name isEqualTo "")) exitWith {}; +if (_uid isEqualTo "" || {_name isEqualTo ""}) exitWith {}; -//Parse and setup some data. -_name = [_name] call HC_fnc_mresString; -_gear = [_gear] call HC_fnc_mresArray; -_stats = [_stats] call HC_fnc_mresArray; -_cash = [_cash] call HC_fnc_numberSafe; -_bank = [_bank] call HC_fnc_numberSafe; -_position = if (_side isEqualTo civilian) then {[_position] call HC_fnc_mresArray} else {[]}; +//Setup some data. +_position = if (_side isEqualTo civilian) then {_position} else {[]}; +_arrested = [0, 1] select _arrested; +_alive = [0, 1] select _alive; -//Does something license related but I can't remember I only know it's important? -for "_i" from 0 to count(_licenses)-1 do { - _bool = [(_licenses select _i) select 1] call HC_fnc_bool; - _licenses set[_i,[(_licenses select _i) select 0,_bool]]; +for "_i" from 0 to (count _licenses) -1 do { + (_licenses select _i) params ["_license", "_owned"]; + _licenses set[_i, [_license, [0, 1] select _owned]]; }; -_licenses = [_licenses] call HC_fnc_mresArray; - //PLAYTIME _playtime = [_uid] call HC_fnc_getPlayTime; _playtime_update = []; @@ -54,12 +51,12 @@ switch (_side) do { case civilian: {_playtime_update set[2,_playtime];}; case independent: {_playtime_update set[1,_playtime];}; }; -_playtime_update = [_playtime_update] call HC_fnc_mresArray; -switch (_side) do { - case west: {_query = format ["UPDATE players SET name='%1', cash='%2', bankacc='%3', cop_gear='%4', cop_licenses='%5', cop_stats='%6', playtime='%7' WHERE pid='%8'",_name,_cash,_bank,_gear,_licenses,_stats,_playtime_update,_uid];}; - case civilian: {_query = format ["UPDATE players SET name='%1', cash='%2', bankacc='%3', civ_licenses='%4', civ_gear='%5', arrested='%6', civ_stats='%7', civ_alive='%8', civ_position='%9', playtime='%10' WHERE pid='%11'",_name,_cash,_bank,_licenses,_gear,[_this select 8] call HC_fnc_bool,_stats,[_alive] call HC_fnc_bool,_position,_playtime_update,_uid];}; - case independent: {_query = format ["UPDATE players SET name='%1', cash='%2', bankacc='%3', med_licenses='%4', med_gear='%5', med_stats='%6', playtime='%7' WHERE pid='%8'",_name,_cash,_bank,_licenses,_gear,_stats,_playtime_update,_uid];}; +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; + +_queryResult = [_query, 1] call HC_fnc_asyncCall; diff --git a/life_hc/MySQL/Housing/fn_addContainer.sqf b/life_hc/MySQL/Housing/fn_addContainer.sqf old mode 100644 new mode 100755 index 85f53291a..ad06651d3 --- a/life_hc/MySQL/Housing/fn_addContainer.sqf +++ b/life_hc/MySQL/Housing/fn_addContainer.sqf @@ -8,24 +8,23 @@ Description: Add container in Database. */ -private ["_containerPos","_query","_className","_dir"]; + params [ - ["_uid","",[""]], - ["_container",objNull,[objNull]] + ["_uid", "", [""]], + ["_container", objNull, [objNull]] ]; -if (isNull _container || _uid isEqualTo "") exitWith {}; - -_containerPos = getPosATL _container; -_className = typeOf _container; -_dir = [vectorDir _container, vectorUp _container]; +if (isNull _container || {_uid isEqualTo ""}) exitWith {}; -_query = format ["INSERT INTO containers (pid, pos, classname, inventory, gear, owned, dir) VALUES('%1', '%2', '%3', '""[[],0]""', '""[]""', '1', '%4')",_uid,_containerPos,_className,_dir]; -[_query,1] call HC_fnc_asyncCall; +private _containerPos = getPosATL _container; +private _className = typeOf _container; +private _dir = [vectorDir _container, vectorUp _container]; -sleep 0.3; +private _query = format ["insertContainer:%1:%2:%3:%4", _uid, _containerPos, _className, _dir]; +[_query, 1] call HC_fnc_asyncCall; -_query = format ["SELECT id FROM containers WHERE pos='%1' AND pid='%2' AND owned='1'",_containerPos,_uid]; -_queryResult = [_query,2] call HC_fnc_asyncCall; +uiSleep 0.3; -_container setVariable ["container_id",(_queryResult select 0),true]; +_query = format ["selectContainerID:%1:%2", _containerPos, _uid]; +_queryResult = [_query, 2] call HC_fnc_asyncCall; +_container setVariable ["container_id", _queryResult select 0, true]; diff --git a/life_hc/MySQL/Housing/fn_addHouse.sqf b/life_hc/MySQL/Housing/fn_addHouse.sqf old mode 100644 new mode 100755 index fad0676ab..446a2295e --- a/life_hc/MySQL/Housing/fn_addHouse.sqf +++ b/life_hc/MySQL/Housing/fn_addHouse.sqf @@ -6,23 +6,23 @@ This file is for Nanou's HeadlessClient. Description: - Blah + Inserts the players newly bought house in the database. */ -private ["_housePos","_query"]; + params [ ["_uid","",[""]], ["_house",objNull,[objNull]] ]; -if (isNull _house || _uid isEqualTo "") exitWith {}; -_housePos = getPosATL _house; +if (isNull _house || {_uid isEqualTo ""}) exitWith {}; -_query = format ["INSERT INTO houses (pid, pos, owned) VALUES('%1', '%2', '1')",_uid,_housePos]; -[_query,1] call HC_fnc_asyncCall; +private _housePos = getPosATL _house; -sleep 0.3; +private _query = format ["insertHouse:%1:%2", _uid, _housePos]; +[_query, 1] call HC_fnc_asyncCall; -_query = format ["SELECT id FROM houses WHERE pos='%1' AND pid='%2' AND owned='1'",_housePos,_uid]; -_queryResult = [_query,2] call HC_fnc_asyncCall; +uiSleep 0.3; -_house setVariable ["house_id",(_queryResult select 0),true]; +_query = format ["selectHouseID:%1:%2", _housePos, _uid]; +_queryResult = [_query, 2] call HC_fnc_asyncCall; +_house setVariable ["house_id", _queryResult select 0, true]; diff --git a/life_hc/MySQL/Housing/fn_deleteDBContainer.sqf b/life_hc/MySQL/Housing/fn_deleteDBContainer.sqf old mode 100644 new mode 100755 index 36b9b55bc..6135b7a58 --- a/life_hc/MySQL/Housing/fn_deleteDBContainer.sqf +++ b/life_hc/MySQL/Housing/fn_deleteDBContainer.sqf @@ -7,22 +7,27 @@ Description: Delete Container and remove Container in Database */ -private ["_house","_houseID","_ownerID","_housePos","_query","_radius","_containers"]; -_container = [_this,0,objNull,[objNull]] call BIS_fnc_param; + +params [ + ["_container", objNull, [objNull]] +]; + if (isNull _container) exitWith {diag_log "container null";}; +_containerID = _container getVariable ["container_id", -1]; + +private "_query"; -_containerID = _container getVariable ["container_id",-1]; if (_containerID isEqualTo -1) then { _containerPos = getPosATL _container; - _ownerID = (_container getVariable "container_owner") select 0; - _query = format ["UPDATE containers SET owned='0', pos='[]' WHERE pid='%1' AND pos='%2' AND owned='1'",_ownerID,_containerPos]; + private _ownerID = (_container getVariable "container_owner") select 0; + _query = format ["deleteContainer:%1:%2", _ownerID, _containerPos]; } else { - _query = format ["UPDATE containers SET owned='0', pos='[]' WHERE id='%1'",_containerID]; + _query = format ["deleteContainer1:%1",_containerID]; }; -_container setVariable ["container_id",nil,true]; -_container setVariable ["container_owner",nil,true]; +_container setVariable ["container_id", nil, true]; +_container setVariable ["container_owner", nil, true]; -[_query,1] call HC_fnc_asyncCall; +[_query, 1] call HC_fnc_asyncCall; -["CALL deleteOldContainers",1] call HC_fnc_asyncCall; +["deleteOldContainers", 1] call HC_fnc_asyncCall; deleteVehicle _container; diff --git a/life_hc/MySQL/Housing/fn_fetchPlayerHouses.sqf b/life_hc/MySQL/Housing/fn_fetchPlayerHouses.sqf old mode 100644 new mode 100755 index 08940cb8e..368060a29 --- a/life_hc/MySQL/Housing/fn_fetchPlayerHouses.sqf +++ b/life_hc/MySQL/Housing/fn_fetchPlayerHouses.sqf @@ -10,30 +10,30 @@ 1. Fetches all the players houses and sets them up. 2. Fetches all the players containers and sets them up. */ -private ["_query","_containers","_containerss","_houses"]; + params [ ["_uid","",[""]] ]; + if (_uid isEqualTo "") exitWith {}; -_query = format ["SELECT pid, pos, classname, inventory, gear, dir, id FROM containers WHERE pid='%1' AND owned='1'",_uid]; -_containers = [_query,2,true] call HC_fnc_asyncCall; +private _query = format ["selectContainers:%1", _uid]; +private _containers = [_query, 2, true] call HC_fnc_asyncCall; +private _containerss = []; -_containerss = []; { _position = call compile format ["%1",_x select 1]; _house = nearestObject [_position, "House"]; _direction = call compile format ["%1",_x select 5]; - _trunk = [_x select 3] call HC_fnc_mresToArray; + _trunk = _x select 3; if (_trunk isEqualType "") then {_trunk = call compile format ["%1", _trunk];}; - _gear = [_x select 4] call HC_fnc_mresToArray; + _gear = _x select 4; if (_gear isEqualType "") then {_gear = call compile format ["%1", _gear];}; _container = createVehicle[_x select 2,[0,0,999],[],0,"NONE"]; waitUntil {!isNil "_container" && {!isNull _container}}; _containerss = _house getVariable ["containers",[]]; _containerss pushBack _container; _container allowDamage false; - _container enableRopeAttach false; _container setPosATL _position; _container setVectorDirAndUp _direction; //Fix position for more accurate positioning @@ -71,11 +71,11 @@ _containerss = []; _container addBackpackCargoGlobal [((_backpacks select 0) select _i), ((_backpacks select 1) select _i)]; }; }; - _house setVariable ["containers",_containerss,true]; + _house setVariable ["containers", _containerss, true]; } forEach _containers; -_query = format ["SELECT pid, pos FROM houses WHERE pid='%1' AND owned='1'",_uid]; -_houses = [_query,2,true] call HC_fnc_asyncCall; +_query = format ["selectHousePositions:%1", _uid]; +private _houses = [_query, 2, true] call HC_fnc_asyncCall; _return = []; { @@ -85,4 +85,4 @@ _return = []; _return pushBack [_x select 1]; } forEach _houses; -missionNamespace setVariable [format ["houses_%1",_uid],_return]; +missionNamespace setVariable [format ["houses_%1", _uid], _return]; diff --git a/life_hc/MySQL/Housing/fn_houseGarage.sqf b/life_hc/MySQL/Housing/fn_houseGarage.sqf old mode 100644 new mode 100755 index 56baebfe1..56bfb6a4c --- a/life_hc/MySQL/Housing/fn_houseGarage.sqf +++ b/life_hc/MySQL/Housing/fn_houseGarage.sqf @@ -12,21 +12,9 @@ params [ ["_mode",-1,[0]] ]; -if (_uid isEqualTo "") exitWith {}; -if (isNull _house) exitWith {}; -if (_mode isEqualTo -1) exitWith {}; +if (_uid isEqualTo "" || {isNull _house} || {_mode isEqualTo -1}) exitWith {}; private _housePos = getPosATL _house; -private "_query"; - -if (_mode isEqualTo 0) then { - _query = format ["UPDATE houses SET garage='1' WHERE pid='%1' AND pos='%2'",_uid,_housePos]; -} else { - _query = format ["UPDATE houses SET garage='0' WHERE pid='%1' AND pos='%2'",_uid,_housePos]; -}; - -if (EXTDB_SETTING(getNumber,"DebugMode") isEqualTo 1) then { - diag_log format ["Query: %1",_query]; -}; - -[_query,1] call DB_fnc_asyncCall; \ No newline at end of file +private _active = ["0", "1"] select (_mode isEqualTo 0); +private _query = format ["updateGarage:%1:%2:%3", _active, _uid, _housePos]; +[_query, 1] call HC_fnc_asyncCall; diff --git a/life_hc/MySQL/Housing/fn_sellHouse.sqf b/life_hc/MySQL/Housing/fn_sellHouse.sqf old mode 100644 new mode 100755 index 16fd3be32..c7bffcfee --- a/life_hc/MySQL/Housing/fn_sellHouse.sqf +++ b/life_hc/MySQL/Housing/fn_sellHouse.sqf @@ -8,22 +8,28 @@ Used in selling the house, sets the owned to 0 and will cleanup with a stored procedure on restart. */ -private ["_house","_houseID","_ownerID","_housePos","_query","_radius","_containers"]; -_house = [_this,0,objNull,[objNull]] call BIS_fnc_param; -if (isNull _house) exitWith {}; -_houseID = _house getVariable ["house_id",-1]; +params [ + ["_house", objNull, [objNull]] +]; + +if (isNull _house) exitWith {systemChat ":SERVER:sellHouse: House is null";}; +private _houseID = _house getVariable ["house_id", -1]; + +private "_query"; + if (_houseID isEqualTo -1) then { - _housePos = getPosATL _house; - _ownerID = (_house getVariable "house_owner") select 0; - _query = format ["UPDATE houses SET owned='0', pos='[]' WHERE pid='%1' AND pos='%2' AND owned='1'",_ownerID,_housePos]; + private _housePos = getPosATL _house; + private _ownerID = (_house getVariable "house_owner") select 0; + _query = format ["deleteHouse:%1:%2", _ownerID, _housePos]; } else { - _query = format ["UPDATE houses SET owned='0', pos='[]' WHERE id='%1'",_houseID]; + _query = format ["deleteHouse1:%1", _houseID]; }; -_house setVariable ["house_id",nil,true]; -_house setVariable ["house_owner",nil,true]; +_house setVariable ["house_id", nil, true]; +_house setVariable ["house_owner", nil, true]; +_house setVariable ["garageBought", false, true]; -[_query,1] call HC_fnc_asyncCall; -_house setVariable ["house_sold",nil,true]; -["CALL deleteOldHouses",1] call HC_fnc_asyncCall; \ No newline at end of file +[_query, 1] call HC_fnc_asyncCall; +_house setVariable ["house_sold", nil, true]; +["deleteOldHouses", 1] call HC_fnc_asyncCall; diff --git a/life_hc/MySQL/Housing/fn_sellHouseContainer.sqf b/life_hc/MySQL/Housing/fn_sellHouseContainer.sqf old mode 100644 new mode 100755 index 0f6152575..a080686bb --- a/life_hc/MySQL/Housing/fn_sellHouseContainer.sqf +++ b/life_hc/MySQL/Housing/fn_sellHouseContainer.sqf @@ -8,22 +8,27 @@ Used in selling the house, container sets the owned to 0 and will cleanup with a stored procedure on restart. */ -private ["_house","_houseID","_ownerID","_housePos","_query","_radius","_containers"]; -_container = [_this,0,objNull,[objNull]] call BIS_fnc_param; -if (isNull _container) exitWith {}; +params [ + ["_container", objNull, [objNull]] +]; + +if (isNull _container) exitWith {}; _containerID = _container getVariable ["container_id",-1]; + +private "_query"; + if (_containerID isEqualTo -1) then { _containerPos = getPosATL _container; - _ownerID = (_container getVariable "container_owner") select 0; - _query = format ["UPDATE containers SET owned='0', pos='[]' WHERE pid='%1' AND pos='%2' AND owned='1'",_ownerID,_containerPos]; + private _ownerID = (_container getVariable "container_owner") select 0; + _query = format ["deleteContainer:%1:%2", _ownerID, _containerPos]; } else { - _query = format ["UPDATE containers SET owned='0', pos='[]' WHERE id='%1'",_containerID]; + _query = format ["deleteContainer1:%1", _containerID]; }; -_container setVariable ["container_id",nil,true]; -_container setVariable ["container_owner",nil,true]; +_container setVariable ["container_id", nil, true]; +_container setVariable ["container_owner", nil, true]; deleteVehicle _container; -[_query,1] call HC_fnc_asyncCall; -["CALL deleteOldContainers",1] call HC_fnc_asyncCall; \ No newline at end of file +[_query, 1] call HC_fnc_asyncCall; +["deleteOldContainers", 1] call HC_fnc_asyncCall; diff --git a/life_hc/MySQL/Housing/fn_updateHouseContainers.sqf b/life_hc/MySQL/Housing/fn_updateHouseContainers.sqf old mode 100644 new mode 100755 index d34158199..8aca57fe3 --- a/life_hc/MySQL/Housing/fn_updateHouseContainers.sqf +++ b/life_hc/MySQL/Housing/fn_updateHouseContainers.sqf @@ -7,20 +7,22 @@ Description: Update inventory "i" in container */ -private ["_containerID","_containers","_query","_vehItems","_vehMags","_vehWeapons","_vehBackpacks","_cargo"]; -_container = [_this,0,objNull,[objNull]] call BIS_fnc_param; + +params [ + ["_container", objNull, [objNull]] +]; + if (isNull _container) exitWith {}; -_containerID = _container getVariable ["container_id",-1]; -if (_houseID isEqualTo -1) exitWith {}; -_vehItems = getItemCargo _container; -_vehMags = getMagazineCargo _container; -_vehWeapons = getWeaponCargo _container; -_vehBackpacks = getBackpackCargo _container; -_cargo = [_vehItems,_vehMags,_vehWeapons,_vehBackpacks]; +private _containerID = _container getVariable ["container_id", -1]; +if (_containerID isEqualTo -1) exitWith {}; -_cargo = [_cargo] call HC_fnc_mresArray; +private _vehItems = getItemCargo _container; +private _vehMags = getMagazineCargo _container; +private _vehWeapons = getWeaponCargo _container; +private _vehBackpacks = getBackpackCargo _container; +private _cargo = [_vehItems, _vehMags, _vehWeapons, _vehBackpacks]; -_query = format ["UPDATE containers SET gear='%1' WHERE id='%2'",_cargo,_containerID]; +private _query = format ["updateContainer:%1:%2", _cargo, _containerID]; -[_query,1] call HC_fnc_asyncCall; +[_query, 1] call HC_fnc_asyncCall; diff --git a/life_hc/MySQL/Housing/fn_updateHouseTrunk.sqf b/life_hc/MySQL/Housing/fn_updateHouseTrunk.sqf old mode 100644 new mode 100755 index 02f5ae6fe..c05c347e5 --- a/life_hc/MySQL/Housing/fn_updateHouseTrunk.sqf +++ b/life_hc/MySQL/Housing/fn_updateHouseTrunk.sqf @@ -7,16 +7,17 @@ Description: Update inventory "y" in container */ -private ["_house"]; -_container = [_this,0,objNull,[objNull]] call BIS_fnc_param; -if (isNull _container) exitWith {}; -_trunkData = _container getVariable ["Trunk",[[],0]]; -_containerID = _container getVariable ["container_id",-1]; +params [ + ["_container", objNull, [objNull]] +]; + +if (isNull _container) exitWith {}; -if (_containerID isEqualTo -1) exitWith {}; //Dafuq? +_trunkData = _container getVariable ["Trunk", [[], 0]]; +_containerID = _container getVariable ["container_id", -1]; -_trunkData = [_trunkData] call HC_fnc_mresArray; -_query = format ["UPDATE containers SET inventory='%1' WHERE id='%2'",_trunkData,_containerID]; +if (_containerID isEqualTo -1) exitWith {}; -[_query,1] call HC_fnc_asyncCall; +_query = format ["updateHouseTrunk:%1:%2", _trunkData, _containerID]; +[_query, 1] call HC_fnc_asyncCall; diff --git a/life_hc/MySQL/Vehicles/fn_chopShopSell.sqf b/life_hc/MySQL/Vehicles/fn_chopShopSell.sqf old mode 100644 new mode 100755 index a47da9473..85a7d7927 --- a/life_hc/MySQL/Vehicles/fn_chopShopSell.sqf +++ b/life_hc/MySQL/Vehicles/fn_chopShopSell.sqf @@ -8,26 +8,36 @@ Description: Checks whether or not the vehicle is persistent or temp and sells it. */ + params [ - ["_unit",objNull,[objNull]], - ["_vehicle",objNull,[objNull]], - ["_price",500,[0]] + ["_unit", objNull, [objNull]], + ["_vehicle", objNull, [objNull]], + ["_price", 500, [0]], + ["_cash", 0, [0]] ]; +_ownerUnit = _ownerUnit getVariable "life_clientID"; + //Error checks -if (isNull _vehicle || isNull _unit) exitWith { - [] remoteExecCall ["life_fnc_chopShopSold", remoteExecutedOwner]; +if (isNull _vehicle || {isNull _unit}) exitWith { + life_action_inUse = false; + _ownerUnit publicVariableClient "life_action_inUse"; }; -private _displayName = FETCH_CONFIG2(getText,"CfgVehicles",typeOf _vehicle, "displayName"); +_displayName = FETCH_CONFIG2(getText, "CfgVehicles", typeOf _vehicle, "displayName"); -private _dbInfo = _vehicle getVariable ["dbInfo",[]]; -if (count _dbInfo > 0) then { - _dbInfo params ["_uid","_plate"]; - private _query = format ["UPDATE vehicles SET alive='0' WHERE pid='%1' AND plate='%2'",_uid,_plate]; - [_query,1] call HC_fnc_asyncCall; +_dbInfo = _vehicle getVariable ["dbInfo", []]; +if !(_dbInfo isEqualTo []) then { + _uid = (_dbInfo select 0); + _plate = (_dbInfo select 1); + + _query = format ["deleteVehicle:%1:%2", _uid, _plate]; + _sql = [_query, 1] call HC_fnc_asyncCall; }; deleteVehicle _vehicle; - -[_price,_displayName] remoteExecCall ["life_fnc_chopShopSold", remoteExecutedOwner]; \ No newline at end of file +life_action_inUse = false; +_ownerUnit publicVariableClient "life_action_inUse"; +CASH = _cash; +_ownerUnit publicVariableClient "life_cash"; +[2, "STR_NOTF_ChopSoldCar", true, [_displayName, [_price] call life_fnc_numberText]] remoteExecCall ["life_fnc_broadcast", _unit]; diff --git a/life_hc/MySQL/Vehicles/fn_getVehicles.sqf b/life_hc/MySQL/Vehicles/fn_getVehicles.sqf old mode 100644 new mode 100755 index 1debb7a1a..6a742e038 --- a/life_hc/MySQL/Vehicles/fn_getVehicles.sqf +++ b/life_hc/MySQL/Vehicles/fn_getVehicles.sqf @@ -8,16 +8,18 @@ Description: Sends a request to query the database information and returns vehicles. */ -private ["_pid","_side","_type","_unit","_ret","_tickTime","_queryResult"]; -_pid = [_this,0,"",[""]] call BIS_fnc_param; -_side = [_this,1,sideUnknown,[west]] call BIS_fnc_param; -_type = [_this,2,"",[""]] call BIS_fnc_param; -_unit = [_this,3,objNull,[objNull]] call BIS_fnc_param; + +params [ + ["_pid", "", [""]], + ["_side", sideUnknown, [west]], + ["_type", "", [""]], + ["_unit", objNull, [objNull]] +]; //Error checks -if (_pid isEqualTo "" || _side isEqualTo sideUnknown || _type isEqualTo "" || isNull _unit) exitWith { +if (_pid isEqualTo "" || {_side isEqualTo sideUnknown} || {_type isEqualTo ""} || {isNull _unit}) exitWith { if (!isNull _unit) then { - [[]] remoteExec ["life_fnc_impoundMenu",_unit]; + [[]] remoteExec ["life_fnc_impoundMenu", _unit]; }; }; @@ -28,17 +30,15 @@ _side = switch (_side) do { default {"Error"}; }; -if (_side == "Error") exitWith { - [[]] remoteExec ["life_fnc_impoundMenu",_unit]; +if (_side isEqualTo "Error") exitWith { + [[]] remoteExec ["life_fnc_impoundMenu", _unit]; }; -_query = format ["SELECT id, side, classname, type, pid, alive, active, plate, color FROM vehicles WHERE pid='%1' AND alive='1' AND active='0' AND side='%2' AND type='%3'",_pid,_side,_type]; - -_tickTime = diag_tickTime; -_queryResult = [_query,2,true] call HC_fnc_asyncCall; +private _query = format ["selectVehicles:%1:%2:%3", _pid, _side, _type]; +private _queryResult = [_query, 2, true] call HC_fnc_asyncCall; if (_queryResult isEqualType "") exitWith { - [[]] remoteExec ["life_fnc_impoundMenu",_unit]; + [[]] remoteExec ["life_fnc_impoundMenu", _unit]; }; -[_queryResult] remoteExec ["life_fnc_impoundMenu",_unit]; +[_queryResult] remoteExec ["life_fnc_impoundMenu", _unit]; diff --git a/life_hc/MySQL/Vehicles/fn_spawnVehicle.sqf b/life_hc/MySQL/Vehicles/fn_spawnVehicle.sqf old mode 100644 new mode 100755 index 48c0409fa..c6accc63a --- a/life_hc/MySQL/Vehicles/fn_spawnVehicle.sqf +++ b/life_hc/MySQL/Vehicles/fn_spawnVehicle.sqf @@ -9,6 +9,7 @@ Sends the query request to the database, if an array is returned then it creates the vehicle if it's not in use or dead. */ + params [ ["_vid", -1, [0]], ["_pid", "", [""]], @@ -19,24 +20,19 @@ params [ "_spawntext" ]; - - -private _ownerID = _unit getVariable ["life_clientID",-1]; private _unit_return = _unit; private _name = name _unit; private _side = side _unit; -//_unit = owner _unit; - if (_vid isEqualTo -1 || {_pid isEqualTo ""}) exitWith {}; if (_vid in serv_sv_use) exitWith {}; serv_sv_use pushBack _vid; -private _servIndex = serv_sv_use find _vid; -private _query = format ["SELECT id, side, classname, type, pid, alive, active, plate, color, inventory, gear, fuel, damage, blacklist FROM vehicles WHERE id='%1' AND pid='%2'",_vid,_pid]; +private _servIndex = serv_sv_use find _vid; private _tickTime = diag_tickTime; -private _queryResult = [_query,2] call HC_fnc_asyncCall; +private _query = format ["selectVehiclesMore:%1:%2", _vid, _pid]; +private _queryResult = [_query, 2] call HC_fnc_asyncCall; if (EXTDB_SETTING(getNumber,"DebugMode") isEqualTo 1) then { diag_log "------------- Client Query Request -------------"; @@ -48,9 +44,9 @@ if (EXTDB_SETTING(getNumber,"DebugMode") isEqualTo 1) then { if (_queryResult isEqualType "") exitWith {}; -_vInfo = _queryResult; +private _vInfo = _queryResult; if (isNil "_vInfo") exitWith {serv_sv_use deleteAt _servIndex;}; -if (count _vInfo isEqualTo 0) exitWith {serv_sv_use deleteAt _servIndex;}; +if (_vInfo isEqualTo []) exitWith {serv_sv_use deleteAt _servIndex;}; if ((_vInfo select 5) isEqualTo 0) exitWith { serv_sv_use deleteAt _servIndex; @@ -62,7 +58,6 @@ if ((_vInfo select 6) isEqualTo 1) exitWith { [1,"STR_Garage_SQLError_Active",true,[_vInfo select 2]] remoteExecCall ["life_fnc_broadcast",_unit]; }; - private "_nearVehicles"; if !(_sp isEqualType "") then { _nearVehicles = nearestObjects[_sp,["Car","Air","Ship"],10]; @@ -70,21 +65,21 @@ if !(_sp isEqualType "") then { _nearVehicles = []; }; -if (count _nearVehicles > 0) exitWith { +if !(_nearVehicles isEqualTo []) exitWith { serv_sv_use deleteAt _servIndex; [_price,_unit_return] remoteExecCall ["life_fnc_garageRefund",_unit]; [1,"STR_Garage_SpawnPointError",true] remoteExecCall ["life_fnc_broadcast",_unit]; }; -_query = format ["UPDATE vehicles SET active='1', damage='""[]""' WHERE pid='%1' AND id='%2'",_pid,_vid]; +_query = format ["updateVehicle:%1:%2", _pid, _vid]; -private _trunk = [(_vInfo select 9)] call HC_fnc_mresToArray; -private _gear = [(_vInfo select 10)] call HC_fnc_mresToArray; -private _damage = [call compile (_vInfo select 12)] call HC_fnc_mresToArray; +private _trunk = _vInfo select 9; +private _gear = _vInfo select 10; +private _damage = _vInfo select 12; private _wasIllegal = _vInfo select 13; -_wasIllegal = if (_wasIllegal isEqualTo 1) then { true } else { false }; +_wasIllegal = _wasIllegal isEqualTo 1; -[_query,1] call HC_fnc_asyncCall; +[_query, 1] call HC_fnc_asyncCall; private "_vehicle"; if (_sp isEqualType "") then { @@ -93,7 +88,7 @@ if (_sp isEqualType "") then { _vehicle allowDamage false; _hs = nearestObjects[getMarkerPos _sp,["Land_Hospital_side2_F"],50] select 0; _vehicle setPosATL (_hs modelToWorld [-0.4,-4,12.65]); - sleep 0.6; + uiSleep 0.6; } else { _vehicle = createVehicle [(_vInfo select 2),_sp,[],0,"NONE"]; waitUntil {!isNil "_vehicle" && {!isNull _vehicle}}; @@ -105,11 +100,10 @@ if (_sp isEqualType "") then { _vehicle allowDamage true; //Send keys over the network. [_vehicle] remoteExecCall ["life_fnc_addVehicle2Chain",_unit]; -/*[_pid,_side,_vehicle,1] call HC_fnc_keyManagement;*/ [_pid,_side,_vehicle,1] remoteExecCall ["TON_fnc_keyManagement",RSERV]; _vehicle lock 2; //Reskin the vehicle -[_vehicle,_vInfo select 8] remoteExecCall ["life_fnc_colorVehicle",_unit]; +[_vehicle, _vInfo select 8] remoteExecCall ["life_fnc_colorVehicle",_unit]; _vehicle setVariable ["vehicle_info_owners",[[_pid,_name]],true]; _vehicle setVariable ["dbInfo",[(_vInfo select 4),(_vInfo select 7)],true]; _vehicle disableTIEquipment true; //No Thermals.. They're cheap but addictive. @@ -118,42 +112,42 @@ _vehicle disableTIEquipment true; //No Thermals.. They're cheap but addictive. if (LIFE_SETTINGS(getNumber,"save_vehicle_virtualItems") isEqualTo 1) then { _vehicle setVariable ["Trunk",_trunk,true]; - + if (_wasIllegal) then { private _refPoint = if (_sp isEqualType "") then {getMarkerPos _sp;} else {_sp;}; - + private _distance = 100000; private "_location"; { private _tempLocation = nearestLocation [_refPoint, _x]; private _tempDistance = _refPoint distance _tempLocation; - + if (_tempDistance < _distance) then { _location = _tempLocation; _distance = _tempDistance; }; false - + } count ["NameCityCapital", "NameCity", "NameVillage"]; - + _location = text _location; - [1,"STR_NOTF_BlackListedVehicle",true,[_location,_name]] remoteExecCall ["life_fnc_broadcast",west]; + [1, "STR_NOTF_BlackListedVehicle", true, [_location, _name]] remoteExecCall ["life_fnc_broadcast", west]; - _query = format ["UPDATE vehicles SET blacklist='0' WHERE id='%1' AND pid='%2'",_vid,_pid]; - [_query,1] call HC_fnc_asyncCall; - }; + _query = format ["updateVehicleBlacklist:%1:%2", _vid, _pid]; + [_query, 1] call HC_fnc_asyncCall; + }; } else { - _vehicle setVariable ["Trunk",[[],0],true]; + _vehicle setVariable ["Trunk", [[], 0], true]; }; if (LIFE_SETTINGS(getNumber,"save_vehicle_fuel") isEqualTo 1) then { _vehicle setFuel (_vInfo select 11); - } else { +} else { _vehicle setFuel 1; }; -if (count _gear > 0 && (LIFE_SETTINGS(getNumber,"save_vehicle_inventory") isEqualTo 1)) then { +if (!(_gear isEqualTo []) && (LIFE_SETTINGS(getNumber,"save_vehicle_inventory") isEqualTo 1)) then { _items = _gear select 0; _mags = _gear select 1; _weapons = _gear select 2; @@ -173,7 +167,7 @@ if (count _gear > 0 && (LIFE_SETTINGS(getNumber,"save_vehicle_inventory") isEqua }; }; -if (count _damage > 0 && (LIFE_SETTINGS(getNumber,"save_vehicle_damage") isEqualTo 1)) then { +if (!(_damage isEqualTo []) && (LIFE_SETTINGS(getNumber,"save_vehicle_damage") isEqualTo 1)) then { _parts = getAllHitPointsDamage _vehicle; for "_i" from 0 to ((count _damage) - 1) do { @@ -182,7 +176,7 @@ if (count _damage > 0 && (LIFE_SETTINGS(getNumber,"save_vehicle_damage") isEqual }; //Sets of animations -if ((_vInfo select 1) isEqualTo "civ" && ((_vInfo select 2)) isEqualTo "B_Heli_Light_01_F" && !((_vInfo select 8) isEqualTo 13)) then { +if ((_vInfo select 1) isEqualTo "civ" && (_vInfo select 2) isEqualTo "B_Heli_Light_01_F" && !((_vInfo select 8) isEqualTo 13)) then { [_vehicle,"civ_littlebird",true] remoteExecCall ["life_fnc_vehicleAnimate",_unit]; }; @@ -190,9 +184,9 @@ if ((_vInfo select 1) isEqualTo "cop" && ((_vInfo select 2)) in ["C_Offroad_01_F [_vehicle,"cop_offroad",true] remoteExecCall ["life_fnc_vehicleAnimate",_unit]; }; -if ((_vInfo select 1) isEqualTo "med" && ((_vInfo select 2)) isEqualTo "C_Offroad_01_F") then { +if ((_vInfo select 1) isEqualTo "med" && (_vInfo select 2) isEqualTo "C_Offroad_01_F") then { [_vehicle,"med_offroad",true] remoteExecCall ["life_fnc_vehicleAnimate",_unit]; }; -[1,_spawntext] remoteExecCall ["life_fnc_broadcast",_unit]; +[1, _spawntext] remoteExecCall ["life_fnc_broadcast",_unit]; serv_sv_use deleteAt _servIndex; diff --git a/life_hc/MySQL/Vehicles/fn_vehicleCreate.sqf b/life_hc/MySQL/Vehicles/fn_vehicleCreate.sqf old mode 100644 new mode 100755 index bb64db519..5f2434c74 --- a/life_hc/MySQL/Vehicles/fn_vehicleCreate.sqf +++ b/life_hc/MySQL/Vehicles/fn_vehicleCreate.sqf @@ -7,17 +7,19 @@ Description: Answers the query request to create the vehicle in the database. */ -private ["_uid","_side","_type","_classname","_color","_plate"]; -_uid = [_this,0,"",[""]] call BIS_fnc_param; -_side = [_this,1,sideUnknown,[west]] call BIS_fnc_param; -_vehicle = [_this,2,objNull,[objNull]] call BIS_fnc_param; -_color = [_this,3,-1,[0]] call BIS_fnc_param; + +params [ + ["_uid", "", [""]], + ["_side", sideUnknown, [west]], + ["_vehicle", objNull, [objNull]], + ["_color", -1, [0]] +]; //Error checks -if (_uid isEqualTo "" || _side isEqualTo sideUnknown || isNull _vehicle) exitWith {}; +if (_uid isEqualTo "" || {_side isEqualTo sideUnknown} || {isNull _vehicle}) exitWith {}; if (!alive _vehicle) exitWith {}; -_className = typeOf _vehicle; -_type = switch (true) do { +private _className = typeOf _vehicle; +private _type = switch (true) do { case (_vehicle isKindOf "Car"): {"Car"}; case (_vehicle isKindOf "Air"): {"Air"}; case (_vehicle isKindOf "Ship"): {"Ship"}; @@ -30,8 +32,7 @@ _side = switch (_side) do { default {"Error"}; }; -_plate = round(random(1000000)); - -[_uid,_side,_type,_classname,_color,_plate] call HC_fnc_insertVehicle; +private _plate = round(random(1000000)); +[_uid, _side, _type, _classname, _color, _plate] call HC_fnc_insertVehicle; -_vehicle setVariable ["dbInfo",[_uid,_plate],true]; +_vehicle setVariable ["dbInfo", [_uid, _plate], true]; diff --git a/life_hc/MySQL/Vehicles/fn_vehicleDelete.sqf b/life_hc/MySQL/Vehicles/fn_vehicleDelete.sqf old mode 100644 new mode 100755 index 7c392232f..218dfe874 --- a/life_hc/MySQL/Vehicles/fn_vehicleDelete.sqf +++ b/life_hc/MySQL/Vehicles/fn_vehicleDelete.sqf @@ -8,16 +8,16 @@ Doesn't actually delete since we don't give our DB user that type of access so instead we set it to alive=0 so it never shows again. */ -diag_log "Script VehicleDelete HC"; -private ["_vid","_sp","_pid","_query","_sql","_type","_thread"]; -_vid = [_this,0,-1,[0]] call BIS_fnc_param; -_pid = [_this,1,"",[""]] call BIS_fnc_param; -_sp = [_this,2,2500,[0]] call BIS_fnc_param; -_unit = [_this,3,objNull,[objNull]] call BIS_fnc_param; -_type = [_this,4,"",[""]] call BIS_fnc_param; -if (_vid isEqualTo -1 || _pid isEqualTo "" || _sp isEqualTo 0 || isNull _unit || _type isEqualTo "") exitWith {}; +params [ + ["_vid", -1, [0]], + ["_pid", "", [""]], + ["_sp", 2500, [0]], + ["_unit", objNull, [objNull]], + ["_type", "", [""]] +]; -_query = format ["UPDATE vehicles SET alive='0' WHERE pid='%1' AND id='%2'",_pid,_vid]; +if (_vid isEqualTo -1 || {_pid isEqualTo ""} || {_sp isEqualTo 0} || {isNull _unit} || {_type isEqualTo ""}) exitWith {}; -_thread = [_query,1] call HC_fnc_asyncCall; +private _query = format ["deleteVehicleID:%1:%2", _pid, _vid]; +private _thread = [_query, 1] call HC_fnc_asyncCall; diff --git a/life_hc/MySQL/Vehicles/fn_vehicleStore.sqf b/life_hc/MySQL/Vehicles/fn_vehicleStore.sqf old mode 100644 new mode 100755 index f963dd9de..b90d8f176 --- a/life_hc/MySQL/Vehicles/fn_vehicleStore.sqf +++ b/life_hc/MySQL/Vehicles/fn_vehicleStore.sqf @@ -2,44 +2,49 @@ /* File: fn_vehicleStore.sqf Author: Bryan "Tonic" Boardwine - - This file is for Nanou's HeadlessClient. - Description: Stores the vehicle in the 'Garage' */ -private ["_vehicle","_impound","_vInfo","_vInfo","_plate","_uid","_query","_sql","_unit","_trunk","_vehItems","_vehMags","_vehWeapons","_vehBackpacks","_cargo","_saveItems","_storetext","_resourceItems","_fuel","_damage","_itemList","_totalweight","_weight"]; -_vehicle = [_this,0,objNull,[objNull]] call BIS_fnc_param; -_impound = [_this,1,false,[true]] call BIS_fnc_param; -_unit = [_this,2,objNull,[objNull]] call BIS_fnc_param; -_storetext = [_this,3,"",[""]] call BIS_fnc_param; -_ownerID = _unit getVariable ["life_clientID",-1]; -_resourceItems = LIFE_SETTINGS(getArray,"save_vehicle_items"); - -if (isNull _vehicle || isNull _unit) exitWith {life_impound_inuse = false; _ownerID publicVariableClient "life_impound_inuse";life_garage_store = false;_ownerID publicVariableClient "life_garage_store";}; //Bad data passed. -_vInfo = _vehicle getVariable ["dbInfo",[]]; - -if (count _vInfo > 0) then { + +params [ + ["_vehicle", objNull, [objNull]], + ["_impound", false, [true]], + ["_unit", objNull, [objNull]], + ["_storetext", "", [""]] +]; + +private _resourceItems = LIFE_SETTINGS(getArray,"save_vehicle_items"); +private _ownerID = _unit getVariable ["life_clientID",-1]; + +if (isNull _vehicle || {isNull _unit}) exitWith {life_impound_inuse = false; _ownerID publicVariableClient "life_impound_inuse";life_garage_store = false;_ownerID publicVariableClient "life_garage_store";}; //Bad data passed. +private _vInfo = _vehicle getVariable ["dbInfo", []]; +private "_plate"; +private "_uid"; + +if !(_vInfo isEqualTo []) then { _plate = _vInfo select 1; _uid = _vInfo select 0; }; // save damage. +private "_damage"; if (LIFE_SETTINGS(getNumber,"save_vehicle_damage") isEqualTo 1) then { _damage = getAllHitPointsDamage _vehicle; _damage = _damage select 2; - } else { +} else { _damage = []; }; -_damage = [_damage] call HC_fnc_mresArray; // because fuel price! +private "_fuel"; if (LIFE_SETTINGS(getNumber,"save_vehicle_fuel") isEqualTo 1) then { _fuel = (fuel _vehicle); - } else { +} else { _fuel = 1; }; +private "_query"; +private "_thread"; if (_impound) exitWith { if (_vInfo isEqualTo []) then { life_impound_inuse = false; @@ -49,7 +54,7 @@ if (_impound) exitWith { deleteVehicle _vehicle; }; } else { // no free repairs! - _query = format ["UPDATE vehicles SET active='0', fuel='%3', damage='%4' WHERE pid='%1' AND plate='%2'",_uid , _plate, _fuel, _damage]; + _query = format ["updateVehicleFuel:%1:%2:%3:%4", _fuel, _damage, _uid, _plate]; _thread = [_query,1] call HC_fnc_asyncCall; if (!isNil "_vehicle" && {!isNull _vehicle}) then { @@ -63,7 +68,7 @@ if (_impound) exitWith { // not persistent so just do this! if (_vInfo isEqualTo []) exitWith { - [1,"STR_Garage_Store_NotPersistent",true] remoteExecCall ["life_fnc_broadcast",_ownerID]; + [1,"STR_Garage_Store_NotPersistent",true] remoteExecCall ["life_fnc_broadcast",_ownerID]; life_garage_store = false; _ownerID publicVariableClient "life_garage_store"; }; @@ -75,23 +80,25 @@ if !(_uid isEqualTo getPlayerUID _unit) exitWith { }; // sort out whitelisted items! -_trunk = _vehicle getVariable ["Trunk", [[], 0]]; -_itemList = _trunk select 0; -_totalweight = 0; +private _trunk = _vehicle getVariable ["Trunk", [[], 0]]; +private _itemList = _trunk select 0; +private _totalweight = 0; +private "_weight"; _items = []; if (LIFE_SETTINGS(getNumber,"save_vehicle_virtualItems") isEqualTo 1) then { if (LIFE_SETTINGS(getNumber,"save_vehicle_illegal") isEqualTo 1) then { - _blacklist = false; - _profileQuery = format ["SELECT name FROM players WHERE pid='%1'", _uid]; + private _blacklist = false; + _profileQuery = format ["selectName:%1", _uid]; _profileName = [_profileQuery, 2] call HC_fnc_asyncCall; _profileName = _profileName select 0; + { - _isIllegal = M_CONFIG(getNumber,"VirtualItems",_x select 0,"illegal"); + private _isIllegal = M_CONFIG(getNumber,"VirtualItems",(_x select 0),"illegal"); - _isIllegal = if (_isIllegal isEqualTo 1) then { true } else { false }; + _isIllegal = if (_isIllegal isEqualTo 1) then { true } else { false }; - if (((_x select 0) in _resourceItems) || (_isIllegal)) then { - _items pushBack[_x select 0, _x select 1]; + if (((_x select 0) in _resourceItems) || (_isIllegal)) then { + _items pushBack[(_x select 0),(_x select 1)]; _weight = (ITEM_WEIGHT(_x select 0)) * (_x select 1); _totalweight = _weight + _totalweight; }; @@ -101,48 +108,47 @@ if (LIFE_SETTINGS(getNumber,"save_vehicle_virtualItems") isEqualTo 1) then { } foreach _itemList; - if (_blacklist) then { - [_uid, _profileName, "481"] remoteExecCall["HC_fnc_wantedAdd", HC_Life]; - _query = format ["UPDATE vehicles SET blacklist='1' WHERE pid='%1' AND plate='%2'", _uid, _plate]; + if (_blacklist) then { + [_uid, _profileName, "481"] remoteExecCall["life_fnc_wantedAdd", RSERV]; + _query = format ["updateVehicleBlacklistPlate:%1:%2", _uid, _plate]; _thread = [_query, 1] call HC_fnc_asyncCall; }; } else { - { - if ((_x select 0) in _resourceItems) then { - _items pushBack[_x select 0,_x select 1]; - _weight = (ITEM_WEIGHT(_x select 0)) * (_x select 1); - _totalweight = _weight + _totalweight; - }; - } - forEach _itemList; + { + if ((_x select 0) in _resourceItems) then { + _items pushBack[(_x select 0),(_x select 1)]; + _weight = (ITEM_WEIGHT(_x select 0)) * (_x select 1); + _totalweight = _weight + _totalweight; + }; + } + forEach _itemList; }; - _trunk = [_items, _totalweight]; - } - else { - _trunk = [[], 0]; - }; + _trunk = [_items, _totalweight]; +} +else { + _trunk = [[], 0]; +}; + +private "_cargo"; + if (LIFE_SETTINGS(getNumber,"save_vehicle_inventory") isEqualTo 1) then { - _vehItems = getItemCargo _vehicle; - _vehMags = getMagazineCargo _vehicle; - _vehWeapons = getWeaponCargo _vehicle; - _vehBackpacks = getBackpackCargo _vehicle; - _cargo = [_vehItems,_vehMags,_vehWeapons,_vehBackpacks]; + private _vehItems = getItemCargo _vehicle; + private _vehMags = getMagazineCargo _vehicle; + private _vehWeapons = getWeaponCargo _vehicle; + private _vehBackpacks = getBackpackCargo _vehicle; + _cargo = [_vehItems, _vehMags, _vehWeapons, _vehBackpacks]; // no items? clean the array so the database looks pretty if (((_vehItems select 0) isEqualTo []) && ((_vehMags select 0) isEqualTo []) && ((_vehWeapons select 0) isEqualTo []) && ((_vehBackpacks select 0) isEqualTo [])) then {_cargo = [];}; } else { _cargo = []; }; -// prepare -_trunk = [_trunk] call HC_fnc_mresArray; -_cargo = [_cargo] call HC_fnc_mresArray; - // update -_query = format ["UPDATE vehicles SET active='0', inventory='%3', gear='%4', fuel='%5', damage='%6' WHERE pid='%1' AND plate='%2'", _uid, _plate, _trunk, _cargo, _fuel, _damage]; +_query = format ["updateVehicleAll:%1:%2:%3:%4:%5:%6", _trunk, _cargo, _fuel, _damage, _uid, _plate]; _thread = [_query,1] call HC_fnc_asyncCall; if (!isNil "_vehicle" && {!isNull _vehicle}) then { @@ -151,4 +157,4 @@ if (!isNil "_vehicle" && {!isNull _vehicle}) then { life_garage_store = false; _ownerID publicVariableClient "life_garage_store"; -[1,_storetext] remoteExecCall ["life_fnc_broadcast",_ownerID]; +[1, _storetext] remoteExecCall ["life_fnc_broadcast", _ownerID]; diff --git a/life_hc/MySQL/Vehicles/fn_vehicleUpdate.sqf b/life_hc/MySQL/Vehicles/fn_vehicleUpdate.sqf old mode 100644 new mode 100755 index 39590e998..d623b2fef --- a/life_hc/MySQL/Vehicles/fn_vehicleUpdate.sqf +++ b/life_hc/MySQL/Vehicles/fn_vehicleUpdate.sqf @@ -8,48 +8,53 @@ Description: Tells the database that this vehicle need update inventory. */ -private ["_vehicle","_plate","_uid","_query","_sql","_dbInfo","_thread","_cargo","_trunk","_resourceItems","_itemList","_totalweight","_weight"]; -_vehicle = [_this,0,objNull,[objNull]] call BIS_fnc_param; -_mode = [_this,1,1,[0]] call BIS_fnc_param; + +params [ + ["_vehicle", objNull, [objNull]], + ["_mode", 1, [0]] +]; + if (isNull _vehicle) exitWith {}; //NULL -_dbInfo = _vehicle getVariable ["dbInfo",[]]; +private _dbInfo = _vehicle getVariable ["dbInfo",[]]; if (_dbInfo isEqualTo []) exitWith {}; -_uid = _dbInfo select 0; -_plate = _dbInfo select 1; + +private _uid = _dbInfo select 0; +private _plate = _dbInfo select 1; + switch (_mode) do { case 1: { - _vehItems = getItemCargo _vehicle; - _vehMags = getMagazineCargo _vehicle; - _vehWeapons = getWeaponCargo _vehicle; - _vehBackpacks = getBackpackCargo _vehicle; - _cargo = [_vehItems,_vehMags,_vehWeapons,_vehBackpacks]; + private _vehItems = getItemCargo _vehicle; + private _vehMags = getMagazineCargo _vehicle; + private _vehWeapons = getWeaponCargo _vehicle; + private _vehBackpacks = getBackpackCargo _vehicle; + private _cargo = [_vehItems,_vehMags,_vehWeapons,_vehBackpacks]; // Keep it clean! - if (((_vehItems select 0) isEqualTo []) && ((_vehMags select 0) isEqualTo []) && ((_vehWeapons select 0) isEqualTo []) && ((_vehBackpacks select 0) isEqualTo [])) then {_cargo = [];}; - - _cargo = [_cargo] call HC_fnc_mresArray; + if (((_vehItems select 0) isEqualTo []) && ((_vehMags select 0) isEqualTo []) && ((_vehWeapons select 0) isEqualTo []) && ((_vehBackpacks select 0) isEqualTo [])) then { + _cargo = []; + }; - _query = format ["UPDATE vehicles SET gear='%3' WHERE pid='%1' AND plate='%2'",_uid,_plate,_cargo]; - _thread = [_query,1] call HC_fnc_asyncCall; + private _query = format ["updateVehicleGear:%1:%2:%3", _cargo, _uid, _plate]; + private _thread = [_query, 1] call HC_fnc_asyncCall; }; case 2: { - _resourceItems = LIFE_SETTINGS(getArray,"save_vehicle_items"); - _trunk = _vehicle getVariable ["Trunk",[[],0]]; - _totalweight = 0; - _items = []; + private _resourceItems = LIFE_SETTINGS(getArray,"save_vehicle_items"); + private _trunk = _vehicle getVariable ["Trunk",[[],0]]; + private _itemList = _trunk select 0; + private _totalweight = 0; + private _items = []; { if ((_x select 0) in _resourceItems) then { - _items pushBack [(_x select 0),(_x select 1)]; - _weight = (ITEM_WEIGHT(_x select 0)) * (_x select 1); + _items pushBack [_x select 0,_x select 1]; + private _weight = (ITEM_WEIGHT(_x select 0)) * (_x select 1); _totalweight = _weight + _totalweight; }; - }forEach (_trunk select 0); + } forEach _itemList; _trunk = [_items,_totalweight]; - _trunk = [_trunk] call HC_fnc_mresArray; - _query = format ["UPDATE vehicles SET inventory='%3' WHERE pid='%1' AND plate='%2'",_uid,_plate,_trunk]; - _thread = [_query,1] call HC_fnc_asyncCall; + private _query = format ["updateVehicleTrunk:%1:%2:%3", _trunk, _uid, _plate]; + private _thread = [_query,1] call HC_fnc_asyncCall; }; }; diff --git a/life_hc/MySQL/WantedSystem/fn_wantedAdd.sqf b/life_hc/MySQL/WantedSystem/fn_wantedAdd.sqf old mode 100644 new mode 100755 index c878dc3c5..5e99e944d --- a/life_hc/MySQL/WantedSystem/fn_wantedAdd.sqf +++ b/life_hc/MySQL/WantedSystem/fn_wantedAdd.sqf @@ -10,88 +10,45 @@ Description: Adds or appends a unit to the wanted list. */ -private ["_uid","_type","_index","_data","_crime","_val","_customBounty","_name","_pastCrimes","_query","_queryResult"]; -_uid = [_this,0,"",[""]] call BIS_fnc_param; -_name = [_this,1,"",[""]] call BIS_fnc_param; -_type = [_this,2,"",[""]] call BIS_fnc_param; -_customBounty = [_this,3,-1,[0]] call BIS_fnc_param; -if (_uid isEqualTo "" || _type isEqualTo "" || _name isEqualTo "") exitWith {}; //Bad data passed. + +params [ + ["_uid","",[""]], + ["_name","",[""]], + ["_type","",[""]], + ["_customBounty",-1,[0]] +]; + +if (_uid isEqualTo "" || {_type isEqualTo ""} || {_name isEqualTo ""}) exitWith {}; //Bad data passed. //What is the crime? -switch (_type) do -{ - case "187V": {_type = ["187V",650]}; - case "187": {_type = ["187",2000]}; - case "901": {_type = ["901",450]}; - case "215": {_type = ["215",200]}; - case "213": {_type = ["213",1000]}; - case "211": {_type = ["211",100]}; - case "207": {_type = ["207",350]}; - case "207A": {_type = ["207A",200]}; - case "390": {_type = ["390",1500]}; - case "487": {_type = ["487",150]}; - case "488": {_type = ["488",70]}; - case "480": {_type = ["480",100]}; - case "481": {_type = ["481",100]}; - case "482": {_type = ["482",500]}; - case "483": {_type = ["483",950]}; - case "459": {_type = ["459",650]}; - case "666": {_type = ["666",200]}; - case "667": {_type = ["667",4500]}; - case "668": {_type = ["668",1500]}; +private _crimesConfig = getArray(missionConfigFile >> "Life_Settings" >> "crimes"); +private _index = [_type, _crimesConfig] call TON_fnc_index; - case "1": {_type = ["1",250]}; - case "2": {_type = ["2",100]}; - case "3": {_type = ["3",75]}; - case "4": {_type = ["4",125]}; - case "5": {_type = ["5",50]}; - case "6": {_type = ["6",40]}; - case "7": {_type = ["7",75]}; - case "8": {_type = ["8",2500]}; - case "9": {_type = ["9",2500]}; - case "10": {_type = ["10",7500]}; - case "11": {_type = ["11",5000]}; - case "12": {_type = ["12",1250]}; - case "13": {_type = ["13",750]}; - case "14": {_type = ["14",250]}; - case "15": {_type = ["15",1250]}; - case "16": {_type = ["16",750]}; - case "17": {_type = ["17",50]}; - case "18": {_type = ["18",750]}; - case "19": {_type = ["19",1250]}; - case "20": {_type = ["20",250]}; - case "21": {_type = ["21",250]}; - case "22": {_type = ["22",1000]}; - case "23": {_type = ["23",2500]}; - case "24": {_type = ["24",5000]}; - case "25": {_type = ["25",10000]}; - default {_type = [];}; -}; +if (_index isEqualTo -1) exitWith {}; + +_type = [_type, parseNumber ((_crimesConfig select _index) select 1)]; if (_type isEqualTo []) exitWith {}; //Not our information being passed... //Is there a custom bounty being sent? Set that as the pricing. if !(_customBounty isEqualTo -1) then {_type set[1,_customBounty];}; //Search the wanted list to make sure they are not on it. -_query = format ["SELECT wantedID FROM wanted WHERE wantedID='%1'",_uid]; -_queryResult = [_query,2,true] call HC_fnc_asyncCall; -_val = [_type select 1] call HC_fnc_numberSafe; -_number = _type select 0; +private _query = format ["selectWantedID:%1", _uid]; +private _queryResult = [_query,2,true] call HC_fnc_asyncCall; +private _val = _type select 1; +private _number = _type select 0; + +if !(_queryResult isEqualTo []) then { + _query = format ["selectWantedCrimes:%1", _uid]; + _queryResult = [_query,2] call HC_fnc_asyncCall; + _pastCrimes = _queryResult select 0; -if !(count _queryResult isEqualTo 0) then -{ - _crime = format ["SELECT wantedCrimes, wantedBounty FROM wanted WHERE wantedID='%1'",_uid]; - _crimeresult = [_crime,2] call HC_fnc_asyncCall; - _pastcrimess = [_crimeresult select 0] call HC_fnc_mresToArray; - if (_pastcrimess isEqualType "") then {_pastcrimess = call compile format ["%1", _pastcrimess];}; - _pastCrimes = _pastcrimess; + if (_pastCrimes isEqualType "") then {_pastCrimes = call compile format ["%1", _pastCrimes];}; _pastCrimes pushBack _number; - _pastCrimes = [_pastCrimes] call HC_fnc_mresArray; - _query = format ["UPDATE wanted SET wantedCrimes = '%1', wantedBounty = wantedBounty + '%2', active = '1' WHERE wantedID='%3'",_pastCrimes,_val,_uid]; + _query = format ["updateWanted:%1:%2:%3", _pastCrimes, _val, _uid]; [_query,1] call HC_fnc_asyncCall; } else { _crime = [_type select 0]; - _crime = [_crime] call HC_fnc_mresArray; - _query = format ["INSERT INTO wanted (wantedID, wantedName, wantedCrimes, wantedBounty, active) VALUES('%1', '%2', '%3', '%4', '1')",_uid,_name,_crime,_val]; + _query = format ["insertWanted:%1:%2:%3:%4", _uid, _name, _crime, _val]; [_query,1] call HC_fnc_asyncCall; }; diff --git a/life_hc/MySQL/WantedSystem/fn_wantedBounty.sqf b/life_hc/MySQL/WantedSystem/fn_wantedBounty.sqf old mode 100644 new mode 100755 index 9096a2ef4..7c99d2219 --- a/life_hc/MySQL/WantedSystem/fn_wantedBounty.sqf +++ b/life_hc/MySQL/WantedSystem/fn_wantedBounty.sqf @@ -10,24 +10,27 @@ Description: Checks if the person is on the bounty list and awards the cop for killing them. */ -private ["_civ","_cop","_id","_half","_result","_queryResult","_amount"]; -_uid = [_this,0,"",[""]] call BIS_fnc_param; -_civ = [_this,1,objNull,[objNull]] call BIS_fnc_param; -_cop = [_this,2,objNull,[objNull]] call BIS_fnc_param; -_half = [_this,3,false,[false]] call BIS_fnc_param; -if (isNull _civ || isNull _cop) exitWith {}; -_query = format ["SELECT wantedID, wantedName, wantedCrimes, wantedBounty FROM wanted WHERE active='1' AND wantedID='%1'",_uid]; -_queryResult = [_query,2] call HC_fnc_asyncCall; +params [ + ["_uid","",[""]], + ["_civ",objNull,[objNull]], + ["_cop",objNull,[objNull]], + ["_half",false,[false]] +]; -if !(count _queryResult isEqualTo 0) then -{ - _amount = _queryResult select 3; +if (isNull _civ || {isNull _cop}) exitWith {}; + +private _query = format ["selectWanted:%1", _uid]; +private _queryResult = [_query,2] call HC_fnc_asyncCall; + +private "_amount"; +if !(_queryResult isEqualTo []) then { + _amount = _queryResult param [3]; if !(_amount isEqualTo 0) then { if (_half) then { - [((_amount) / 2),_amount] remoteExecCall ["life_fnc_bountyReceive",_cop]; + [((_amount) / 2),_amount] remoteExecCall ["life_fnc_bountyReceive", _cop]; } else { - [_amount,_amount] remoteExecCall ["life_fnc_bountyReceive",_cop]; + [_amount,_amount] remoteExecCall ["life_fnc_bountyReceive", _cop]; }; }; }; diff --git a/life_hc/MySQL/WantedSystem/fn_wantedCrimes.sqf b/life_hc/MySQL/WantedSystem/fn_wantedCrimes.sqf old mode 100644 new mode 100755 index 90722f07a..212ba7341 --- a/life_hc/MySQL/WantedSystem/fn_wantedCrimes.sqf +++ b/life_hc/MySQL/WantedSystem/fn_wantedCrimes.sqf @@ -10,71 +10,27 @@ Description: Grabs a list of crimes committed by a person. */ -private ["_display","_criminal","_tab","_queryResult","_result","_ret","_crimesDb","_crimesArr","_type"]; + disableSerialization; -_ret = [_this,0,objNull,[objNull]] call BIS_fnc_param; -_criminal = [_this,1,[],[]] call BIS_fnc_param; -_query = format ["SELECT wantedCrimes, wantedBounty FROM wanted WHERE active='1' AND wantedID='%1'",_criminal select 0]; -_queryResult = [_query,2] call HC_fnc_asyncCall; +params [ + ["_ret",objNull,[objNull]], + ["_criminal",[],[]] +]; -_crimesArr = []; +private _query = format ["selectWantedActive:%1", _criminal select 0]; +private _queryResult = [_query, 2] call HC_fnc_asyncCall; -_type = [_queryResult select 0] call HC_fnc_mresToArray; +private _type = _queryResult select 0; if (_type isEqualType "") then {_type = call compile format ["%1", _type];}; + +private _crimesArr = []; { - switch (_x) do - { - case "187V": {_x = "STR_Crime_187V"}; - case "187": {_x = "STR_Crime_187"}; - case "901": {_x = "STR_Crime_901"}; - case "215": {_x = "STR_Crime_215"}; - case "213": {_x = "STR_Crime_213"}; - case "211": {_x = "STR_Crime_211"}; - case "207": {_x = "STR_Crime_207"}; - case "207A": {_x = "STR_Crime_207A"}; - case "390": {_x = "STR_Crime_390"}; - case "487": {_x = "STR_Crime_487"}; - case "488": {_x = "STR_Crime_488"}; - case "480": {_x = "STR_Crime_480"}; - case "481": {_x = "STR_Crime_481"}; - case "482": {_x = "STR_Crime_482"}; - case "483": {_x = "STR_Crime_483"}; - case "459": {_x = "STR_Crime_459"}; - case "666": {_x = "STR_Crime_666"}; - case "667": {_x = "STR_Crime_667"}; - case "668": {_x = "STR_Crime_668"}; - case "919": {_x = "STR_Crime_919"}; - case "919A": {_x = "STR_Crime_919A"}; + private _str = format ["STR_Crime_%1", _x]; + _crimesArr pushBack _str; + false +} count _type; - case "1": {_x = "STR_Crime_1"}; - case "2": {_x = "STR_Crime_2"}; - case "3": {_x = "STR_Crime_3"}; - case "4": {_x = "STR_Crime_4"}; - case "5": {_x = "STR_Crime_5"}; - case "6": {_x = "STR_Crime_6"}; - case "7": {_x = "STR_Crime_7"}; - case "8": {_x = "STR_Crime_8"}; - case "9": {_x = "STR_Crime_9"}; - case "10": {_x = "STR_Crime_10"}; - case "11": {_x = "STR_Crime_11"}; - case "12": {_x = "STR_Crime_12"}; - case "13": {_x = "STR_Crime_13"}; - case "14": {_x = "STR_Crime_14"}; - case "15": {_x = "STR_Crime_15"}; - case "16": {_x = "STR_Crime_16"}; - case "17": {_x = "STR_Crime_17"}; - case "18": {_x = "STR_Crime_18"}; - case "19": {_x = "STR_Crime_19"}; - case "20": {_x = "STR_Crime_20"}; - case "21": {_x = "STR_Crime_21"}; - case "22": {_x = "STR_Crime_22"}; - case "23": {_x = "STR_Crime_23"}; - case "24": {_x = "STR_Crime_24"}; - case "25": {_x = "STR_Crime_25"}; - }; - _crimesArr pushBack _x; -}forEach _type; -_queryResult set[0,_crimesArr]; +_queryResult set[0, _crimesArr]; -[_queryResult] remoteExec ["life_fnc_wantedInfo",_ret]; +[_queryResult] remoteExec ["life_fnc_wantedInfo", _ret]; diff --git a/life_hc/MySQL/WantedSystem/fn_wantedFetch.sqf b/life_hc/MySQL/WantedSystem/fn_wantedFetch.sqf old mode 100644 new mode 100755 index 40e66bdf0..8d18d4b72 --- a/life_hc/MySQL/WantedSystem/fn_wantedFetch.sqf +++ b/life_hc/MySQL/WantedSystem/fn_wantedFetch.sqf @@ -11,39 +11,43 @@ Description: Displays wanted list information sent from the server. */ -private ["_ret","_list","_result","_queryResult","_units","_inStatement"]; -_ret = [_this,0,objNull,[objNull]] call BIS_fnc_param; + +params [ + ["_ret", objNull, [objNull]] +]; + if (isNull _ret) exitWith {}; -_inStatement = ""; -_list = []; -_units = []; -{if ((side _x) isEqualTo civilian) then {_units pushBack (getPlayerUID _x)};} forEach playableUnits; + +private _inStatement = ""; +private _list = []; +private _units = []; +{ + if (side _x isEqualTo civilian) then {_units pushBack (getPlayerUID _x)}; + false +} count playableUnits; if (_units isEqualTo []) exitWith {[_list] remoteExec ["life_fnc_wantedList",_ret];}; { if (count _units > 1) then { - if (_inStatement isEqualTo "") then { + if (_inStatement isEqualTo "") then { _inStatement = "'" + _x + "'"; } else { _inStatement = _inStatement + ", '" + _x + "'"; }; } else { - _inStatement = _x; + _inStatement = _x; }; } forEach _units; -_query = format ["SELECT wantedID, wantedName FROM wanted WHERE active='1' AND wantedID in (%1)",_inStatement]; -_queryResult = [_query,2,true] call HC_fnc_asyncCall; - -diag_log format ["Query: %1",_query]; - +private _query = format ["selectWantedActiveID:%1", _inStatement]; +private _queryResult = [_query, 2, true] call HC_fnc_asyncCall; { - _list pushBack (_x); -} -forEach _queryResult; + _list pushBack _x; + false +} count _queryResult; -if (_list isEqualTo []) exitWith {[_list] remoteExec ["life_fnc_wantedList",_ret];}; +if (_list isEqualTo []) exitWith {[_list] remoteExec ["life_fnc_wantedList", _ret];}; -[_list] remoteExec ["life_fnc_wantedList",_ret]; +[_list] remoteExec ["life_fnc_wantedList", _ret]; diff --git a/life_hc/MySQL/WantedSystem/fn_wantedPerson.sqf b/life_hc/MySQL/WantedSystem/fn_wantedPerson.sqf old mode 100644 new mode 100755 index c1ffdf50b..383c96fa2 --- a/life_hc/MySQL/WantedSystem/fn_wantedPerson.sqf +++ b/life_hc/MySQL/WantedSystem/fn_wantedPerson.sqf @@ -10,12 +10,16 @@ Description: Fetches a specific person from the wanted array. */ -private ["_unit","_index","_queryResult","_result"]; -_unit = [_this,0,objNull,[objNull]] call BIS_fnc_param; + +params [ + ["_unit", objNull, [objNull]] +]; + if (isNull _unit) exitWith {[]}; -_uid = getPlayerUID player; -_query = format ["SELECT wantedID, wantedName, wantedBounty FROM wanted WHERE active='1' AND wantedID='%1'",_uid]; -_queryResult = [_query,2] call HC_fnc_asyncCall; +private _uid = getPlayerUID _unit; +private _query = format ["selectWantedBounty:%1", _uid]; +private _queryResult = [_query,2] call HC_fnc_asyncCall; + if (_queryResult isEqualTo []) exitWith {[]}; _queryResult; diff --git a/life_hc/MySQL/WantedSystem/fn_wantedProfUpdate.sqf b/life_hc/MySQL/WantedSystem/fn_wantedProfUpdate.sqf old mode 100644 new mode 100755 index 3daa31ea9..f74adc3ad --- a/life_hc/MySQL/WantedSystem/fn_wantedProfUpdate.sqf +++ b/life_hc/MySQL/WantedSystem/fn_wantedProfUpdate.sqf @@ -9,19 +9,20 @@ Description: Updates name of player if they change profiles */ -private ["_uid","_name","_query","_tickTime","_wantedCheck","_wantedQuery"]; -_uid = [_this,0,"",[""]] call BIS_fnc_param; -_name = [_this,1,"",[""]] call BIS_fnc_param; +params [ + ["_uid","",[""]], + ["_name","",[""]] +]; + //Bad data check -if (_uid isEqualTo "" || _name isEqualTo "") exitWith {}; +if (_uid isEqualTo "" || {_name isEqualTo ""}) exitWith {}; -_wantedCheck = format ["SELECT wantedName FROM wanted WHERE wantedID='%1'",_uid]; -_wantedQuery = [_wantedCheck,2] call HC_fnc_asyncCall; +private _wantedCheck = format ["selectWantedName:%1", _uid]; +private _wantedQuery = [_wantedCheck, 2] call HC_fnc_asyncCall; if (_wantedQuery isEqualTo []) exitWith {}; -_wantedQuery = call compile format ["%1",_wantedQuery]; if !(_name isEqualTo (_wantedQuery select 0)) then { - _query = format ["UPDATE wanted SET wantedName='%1' WHERE wantedID='%2'",_name,_uid]; - [_query,2] call HC_fnc_asyncCall; + private _query = format ["updateWantedName:%1:%2", _name, _uid]; + [_query, 2] call HC_fnc_asyncCall; }; diff --git a/life_hc/MySQL/WantedSystem/fn_wantedRemove.sqf b/life_hc/MySQL/WantedSystem/fn_wantedRemove.sqf old mode 100644 new mode 100755 index 677047ade..4c2bca12c --- a/life_hc/MySQL/WantedSystem/fn_wantedRemove.sqf +++ b/life_hc/MySQL/WantedSystem/fn_wantedRemove.sqf @@ -10,9 +10,12 @@ Description: Removes a person from the wanted list. */ -private ["_uid","_query"]; -_uid = [_this,0,"",[""]] call BIS_fnc_param; + +params [ + ["_uid", "", [""]] +]; + if (_uid isEqualTo "") exitWith {}; //Bad data -_query = format ["UPDATE wanted SET active = '0', wantedCrimes = '[]', wantedBounty = 0 WHERE wantedID='%1'",_uid]; -[_query,2] call HC_fnc_asyncCall; +private _query = format ["deleteWanted:%1", _uid]; +[_query, 2] call HC_fnc_asyncCall; diff --git a/life_hc/config.cpp b/life_hc/config.cpp old mode 100644 new mode 100755 index 3478c4f4a..1d1f4a057 --- a/life_hc/config.cpp +++ b/life_hc/config.cpp @@ -24,13 +24,8 @@ class CfgFunctions { file = "\life_hc\MySQL\General"; class asyncCall {}; - class bool {}; class insertRequest {}; class insertVehicle {}; - class mresArray {}; - class mresString {}; - class mresToArray {}; - class numberSafe {}; class queryRequest {}; class updatePartial {}; class updateRequest {}; @@ -53,6 +48,7 @@ class CfgFunctions class addHouse {}; class deleteDBContainer {}; class fetchPlayerHouses {}; + class houseCleanup {}; class sellHouse {}; class sellHouseContainer {}; class updateHouseContainers {}; diff --git a/life_hc/initHC.sqf b/life_hc/initHC.sqf index ed820d00a..916ff8d5f 100644 --- a/life_hc/initHC.sqf +++ b/life_hc/initHC.sqf @@ -21,7 +21,7 @@ if (isNil {uiNamespace getVariable "life_sql_id"}) then { try { _result = EXTDB format ["9:ADD_DATABASE:%1",EXTDB_SETTING(getText,"DatabaseName")]; if (!(_result isEqualTo "[1]")) then {throw "extDB3: Error with Database Connection"}; - _result = EXTDB format ["9:ADD_DATABASE_PROTOCOL:%2:SQL:%1:TEXT2",FETCH_CONST(life_sql_id),EXTDB_SETTING(getText,"DatabaseName")]; + _result = EXTDB format ["9:ADD_DATABASE_PROTOCOL:%2:SQL_CUSTOM:%1:AL.ini",FETCH_CONST(life_sql_id),EXTDB_SETTING(getText,"DatabaseName")]; if (!(_result isEqualTo "[1]")) then {throw "extDB3: Error with Database Connection"}; } catch { diag_log _exception; @@ -48,10 +48,10 @@ if (_extDBNotLoaded isEqualType []) then { if (_extDBNotLoaded isEqualType []) exitWith {}; //extDB3-HC did not fully initialize so terminate the rest of the initialization process. -["CALL resetLifeVehicles",1] call HC_fnc_asyncCall; -["CALL deleteDeadVehicles",1] call HC_fnc_asyncCall; -["CALL deleteOldHouses",1] call HC_fnc_asyncCall; -["CALL deleteOldGangs",1] call HC_fnc_asyncCall; +["resetLifeVehicles", 1] call DB_fnc_asyncCall; +["deleteDeadVehicles", 1] call DB_fnc_asyncCall; +["deleteOldHouses", 1] call DB_fnc_asyncCall; +["deleteOldGangs", 1] call DB_fnc_asyncCall; _timeStamp = diag_tickTime; diag_log "----------------------------------------------------------------------------------------------------"; diff --git a/life_server/FSM/cleanup.fsm b/life_server/FSM/cleanup.fsm old mode 100644 new mode 100755 index 7ea28061e..6e28987f3 --- a/life_server/FSM/cleanup.fsm +++ b/life_server/FSM/cleanup.fsm @@ -91,7 +91,7 @@ class FSM " _uid = _dbInfo select 0;" \n " _plate = _dbInfo select 1;" \n "" \n - " _query = format [""UPDATE vehicles SET alive='0' WHERE pid='%1' AND plate='%2'"",_uid,_plate];" \n + " _query = format [""deleteVehicle:%1:%2"", _uid, _plate];" \n " _query spawn {" \n " " \n " _thread = [_this,1] call DB_fnc_asyncCall;" \n @@ -110,7 +110,7 @@ class FSM " _uid = _dbInfo select 0;" \n " _plate = _dbInfo select 1;" \n "" \n - " _query = format [""UPDATE vehicles SET alive='0' WHERE pid='%1' AND plate='%2'"",_uid,_plate];" \n + " _query = format [""deleteVehicle:%1:%2"", _uid, _plate];" \n " _query spawn {" \n " " \n " _thread = [_this,1] call DB_fnc_asyncCall;" \n diff --git a/life_server/Functions/Gangs/fn_insertGang.sqf b/life_server/Functions/Gangs/fn_insertGang.sqf old mode 100644 new mode 100755 index 784b1229a..bea490774 --- a/life_server/Functions/Gangs/fn_insertGang.sqf +++ b/life_server/Functions/Gangs/fn_insertGang.sqf @@ -6,64 +6,65 @@ Description: Inserts the gang into the database. */ -private ["_query","_queryResult","_gangMembers","_group"]; + params [ - ["_ownerID",objNull,[objNull]], - ["_uid","",[""]], - ["_gangName","",[""]] + ["_ownerID", objNull, [objNull]], + ["_uid", "", [""]], + ["_gangName", "", [""]] ]; -_group = group _ownerID; -if (isNull _ownerID || _uid isEqualTo "" || _gangName isEqualTo "") exitWith {}; //Fail +private _group = group _ownerID; + +if (isNull _ownerID || {_uid isEqualTo ""} || {_gangName isEqualTo ""}) exitWith {}; _ownerID = owner _ownerID; -_gangName = [_gangName] call DB_fnc_mresString; -_query = format ["SELECT id FROM gangs WHERE name='%1' AND active='1'",_gangName]; +private _query = format ["selectGangID:%1", _gangName]; -_queryResult = [_query,2] call DB_fnc_asyncCall; +private _queryResult = [_query, 2] call DB_fnc_asyncCall; //Check to see if the gang name already exists. -if (!(count _queryResult isEqualTo 0)) exitWith { - [1,"There is already a gang created with that name please pick another name."] remoteExecCall ["life_fnc_broadcast",_ownerID]; +if !(_queryResult isEqualTo []) exitWith { + [1, "There is already a gang created with that name please pick another name."] remoteExecCall ["life_fnc_broadcast", _ownerID]; life_action_gangInUse = nil; _ownerID publicVariableClient "life_action_gangInUse"; }; -_query = format ["SELECT id FROM gangs WHERE members LIKE '%2%1%2' AND active='1'",_uid,"%"]; +private _uidLike = format["%2%1%2", _uid, "%"]; +_query = format ["selectGangIDFromMembers:%1", _uidLike]; -_queryResult = [_query,2] call DB_fnc_asyncCall; +_queryResult = [_query,2 ] call DB_fnc_asyncCall; //Check to see if this person already owns or belongs to a gang. if (!(count _queryResult isEqualTo 0)) exitWith { - [1,"You are currently already active in a gang, please leave the gang first."] remoteExecCall ["life_fnc_broadcast",_ownerID]; + [1, "You are currently already active in a gang, please leave the gang first."] remoteExecCall ["life_fnc_broadcast", _ownerID]; life_action_gangInUse = nil; _ownerID publicVariableClient "life_action_gangInUse"; }; //Check to see if a gang with that name already exists but is inactive. -_query = format ["SELECT id, active FROM gangs WHERE name='%1' AND active='0'",_gangName]; +_query = format ["selectInactiveGang:%1", _gangName]; -_queryResult = [_query,2] call DB_fnc_asyncCall; -_gangMembers = [[_uid]] call DB_fnc_mresArray; +_queryResult = [_query, 2] call DB_fnc_asyncCall; +private _gangMembers = [_uid]; -if (!(count _queryResult isEqualTo 0)) then { - _query = format ["UPDATE gangs SET active='1', owner='%1',members='%2' WHERE id='%3'",_uid,_gangMembers,(_queryResult select 0)]; +if !(_queryResult isEqualTo []) then { + _query = format ["updateGang:%1:%2:%3", (_queryResult select 0), _gangMembers, _uid]; } else { - _query = format ["INSERT INTO gangs (owner, name, members) VALUES('%1','%2','%3')",_uid,_gangName,_gangMembers]; + _query = format ["insertGang:%1:%2:%3", _uid, _gangName, _gangMembers]; }; -_queryResult = [_query,1] call DB_fnc_asyncCall; +_queryResult = [_query, 1] call DB_fnc_asyncCall; -_group setVariable ["gang_name",_gangName,true]; -_group setVariable ["gang_owner",_uid,true]; -_group setVariable ["gang_bank",0,true]; -_group setVariable ["gang_maxMembers",8,true]; -_group setVariable ["gang_members",[_uid],true]; -[_group] remoteExecCall ["life_fnc_gangCreated",_ownerID]; +_group setVariable ["gang_name", _gangName, true]; +_group setVariable ["gang_owner", _uid, true]; +_group setVariable ["gang_bank", 0, true]; +_group setVariable ["gang_maxMembers", 8, true]; +_group setVariable ["gang_members", [_uid], true]; +[_group] remoteExecCall ["life_fnc_gangCreated", _ownerID]; uiSleep 0.35; -_query = format ["SELECT id FROM gangs WHERE owner='%1' AND active='1'",_uid]; +_query = format ["selectGangIDFromOwner:%1", _uid]; -_queryResult = [_query,2] call DB_fnc_asyncCall; +_queryResult = [_query, 2] call DB_fnc_asyncCall; -_group setVariable ["gang_id",(_queryResult select 0),true]; +_group setVariable ["gang_id", (_queryResult select 0), true]; diff --git a/life_server/Functions/Gangs/fn_queryPlayerGang.sqf b/life_server/Functions/Gangs/fn_queryPlayerGang.sqf old mode 100644 new mode 100755 index 36f6a7526..35313845e --- a/life_server/Functions/Gangs/fn_queryPlayerGang.sqf +++ b/life_server/Functions/Gangs/fn_queryPlayerGang.sqf @@ -5,15 +5,9 @@ Description: Queries to see if the player belongs to any gang. */ -private ["_query","_queryResult"]; -_query = format ["SELECT id, owner, name, maxmembers, bank, members FROM gangs WHERE active='1' AND members LIKE '%2%1%2'",_this,"%"]; +private _pid = format ["%2%1%2", _this, "%"]; +private _query = format ["selectPlayerGang:%1", _pid]; +private _queryResult = [_query, 2] call DB_fnc_asyncCall; -_queryResult = [_query,2] call DB_fnc_asyncCall; - -if !(count _queryResult isEqualTo 0) then { - _tmp = [_queryResult select 5] call DB_fnc_mresToArray; - if (_tmp isEqualType "") then {_tmp = call compile format ["%1", _tmp];}; - _queryResult set[5, _tmp]; -}; -missionNamespace setVariable [format ["gang_%1",_this],_queryResult]; +missionNamespace setVariable [format ["gang_%1", _this], _queryResult]; diff --git a/life_server/Functions/Gangs/fn_removeGang.sqf b/life_server/Functions/Gangs/fn_removeGang.sqf old mode 100644 new mode 100755 index fafb7a70d..b4c01bd07 --- a/life_server/Functions/Gangs/fn_removeGang.sqf +++ b/life_server/Functions/Gangs/fn_removeGang.sqf @@ -6,19 +6,22 @@ Description: Removes gang from database */ -private ["_group","_groupID"]; -_group = param [0,grpNull,[grpNull]]; + +params [ + ["_group", grpNull, [grpNull]] +]; + if (isNull _group) exitWith {}; -_groupID = _group getVariable ["gang_id",-1]; +private _groupID = _group getVariable ["gang_id",-1]; if (_groupID isEqualTo -1) exitWith {}; -[format ["UPDATE gangs SET active='0' WHERE id='%1'",_groupID],1] call DB_fnc_asyncCall; +[format ["deleteGang:%1", _groupID], 1] call DB_fnc_asyncCall; -_result = [format ["SELECT id FROM gangs WHERE active='1' AND id='%1'",_groupID],2] call DB_fnc_asyncCall; -if (count _result isEqualTo 0) then { +_result = [format ["selectGang:%1", _groupID], 2] call DB_fnc_asyncCall; +if (_result isEqualTo []) then { [_group] remoteExecCall ["life_fnc_gangDisbanded",(units _group)]; uiSleep 5; deleteGroup _group; }; -["CALL deleteOldGangs",1] call DB_fnc_asyncCall; +["deleteOldGangs", 1] call DB_fnc_asyncCall; diff --git a/life_server/Functions/Gangs/fn_updateGang.sqf b/life_server/Functions/Gangs/fn_updateGang.sqf old mode 100644 new mode 100755 index a8815996b..6263a09df --- a/life_server/Functions/Gangs/fn_updateGang.sqf +++ b/life_server/Functions/Gangs/fn_updateGang.sqf @@ -1,4 +1,3 @@ -#include "\life_server\script_macros.hpp" /* File: fn_updateGang.sqf Author: Bryan "Tonic" Boardwine @@ -6,78 +5,48 @@ Description: Updates the gang information? */ -private ["_groupID","_bank","_maxMembers","_members","_membersFinal","_query","_owner"]; + params [ - ["_mode",0,[0]], - ["_group",grpNull,[grpNull]] + ["_mode", 0, [0]], + ["_group", grpNull, [grpNull]] ]; if (isNull _group) exitWith {}; //FAIL -_groupID = _group getVariable ["gang_id",-1]; +private _groupID = _group getVariable ["gang_id", -1]; if (_groupID isEqualTo -1) exitWith {}; +private "_query"; + switch (_mode) do { case 0: { - _bank = [(_group getVariable ["gang_bank",0])] call DB_fnc_numberSafe; - _maxMembers = _group getVariable ["gang_maxMembers",8]; - _members = [(_group getVariable "gang_members")] call DB_fnc_mresArray; - _owner = _group getVariable ["gang_owner",""]; + private _bank = _group getVariable ["gang_bank", 0]; + private _maxMembers = _group getVariable ["gang_maxMembers", 8]; + private _members = _group getVariable "gang_members"; + private _owner = _group getVariable ["gang_owner", ""]; if (_owner isEqualTo "") exitWith {}; - _query = format ["UPDATE gangs SET bank='%1', maxmembers='%2', owner='%3' WHERE id='%4'",_bank,_maxMembers,_owner,_groupID]; + _query = format ["updateGang1:%1:%2:%3:%4", _bank, _maxMembers, _owner, _groupID]; }; case 1: { - params [ - "", - "", - ["_deposit",false,[false]], - ["_value",0,[0]], - ["_unit",objNull,[objNull]], - ["_cash",0,[0]] - ]; - - private _funds = _group getVariable ["gang_bank",0]; - if (_deposit) then { - _funds = _funds + _value; - _group setVariable ["gang_bank",_funds,true]; - [1,"STR_ATM_DepositSuccessG",true,[_value]] remoteExecCall ["life_fnc_broadcast",remoteExecutedOwner]; - _cash = _cash - _value; - } else { - if (_value > _funds) exitWith { - [1,"STR_ATM_NotEnoughFundsG",true] remoteExecCall ["life_fnc_broadcast",remoteExecutedOwner]; - breakOut ""; - }; - _funds = _funds - _value; - _group setVariable ["gang_bank",_funds,true]; - [_value] remoteExecCall ["life_fnc_gangBankResponse",remoteExecutedOwner]; - _cash = _cash + _value; - }; - if (LIFE_SETTINGS(getNumber,"player_moneyLog") isEqualTo 1) then { - if (LIFE_SETTINGS(getNumber,"battlEye_friendlyLogging") isEqualTo 1) then { - diag_log (format [localize "STR_DL_ML_withdrewGang_BEF",_value,[_funds] call life_fnc_numberText,[0] call life_fnc_numberText,[_cash] call life_fnc_numberText]); - } else { - diag_log (format [localize "STR_DL_ML_withdrewGang",name _unit,(getPlayerUID _unit),_value,[_funds] call life_fnc_numberText,[0] call life_fnc_numberText,[_cash] call life_fnc_numberText]); - }; - }; - _query = format ["UPDATE gangs SET bank='%1' WHERE id='%2'",([_funds] call DB_fnc_numberSafe),_groupID]; - [getPlayerUID _unit,side _unit,_cash,0] call DB_fnc_updatePartial; + _query = format ["updateGangBank:%1:%2", _group getVariable ["gang_bank", 0], _groupID]; }; case 2: { - _query = format ["UPDATE gangs SET maxmembers='%1' WHERE id='%2'",(_group getVariable ["gang_maxMembers",8]),_groupID]; + _query = format ["updateGangMaxmembers:%1:%2", (_group getVariable ["gang_maxMembers", 8]), _groupID]; }; case 3: { - _owner = _group getVariable ["gang_owner",""]; + private _owner = _group getVariable ["gang_owner", ""]; if (_owner isEqualTo "") exitWith {}; - _query = format ["UPDATE gangs SET owner='%1' WHERE id='%2'",_owner,_groupID]; + _query = format ["updateGangOwner:%1:%2", _owner, _groupID]; }; case 4: { - _members = _group getVariable "gang_members"; - if (count _members > (_group getVariable ["gang_maxMembers",8])) then { + private _members = _group getVariable "gang_members"; + private "_membersFinal"; + if (count _members > (_group getVariable ["gang_maxMembers", 8])) then { _membersFinal = []; for "_i" from 0 to _maxMembers -1 do { _membersFinal pushBack (_members select _i); @@ -85,11 +54,10 @@ switch (_mode) do { } else { _membersFinal = _group getVariable "gang_members"; }; - _membersFinal = [_membersFinal] call DB_fnc_mresArray; - _query = format ["UPDATE gangs SET members='%1' WHERE id='%2'",_membersFinal,_groupID]; + _query = format ["updateGangMembers:%1:%2", _membersFinal, _groupID]; }; }; if (!isNil "_query") then { - [_query,1] call DB_fnc_asyncCall; + [_query, 1] call DB_fnc_asyncCall; }; diff --git a/life_server/Functions/Housing/fn_addContainer.sqf b/life_server/Functions/Housing/fn_addContainer.sqf old mode 100644 new mode 100755 index e7a999ac3..a3962cece --- a/life_server/Functions/Housing/fn_addContainer.sqf +++ b/life_server/Functions/Housing/fn_addContainer.sqf @@ -6,28 +6,27 @@ Description: Add container in Database. */ -private ["_containerPos","_query","_className","_dir"]; + params [ - ["_uid","",[""]], - ["_container",objNull,[objNull]] + ["_uid", "", [""]], + ["_container", objNull, [objNull]] ]; -if (isNull _container || _uid isEqualTo "") exitWith {}; +if (isNull _container || {_uid isEqualTo ""}) exitWith {}; -_containerPos = getPosATL _container; -_className = typeOf _container; -_dir = [vectorDir _container, vectorUp _container]; +private _containerPos = getPosATL _container; +private _className = typeOf _container; +private _dir = [vectorDir _container, vectorUp _container]; -_query = format ["INSERT INTO containers (pid, pos, classname, inventory, gear, owned, dir) VALUES('%1', '%2', '%3', '""[[],0]""', '""[]""', '1', '%4')",_uid,_containerPos,_className,_dir]; +private _query = format ["insertContainer:%1:%2:%3:%4", _uid, _containerPos, _className, _dir]; if (EXTDB_SETTING(getNumber,"DebugMode") isEqualTo 1) then { - diag_log format ["Query: %1",_query]; + diag_log format ["Query: %1", _query]; }; -[_query,1] call DB_fnc_asyncCall; +[_query, 1] call DB_fnc_asyncCall; uiSleep 0.3; -_query = format ["SELECT id FROM containers WHERE pos='%1' AND pid='%2' AND owned='1'",_containerPos,_uid]; -_queryResult = [_query,2] call DB_fnc_asyncCall; -//systemChat format ["House ID assigned: %1",_queryResult select 0]; -_container setVariable ["container_id",(_queryResult select 0),true]; +_query = format ["selectContainerID:%1:%2", _containerPos, _uid]; +_queryResult = [_query, 2] call DB_fnc_asyncCall; +_container setVariable ["container_id", _queryResult select 0, true]; diff --git a/life_server/Functions/Housing/fn_addHouse.sqf b/life_server/Functions/Housing/fn_addHouse.sqf old mode 100644 new mode 100755 index 6c4aa62cf..de33fbb96 --- a/life_server/Functions/Housing/fn_addHouse.sqf +++ b/life_server/Functions/Housing/fn_addHouse.sqf @@ -6,25 +6,26 @@ Description: Inserts the players newly bought house in the database. */ -private ["_housePos","_query"]; + params [ ["_uid","",[""]], ["_house",objNull,[objNull]] ]; -if (isNull _house || _uid isEqualTo "") exitWith {}; -_housePos = getPosATL _house; +if (isNull _house || {_uid isEqualTo ""}) exitWith {}; + +private _housePos = getPosATL _house; -_query = format ["INSERT INTO houses (pid, pos, owned) VALUES('%1', '%2', '1')",_uid,_housePos]; +private _query = format ["insertHouse:%1:%2", _uid, _housePos]; if (EXTDB_SETTING(getNumber,"DebugMode") isEqualTo 1) then { diag_log format ["Query: %1",_query]; }; -[_query,1] call DB_fnc_asyncCall; +[_query, 1] call DB_fnc_asyncCall; uiSleep 0.3; -_query = format ["SELECT id FROM houses WHERE pos='%1' AND pid='%2' AND owned='1'",_housePos,_uid]; -_queryResult = [_query,2] call DB_fnc_asyncCall; -//systemChat format ["House ID assigned: %1",_queryResult select 0]; -_house setVariable ["house_id",(_queryResult select 0),true]; +_query = format ["selectHouseID:%1:%2", _housePos, _uid]; +_queryResult = [_query, 2] call DB_fnc_asyncCall; +//systemChat format ["House ID assigned: %1", _queryResult select 0]; +_house setVariable ["house_id", _queryResult select 0, true]; diff --git a/life_server/Functions/Housing/fn_deleteDBContainer.sqf b/life_server/Functions/Housing/fn_deleteDBContainer.sqf old mode 100644 new mode 100755 index df05d16b3..99aa5d9b2 --- a/life_server/Functions/Housing/fn_deleteDBContainer.sqf +++ b/life_server/Functions/Housing/fn_deleteDBContainer.sqf @@ -5,24 +5,27 @@ Description: Delete Container and remove Container in Database */ -private ["_house","_houseID","_ownerID","_housePos","_query","_radius","_containers"]; -_container = [_this,0,objNull,[objNull]] call BIS_fnc_param; + +params [ + ["_container", objNull, [objNull]] +]; + if (isNull _container) exitWith {diag_log "container null";}; +_containerID = _container getVariable ["container_id", -1]; + +private "_query"; -_containerID = _container getVariable ["container_id",-1]; if (_containerID isEqualTo -1) then { _containerPos = getPosATL _container; - _ownerID = (_container getVariable "container_owner") select 0; - _query = format ["UPDATE containers SET owned='0', pos='[]' WHERE pid='%1' AND pos='%2' AND owned='1'",_ownerID,_containerPos]; - //systemChat format [":SERVER:sellHouse: container_id does not exist"]; + private _ownerID = (_container getVariable "container_owner") select 0; + _query = format ["deleteContainer:%1:%2", _ownerID, _containerPos]; } else { - //systemChat format [":SERVER:sellHouse: house_id is %1",_houseID]; - _query = format ["UPDATE containers SET owned='0', pos='[]' WHERE id='%1'",_containerID]; + _query = format ["deleteContainer1:%1",_containerID]; }; -_container setVariable ["container_id",nil,true]; -_container setVariable ["container_owner",nil,true]; +_container setVariable ["container_id", nil, true]; +_container setVariable ["container_owner", nil, true]; -[_query,1] call DB_fnc_asyncCall; +[_query, 1] call DB_fnc_asyncCall; -["CALL deleteOldContainers",1] call DB_fnc_asyncCall; +["deleteOldContainers", 1] call DB_fnc_asyncCall; deleteVehicle _container; diff --git a/life_server/Functions/Housing/fn_fetchPlayerHouses.sqf b/life_server/Functions/Housing/fn_fetchPlayerHouses.sqf old mode 100644 new mode 100755 index 1d7f750ee..38bfd9b11 --- a/life_server/Functions/Housing/fn_fetchPlayerHouses.sqf +++ b/life_server/Functions/Housing/fn_fetchPlayerHouses.sqf @@ -8,30 +8,30 @@ 1. Fetches all the players houses and sets them up. 2. Fetches all the players containers and sets them up. */ -private ["_query","_containers","_containerss","_houses"]; + params [ ["_uid","",[""]] ]; + if (_uid isEqualTo "") exitWith {}; -_query = format ["SELECT pid, pos, classname, inventory, gear, dir, id FROM containers WHERE pid='%1' AND owned='1'",_uid]; -_containers = [_query,2,true] call DB_fnc_asyncCall; +private _query = format ["selectContainers:%1", _uid]; +private _containers = [_query, 2, true] call DB_fnc_asyncCall; +private _containerss = []; -_containerss = []; { _position = call compile format ["%1",_x select 1]; _house = nearestObject [_position, "House"]; _direction = call compile format ["%1",_x select 5]; - _trunk = [_x select 3] call DB_fnc_mresToArray; + _trunk = _x select 3; if (_trunk isEqualType "") then {_trunk = call compile format ["%1", _trunk];}; - _gear = [_x select 4] call DB_fnc_mresToArray; + _gear = _x select 4; if (_gear isEqualType "") then {_gear = call compile format ["%1", _gear];}; _container = createVehicle[_x select 2,[0,0,999],[],0,"NONE"]; waitUntil {!isNil "_container" && {!isNull _container}}; _containerss = _house getVariable ["containers",[]]; _containerss pushBack _container; _container allowDamage false; - _container enableRopeAttach false; _container setPosATL _position; _container setVectorDirAndUp _direction; //Fix position for more accurate positioning @@ -59,21 +59,21 @@ _containerss = []; for "_i" from 0 to ((count (_items select 0)) - 1) do { _container addItemCargoGlobal [((_items select 0) select _i), ((_items select 1) select _i)]; }; - for "_i" from 0 to ((count (_mags select 0)) - 1) do{ + for "_i" from 0 to ((count (_mags select 0)) - 1) do { _container addMagazineCargoGlobal [((_mags select 0) select _i), ((_mags select 1) select _i)]; }; - for "_i" from 0 to ((count (_weapons select 0)) - 1) do{ + for "_i" from 0 to ((count (_weapons select 0)) - 1) do { _container addWeaponCargoGlobal [((_weapons select 0) select _i), ((_weapons select 1) select _i)]; }; - for "_i" from 0 to ((count (_backpacks select 0)) - 1) do{ + for "_i" from 0 to ((count (_backpacks select 0)) - 1) do { _container addBackpackCargoGlobal [((_backpacks select 0) select _i), ((_backpacks select 1) select _i)]; }; }; - _house setVariable ["containers",_containerss,true]; + _house setVariable ["containers", _containerss, true]; } forEach _containers; -_query = format ["SELECT pid, pos FROM houses WHERE pid='%1' AND owned='1'",_uid]; -_houses = [_query,2,true] call DB_fnc_asyncCall; +_query = format ["selectHousePositions:%1", _uid]; +private _houses = [_query, 2, true] call DB_fnc_asyncCall; _return = []; { @@ -83,4 +83,4 @@ _return = []; _return pushBack [_x select 1]; } forEach _houses; -missionNamespace setVariable [format ["houses_%1",_uid],_return]; +missionNamespace setVariable [format ["houses_%1", _uid], _return]; diff --git a/life_server/Functions/Housing/fn_houseCleanup.sqf b/life_server/Functions/Housing/fn_houseCleanup.sqf old mode 100644 new mode 100755 index fc835445d..de84c1da6 --- a/life_server/Functions/Housing/fn_houseCleanup.sqf +++ b/life_server/Functions/Housing/fn_houseCleanup.sqf @@ -5,17 +5,15 @@ Description: Cleans up containers inside in house of player. */ -params [ - ["_uid","",[""]] -]; -private _query = format ["SELECT pos FROM containers WHERE pid='%1' AND owned='1'",_uid]; -private _containers = [_query,2,true] call DB_fnc_asyncCall; +private _query = format ["selectContainerPositions:%1", _this]; +private _containers = [_query, 2, true] call DB_fnc_asyncCall; +if (_containers isEqualTo []) exitWith {}; { - _x params ["_pos"]; - _pos = parseSimpleArray _pos; + _pos = call compile format ["%1", _x select 1]; + _container = nearestObjects[_pos, ["Box_IND_Grenades_F", "B_supplyCrate_F"], 12]; { deleteVehicle _x; - } forEach (nearestObjects[_pos,["Box_IND_Grenades_F","B_supplyCrate_F"],12]); -} forEach _containers; \ No newline at end of file + } forEach _container; +} forEach _containers; diff --git a/life_server/Functions/Housing/fn_houseGarage.sqf b/life_server/Functions/Housing/fn_houseGarage.sqf old mode 100644 new mode 100755 index 3d2c69e0a..33393f206 --- a/life_server/Functions/Housing/fn_houseGarage.sqf +++ b/life_server/Functions/Housing/fn_houseGarage.sqf @@ -12,21 +12,14 @@ params [ ["_mode",-1,[0]] ]; -if (_uid isEqualTo "") exitWith {}; -if (isNull _house) exitWith {}; -if (_mode isEqualTo -1) exitWith {}; +if (_uid isEqualTo "" || {isNull _house} || {_mode isEqualTo -1}) exitWith {}; private _housePos = getPosATL _house; -private "_query"; - -if (_mode isEqualTo 0) then { - _query = format ["UPDATE houses SET garage='1' WHERE pid='%1' AND pos='%2'",_uid,_housePos]; -} else { - _query = format ["UPDATE houses SET garage='0' WHERE pid='%1' AND pos='%2'",_uid,_housePos]; -}; +private _active = ["0", "1"] select (_mode isEqualTo 0); +private _query = format ["updateGarage:%1:%2:%3", _active, _uid, _housePos]; if (EXTDB_SETTING(getNumber,"DebugMode") isEqualTo 1) then { - diag_log format ["Query: %1",_query]; + diag_log format ["Query: %1", _query]; }; -[_query,1] call DB_fnc_asyncCall; \ No newline at end of file +[_query, 1] call DB_fnc_asyncCall; diff --git a/life_server/Functions/Housing/fn_initHouses.sqf b/life_server/Functions/Housing/fn_initHouses.sqf old mode 100644 new mode 100755 index d5d98eb50..61278a7af --- a/life_server/Functions/Housing/fn_initHouses.sqf +++ b/life_server/Functions/Housing/fn_initHouses.sqf @@ -4,31 +4,30 @@ Description: Initalizes house setup when player joins the server. */ -private ["_queryResult","_query","_count","_blacklistedHouses","_blacklistedGarages"]; -_count = (["SELECT COUNT(*) FROM houses WHERE owned='1'",2] call DB_fnc_asyncCall) select 0; +private _count = (["selectAllHouses" ,2] call DB_fnc_asyncCall) select 0; for [{_x=0},{_x<=_count},{_x=_x+10}] do { - _query = format ["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 %1,10",_x]; - _queryResult = [_query,2,true] call DB_fnc_asyncCall; - if (count _queryResult isEqualTo 0) exitWith {}; + private _query = format ["selectPlayerHouses:%1", _x]; + private _queryResult = [_query, 2, true] call DB_fnc_asyncCall; + if (_queryResult isEqualTo []) exitWith {}; { - _pos = call compile format ["%1",_x select 2]; + _pos = call compile format ["%1", _x select 2]; _house = nearestObject [_pos, "House"]; - _house setVariable ["house_owner",[_x select 1,_x select 3],true]; - _house setVariable ["house_id",_x select 0,true]; - _house setVariable ["locked",true,true]; //Lock up all the stuff. + _house setVariable ["house_owner",[_x select 1, _x select 3],true]; + _house setVariable ["house_id", _x select 0, true]; + _house setVariable ["locked", true, true]; //Lock up all the stuff. if (_x select 4 isEqualTo 1) then { - _house setVariable ["garageBought",true,true]; + _house setVariable ["garageBought", true, true]; }; _numOfDoors = getNumber(configFile >> "CfgVehicles" >> (typeOf _house) >> "numberOfDoors"); for "_i" from 1 to _numOfDoors do { - _house setVariable [format ["bis_disabled_Door_%1",_i],1,true]; + _house setVariable [format ["bis_disabled_Door_%1",_i], 1, true]; }; } forEach _queryResult; }; -_blacklistedHouses = "count (getArray (_x >> 'garageBlacklists')) > 0" configClasses (missionconfigFile >> "Housing" >> worldName); -_blacklistedGarages = "count (getArray (_x >> 'garageBlacklists')) > 0" configClasses (missionconfigFile >> "Garages" >> worldName); +private _blacklistedHouses = "count (getArray (_x >> 'garageBlacklists')) > 0" configClasses (missionconfigFile >> "Housing" >> worldName); +private _blacklistedGarages = "count (getArray (_x >> 'garageBlacklists')) > 0" configClasses (missionconfigFile >> "Garages" >> worldName); _blacklistedHouses = _blacklistedHouses apply {configName _x}; _blacklistedGarages = _blacklistedGarages apply {configName _x}; @@ -38,7 +37,7 @@ for "_i" from 0 to count(_blacklistedHouses)-1 do { { _obj = nearestObject [_x,_className]; if (isNull _obj) then { - _obj setVariable ["blacklistedGarage",true,true]; + _obj setVariable ["blacklistedGarage", true, true]; }; } forEach _positions; }; @@ -49,7 +48,7 @@ for "_i" from 0 to count(_blacklistedGarages)-1 do { { _obj = nearestObject [_x,_className]; if (isNull _obj) then { - _obj setVariable ["blacklistedGarage",true,true]; + _obj setVariable ["blacklistedGarage", true, true]; }; } forEach _positions; }; diff --git a/life_server/Functions/Housing/fn_sellHouse.sqf b/life_server/Functions/Housing/fn_sellHouse.sqf old mode 100644 new mode 100755 index 81b20b55d..fe94b9255 --- a/life_server/Functions/Housing/fn_sellHouse.sqf +++ b/life_server/Functions/Housing/fn_sellHouse.sqf @@ -6,25 +6,28 @@ Used in selling the house, sets the owned to 0 and will cleanup with a stored procedure on restart. */ -private ["_house","_houseID","_ownerID","_housePos","_query","_radius","_containers"]; -_house = [_this,0,objNull,[objNull]] call BIS_fnc_param; + +params [ + ["_house", objNull, [objNull]] +]; + if (isNull _house) exitWith {systemChat ":SERVER:sellHouse: House is null";}; +private _houseID = _house getVariable ["house_id", -1]; + +private "_query"; -_houseID = _house getVariable ["house_id",-1]; if (_houseID isEqualTo -1) then { - _housePos = getPosATL _house; - _ownerID = (_house getVariable "house_owner") select 0; - _query = format ["UPDATE houses SET owned='0', pos='[]' WHERE pid='%1' AND pos='%2' AND owned='1'",_ownerID,_housePos]; - //systemChat format [":SERVER:sellHouse: house_id does not exist, query: %1",_query]; + private _housePos = getPosATL _house; + private _ownerID = (_house getVariable "house_owner") select 0; + _query = format ["deleteHouse:%1:%2", _ownerID, _housePos]; } else { - //systemChat format [":SERVER:sellHouse: house_id is %1",_houseID]; - _query = format ["UPDATE houses SET owned='0', pos='[]' WHERE id='%1'",_houseID]; + _query = format ["deleteHouse1:%1", _houseID]; }; -_house setVariable ["house_id",nil,true]; -_house setVariable ["house_owner",nil,true]; -_house setVariable ["garageBought",false,true]; +_house setVariable ["house_id", nil, true]; +_house setVariable ["house_owner", nil, true]; +_house setVariable ["garageBought", false, true]; -[_query,1] call DB_fnc_asyncCall; -_house setVariable ["house_sold",nil,true]; -["CALL deleteOldHouses",1] call DB_fnc_asyncCall; +[_query, 1] call DB_fnc_asyncCall; +_house setVariable ["house_sold", nil, true]; +["deleteOldHouses", 1] call DB_fnc_asyncCall; diff --git a/life_server/Functions/Housing/fn_sellHouseContainer.sqf b/life_server/Functions/Housing/fn_sellHouseContainer.sqf old mode 100644 new mode 100755 index e331f9726..e51c39c1f --- a/life_server/Functions/Housing/fn_sellHouseContainer.sqf +++ b/life_server/Functions/Housing/fn_sellHouseContainer.sqf @@ -6,22 +6,27 @@ Used in selling the house, container sets the owned to 0 and will cleanup with a stored procedure on restart. */ -private ["_house","_houseID","_ownerID","_housePos","_query","_radius","_containers"]; -_container = [_this,0,objNull,[objNull]] call BIS_fnc_param; -if (isNull _container) exitWith {}; +params [ + ["_container", objNull, [objNull]] +]; + +if (isNull _container) exitWith {}; _containerID = _container getVariable ["container_id",-1]; + +private "_query"; + if (_containerID isEqualTo -1) then { _containerPos = getPosATL _container; - _ownerID = (_container getVariable "container_owner") select 0; - _query = format ["UPDATE containers SET owned='0', pos='[]' WHERE pid='%1' AND pos='%2' AND owned='1'",_ownerID,_containerPos]; + private _ownerID = (_container getVariable "container_owner") select 0; + _query = format ["deleteContainer:%1:%2", _ownerID, _containerPos]; } else { - _query = format ["UPDATE containers SET owned='0', pos='[]' WHERE id='%1'",_containerID]; + _query = format ["deleteContainer1:%1", _containerID]; }; -_container setVariable ["container_id",nil,true]; -_container setVariable ["container_owner",nil,true]; +_container setVariable ["container_id", nil, true]; +_container setVariable ["container_owner", nil, true]; deleteVehicle _container; -[_query,1] call DB_fnc_asyncCall; -["CALL deleteOldContainers",1] call DB_fnc_asyncCall; +[_query, 1] call DB_fnc_asyncCall; +["deleteOldContainers", 1] call DB_fnc_asyncCall; diff --git a/life_server/Functions/Housing/fn_updateHouseContainers.sqf b/life_server/Functions/Housing/fn_updateHouseContainers.sqf old mode 100644 new mode 100755 index 8e0be88c0..99717e6ad --- a/life_server/Functions/Housing/fn_updateHouseContainers.sqf +++ b/life_server/Functions/Housing/fn_updateHouseContainers.sqf @@ -5,20 +5,22 @@ Description: Update inventory "i" in container */ -private ["_containerID","_containers","_query","_vehItems","_vehMags","_vehWeapons","_vehBackpacks","_cargo"]; -_container = [_this,0,objNull,[objNull]] call BIS_fnc_param; + +params [ + ["_container", objNull, [objNull]] +]; + if (isNull _container) exitWith {}; -_containerID = _container getVariable ["container_id",-1]; -if (_containerID isEqualTo -1) exitWith {}; -_vehItems = getItemCargo _container; -_vehMags = getMagazineCargo _container; -_vehWeapons = getWeaponCargo _container; -_vehBackpacks = getBackpackCargo _container; -_cargo = [_vehItems,_vehMags,_vehWeapons,_vehBackpacks]; +private _containerID = _container getVariable ["container_id", -1]; +if (_containerID isEqualTo -1) exitWith {}; -_cargo = [_cargo] call DB_fnc_mresArray; +private _vehItems = getItemCargo _container; +private _vehMags = getMagazineCargo _container; +private _vehWeapons = getWeaponCargo _container; +private _vehBackpacks = getBackpackCargo _container; +private _cargo = [_vehItems, _vehMags, _vehWeapons, _vehBackpacks]; -_query = format ["UPDATE containers SET gear='%1' WHERE id='%2'",_cargo,_containerID]; +private _query = format ["updateContainer:%1:%2", _cargo, _containerID]; -[_query,1] call DB_fnc_asyncCall; +[_query, 1] call DB_fnc_asyncCall; diff --git a/life_server/Functions/Housing/fn_updateHouseTrunk.sqf b/life_server/Functions/Housing/fn_updateHouseTrunk.sqf old mode 100644 new mode 100755 index 16e37c845..4d0fab1cb --- a/life_server/Functions/Housing/fn_updateHouseTrunk.sqf +++ b/life_server/Functions/Housing/fn_updateHouseTrunk.sqf @@ -5,16 +5,18 @@ Description: Update inventory "y" in container */ -private ["_house"]; -_container = [_this,0,objNull,[objNull]] call BIS_fnc_param; + +params [ + ["_container", objNull, [objNull]] +]; + if (isNull _container) exitWith {}; -_trunkData = _container getVariable ["Trunk",[[],0]]; -_containerID = _container getVariable ["container_id",-1]; +_trunkData = _container getVariable ["Trunk", [[], 0]]; +_containerID = _container getVariable ["container_id", -1]; -if (_containerID isEqualTo -1) exitWith {}; //Dafuq? +if (_containerID isEqualTo -1) exitWith {}; -_trunkData = [_trunkData] call DB_fnc_mresArray; -_query = format ["UPDATE containers SET inventory='%1' WHERE id='%2'",_trunkData,_containerID]; +_query = format ["updateHouseTrunk:%1:%2", _trunkData, _containerID]; -[_query,1] call DB_fnc_asyncCall; +[_query, 1] call DB_fnc_asyncCall; diff --git a/life_server/Functions/MySQL/fn_asyncCall.sqf b/life_server/Functions/MySQL/fn_asyncCall.sqf old mode 100644 new mode 100755 index 57782bfdd..cb16a479c --- a/life_server/Functions/MySQL/fn_asyncCall.sqf +++ b/life_server/Functions/MySQL/fn_asyncCall.sqf @@ -11,18 +11,20 @@ 1: INTEGER (1 = ASYNC + not return for update/insert, 2 = ASYNC + return for query's). 3: BOOL (True to return a single array, false to return multiple entries mainly for garage). */ -private ["_queryStmt","_mode","_multiarr","_queryResult","_key","_return","_loop"]; -_queryStmt = [_this,0,"",[""]] call BIS_fnc_param; -_mode = [_this,1,1,[0]] call BIS_fnc_param; -_multiarr = [_this,2,false,[false]] call BIS_fnc_param; -_key = EXTDB format ["%1:%2:%3",_mode,FETCH_CONST(life_sql_id),_queryStmt]; +params [ + ["_queryStmt", "", [""]], + ["_mode", 1, [0]], + ["_multiarr", false, [true]] +]; + +private _key = EXTDB format ["%1:%2:%3",_mode,FETCH_CONST(life_sql_id),_queryStmt]; if (_mode isEqualTo 1) exitWith {true}; _key = call compile format ["%1",_key]; -_key = (_key select 1); -_queryResult = EXTDB format ["4:%1", _key]; +_key = _key select 1; +private _queryResult = EXTDB format ["4:%1", _key]; //Make sure the data is received if (_queryResult isEqualTo "[3]") then { @@ -33,7 +35,7 @@ if (_queryResult isEqualTo "[3]") then { }; if (_queryResult isEqualTo "[5]") then { - _loop = true; + private _loop = true; for "_i" from 0 to 1 step 0 do { // extDB3 returned that result is Multi-Part Message _queryResult = ""; for "_i" from 0 to 1 step 0 do { @@ -46,9 +48,9 @@ if (_queryResult isEqualTo "[5]") then { }; _queryResult = call compile _queryResult; if ((_queryResult select 0) isEqualTo 0) exitWith {diag_log format ["extDB3: Protocol Error: %1", _queryResult]; []}; -_return = (_queryResult select 1); -if (!_multiarr && count _return > 0) then { - _return = (_return select 0); +private _return = (_queryResult select 1); +if (!_multiarr && {!(_return isEqualTo [])}) then { + _return = _return select 0; }; _return; diff --git a/life_server/Functions/MySQL/fn_bool.sqf b/life_server/Functions/MySQL/fn_bool.sqf deleted file mode 100644 index 2d9a70f23..000000000 --- a/life_server/Functions/MySQL/fn_bool.sqf +++ /dev/null @@ -1,26 +0,0 @@ -/* - File: fn_bool.sqf - Author: TAW_Tonic - - Description: - Handles bool conversion for MySQL since MySQL doesn't support 'true' or 'false' - instead MySQL uses Tinyint for BOOLEAN (0 = false, 1 = true) -*/ -private ["_bool","_mode"]; -_bool = [_this,0,0,[false,0]] call BIS_fnc_param; -_mode = [_this,1,0,[0]] call BIS_fnc_param; - -switch (_mode) do { - case 0: { - if (_bool isEqualType 0) exitWith {0}; - if (_bool) then {1} else {0}; - }; - - case 1: { - if (!(_bool isEqualType 0)) exitWith {false}; - switch (_bool) do { - case 0: {false}; - case 1: {true}; - }; - }; -}; diff --git a/life_server/Functions/MySQL/fn_insertRequest.sqf b/life_server/Functions/MySQL/fn_insertRequest.sqf old mode 100644 new mode 100755 index b8b9f9bb6..f3e7432e2 --- a/life_server/Functions/MySQL/fn_insertRequest.sqf +++ b/life_server/Functions/MySQL/fn_insertRequest.sqf @@ -7,7 +7,7 @@ Adds a player to the database upon first joining of the server. Recieves information from core\sesison\fn_insertPlayerInfo.sqf */ -private ["_queryResult","_query","_alias"]; + params [ "_uid", "_name", @@ -17,35 +17,28 @@ params [ ]; //Error checks -if ((_uid isEqualTo "") || (_name isEqualTo "")) exitWith {systemChat "Bad UID or name";}; //Let the client be 'lost' in 'transaction' +if (_uid isEqualTo "" || {_name isEqualTo ""}) exitWith {systemChat "Bad UID or name";}; //Let the client be 'lost' in 'transaction' if (isNull _returnToSender) exitWith {systemChat "ReturnToSender is Null!";}; //No one to send this to! -_query = format ["SELECT pid, name FROM players WHERE pid='%1'",_uid]; - - +private _query = format ["checkPlayerExists:%1", _uid]; _tickTime = diag_tickTime; -_queryResult = [_query,2] call DB_fnc_asyncCall; +private _queryResult = [_query, 2] call DB_fnc_asyncCall; if (EXTDB_SETTING(getNumber,"DebugMode") isEqualTo 1) then { diag_log "------------- Insert 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 format ["QUERY: %1", _query]; + diag_log format ["Time to complete: %1 (in seconds)", (diag_tickTime - _tickTime)]; + diag_log format ["Result: %1", _queryResult]; diag_log "------------------------------------------------"; }; //Double check to make sure the client isn't in the database... -if (_queryResult isEqualType "") exitWith {[] remoteExecCall ["SOCK_fnc_dataQuery",(owner _returnToSender)];}; //There was an entry! -if !(count _queryResult isEqualTo 0) exitWith {[] remoteExecCall ["SOCK_fnc_dataQuery",(owner _returnToSender)];}; +if (_queryResult isEqualType "" && !(_queryResult isEqualTo [])) exitWith {[] remoteExecCall ["SOCK_fnc_dataQuery", (owner _returnToSender)];}; -//Clense and prepare some information. -_name = [_name] call DB_fnc_mresString; //Clense the name of bad chars. -_alias = [[_name]] call DB_fnc_mresArray; -_money = [_money] call DB_fnc_numberSafe; -_bank = [_bank] call DB_fnc_numberSafe; +private _alias = [_name]; //Prepare the query statement.. -_query = format ["INSERT INTO players (pid, name, cash, bankacc, aliases, cop_licenses, med_licenses, civ_licenses, civ_gear, cop_gear, med_gear) VALUES('%1', '%2', '%3', '%4', '%5','""[]""','""[]""','""[]""','""[]""','""[]""','""[]""')", +_query = format ["insertNewPlayer:%1:%2:%3:%4:%5", _uid, _name, _money, @@ -53,5 +46,5 @@ _query = format ["INSERT INTO players (pid, name, cash, bankacc, aliases, cop_li _alias ]; -[_query,1] call DB_fnc_asyncCall; -[] remoteExecCall ["SOCK_fnc_dataQuery",(owner _returnToSender)]; +[_query, 1] call DB_fnc_asyncCall; +[] remoteExecCall ["SOCK_fnc_dataQuery", (owner _returnToSender)]; diff --git a/life_server/Functions/MySQL/fn_insertVehicle.sqf b/life_server/Functions/MySQL/fn_insertVehicle.sqf old mode 100644 new mode 100755 index 6682832a4..59532ad2e --- a/life_server/Functions/MySQL/fn_insertVehicle.sqf +++ b/life_server/Functions/MySQL/fn_insertVehicle.sqf @@ -5,7 +5,7 @@ Description: Inserts the vehicle into the database */ -private ["_query","_sql"]; + params [ "_uid", "_side", @@ -16,9 +16,7 @@ params [ ]; //Stop bad data being passed. -if (_uid isEqualTo "" || _side isEqualTo "" || _type isEqualTo "" || _className isEqualTo "" || _color isEqualTo -1 || _plate isEqualTo -1) exitWith {}; - -_query = format ["INSERT INTO vehicles (side, classname, type, pid, alive, active, inventory, color, plate, gear, damage) VALUES ('%1', '%2', '%3', '%4', '1','1','""[[],0]""', '%5', '%6','""[]""','""[]""')",_side,_className,_type,_uid,_color,_plate]; - +if (_uid isEqualTo "" || {_side isEqualTo ""} || {_type isEqualTo ""} || {_className isEqualTo ""} || {_color isEqualTo -1} || {_plate isEqualTo -1}) exitWith {}; -[_query,1] call DB_fnc_asyncCall; +private _query = format ["insertVehicle:%1:%2:%3:%4:%5:%6", _side, _className, _type, _uid, _color, _plate]; +[_query, 1] call DB_fnc_asyncCall; diff --git a/life_server/Functions/MySQL/fn_mresArray.sqf b/life_server/Functions/MySQL/fn_mresArray.sqf deleted file mode 100644 index d8433f26a..000000000 --- a/life_server/Functions/MySQL/fn_mresArray.sqf +++ /dev/null @@ -1,27 +0,0 @@ -/* - File: fn_mresArray.sqf - Author: Bryan "Tonic" Boardwine"; - - Description: - Acts as a mres (MySQL Real Escape) for arrays so they - can be properly inserted into the database without causing - any problems. The return method is 'hacky' but it's effective. -*/ -private ["_array"]; -_array = [_this,0,[],[[]]] call BIS_fnc_param; -_array = str _array; -_array = toArray(_array); - -for "_i" from 0 to (count _array)-1 do -{ - _sel = _array select _i; - if (!(_i isEqualTo 0) && !(_i isEqualTo ((count _array)-1))) then - { - if (_sel isEqualTo 34) then - { - _array set[_i,96]; - }; - }; -}; - -str(toString(_array)); diff --git a/life_server/Functions/MySQL/fn_mresString.sqf b/life_server/Functions/MySQL/fn_mresString.sqf deleted file mode 100644 index 584a8e7bd..000000000 --- a/life_server/Functions/MySQL/fn_mresString.sqf +++ /dev/null @@ -1,21 +0,0 @@ -/* - File: fn_mresString.sqf - Author: Bryan "Tonic" Boardwine - - Description: - Makes the string safe to be passed to MySQL (strips various stuff). -*/ -private ["_string","_filter"]; -_string = [_this,0,"",[""]] call BIS_fnc_param; -_filter = "'/\`:|;,{}-""<>"; - -_string = toArray _string; //Blow it up to an array -_filter = toArray _filter; //Blow it up to an array - -{ - if (_x in _filter) then { - _string deleteAt _forEachIndex; - }; -} forEach _string; - -toString _string; diff --git a/life_server/Functions/MySQL/fn_mresToArray.sqf b/life_server/Functions/MySQL/fn_mresToArray.sqf deleted file mode 100644 index e93e75d67..000000000 --- a/life_server/Functions/MySQL/fn_mresToArray.sqf +++ /dev/null @@ -1,26 +0,0 @@ -/* - File: fn_mresToArray.sqf - Author: Bryan "Tonic" Boardwine"; - - Description: - Acts as a mres (MySQL Real Escape) for arrays so they - can be properly inserted into the database without causing - any problems. The return method is 'hacky' but it's effective. -*/ -private ["_array"]; -_array = [_this,0,"",[""]] call BIS_fnc_param; -if (_array isEqualTo "") exitWith {[]}; -_array = toArray(_array); - -for "_i" from 0 to (count _array)-1 do -{ - _sel = _array select _i; - if (_sel == 96) then - { - _array set[_i,39]; - }; -}; - -_array = toString(_array); -_array = call compile format ["%1", _array]; -_array; \ No newline at end of file diff --git a/life_server/Functions/MySQL/fn_numberSafe.sqf b/life_server/Functions/MySQL/fn_numberSafe.sqf deleted file mode 100644 index 0fc534d88..000000000 --- a/life_server/Functions/MySQL/fn_numberSafe.sqf +++ /dev/null @@ -1,28 +0,0 @@ -/* - File: fn_numberSafe.sqf - Author: Karel Moricky - - Description: - Convert a number into string (avoiding scientific notation) - - Parameter(s): - _this: NUMBER - - Returns: - STRING -*/ -private ["_number","_mod","_digots","_digitsCount","_modBase","_numberText"]; - -_number = [_this,0,0,[0]] call bis_fnc_param; -_mod = [_this,1,3,[0]] call bis_fnc_param; - -_digits = _number call bis_fnc_numberDigits; -_digitsCount = count _digits - 1; - -_modBase = _digitsCount % _mod; -_numberText = ""; -{ - _numberText = _numberText + str _x; - if ((_foreachindex - _modBase) % (_mod) isEqualTo 0 && !(_foreachindex isEqualTo _digitsCount)) then {_numberText = _numberText + "";}; -} forEach _digits; -_numberText diff --git a/life_server/Functions/MySQL/fn_queryRequest.sqf b/life_server/Functions/MySQL/fn_queryRequest.sqf old mode 100644 new mode 100755 index 42b5587e5..de92704f0 --- a/life_server/Functions/MySQL/fn_queryRequest.sqf +++ b/life_server/Functions/MySQL/fn_queryRequest.sqf @@ -11,30 +11,27 @@ 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. */ -private ["_uid","_side","_query","_queryResult","_tickTime","_tmp"]; -_uid = [_this,0,"",[""]] call BIS_fnc_param; -_side = [_this,1,sideUnknown,[civilian]] call BIS_fnc_param; -_ownerID = [_this,2,objNull,[objNull]] call BIS_fnc_param; -if (isNull _ownerID) exitWith {}; - -if (LIFE_SETTINGS(getNumber,"player_deathLog") isEqualTo 1) then { - _ownerID addMPEventHandler ["MPKilled", {_this call fn_whoDoneIt}]; -}; +params [ + ["_uid", "", [""]], + ["_side", sideUnknown, [civilian]], + ["_ownerID", objNull, [objNull]] +]; +if (isNull _ownerID) exitWith {}; _ownerID = owner _ownerID; -_query = switch (_side) do { +private _query = switch (_side) do { // West - 11 entries returned - case west: {format ["SELECT pid, name, cash, bankacc, adminlevel, donorlevel, cop_licenses, coplevel, cop_gear, blacklist, cop_stats, playtime FROM players WHERE pid='%1'",_uid];}; + case west: {format ["selectWest:%1", _uid];}; // Civilian - 12 entries returned - case civilian: {format ["SELECT pid, name, cash, bankacc, adminlevel, donorlevel, civ_licenses, arrested, civ_gear, civ_stats, civ_alive, civ_position, playtime FROM players WHERE pid='%1'",_uid];}; + case civilian: {format ["selectCiv:%1", _uid];}; // Independent - 10 entries returned - case independent: {format ["SELECT pid, name, cash, bankacc, adminlevel, donorlevel, med_licenses, mediclevel, med_gear, med_stats, playtime FROM players WHERE pid='%1'",_uid];}; + case independent: {format ["selectIndep:%1",_uid];}; }; -_tickTime = diag_tickTime; -_queryResult = [_query,2] call DB_fnc_asyncCall; +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 -------------"; @@ -44,122 +41,60 @@ if (EXTDB_SETTING(getNumber,"DebugMode") isEqualTo 1) then { diag_log "------------------------------------------------"; }; -if (_queryResult isEqualType "") exitWith { +if (_queryResult isEqualType "" || _queryResult isEqualTo []) exitWith { [] remoteExecCall ["SOCK_fnc_insertPlayerInfo",_ownerID]; }; -if (count _queryResult isEqualTo 0) exitWith { - [] remoteExecCall ["SOCK_fnc_insertPlayerInfo",_ownerID]; -}; +private _licenses = (_queryResult select 6); -//Blah conversion thing from a2net->extdb -_tmp = _queryResult select 2; -_queryResult set[2,[_tmp] call DB_fnc_numberSafe]; -_tmp = _queryResult select 3; -_queryResult set[3,[_tmp] call DB_fnc_numberSafe]; - -//Parse licenses (Always index 6) -_new = [(_queryResult select 6)] call DB_fnc_mresToArray; -if (_new isEqualType "") then {_new = call compile format ["%1", _new];}; -_queryResult set[6,_new]; - -//Convert tinyint to boolean -_old = _queryResult select 6; -for "_i" from 0 to (count _old)-1 do { - _data = _old select _i; - _old set[_i,[_data select 0, ([_data select 1,1] call DB_fnc_bool)]]; +for "_i" from 0 to (count _licenses) -1 do { + (_licenses select _i) params ["_license", "_owned"]; + _licenses set[_i, [_license, [false, true] select _owned]]; }; -_queryResult set[6,_old]; +private "_playTimes"; -_new = [(_queryResult select 8)] call DB_fnc_mresToArray; -if (_new isEqualType "") then {_new = call compile format ["%1", _new];}; -_queryResult set[8,_new]; -//Parse data for specific side. switch (_side) do { - case west: { - _queryResult set[9,([_queryResult select 9,1] call DB_fnc_bool)]; - - //Parse Stats - _new = [(_queryResult select 10)] call DB_fnc_mresToArray; - if (_new isEqualType "") then {_new = call compile format ["%1", _new];}; - _queryResult set[10,_new]; - - //Playtime - _new = [(_queryResult select 11)] call DB_fnc_mresToArray; - if (_new isEqualType "") then {_new = call compile format ["%1", _new];}; - _index = TON_fnc_playtime_values_request find [_uid, _new]; - 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, _new]; - } else { - TON_fnc_playtime_values_request pushBack [_uid, _new]; - }; - [_uid,_new select 0] call TON_fnc_setPlayTime; - }; - - case civilian: { - _queryResult set[7,([_queryResult select 7,1] call DB_fnc_bool)]; - - //Parse Stats - _new = [(_queryResult select 9)] call DB_fnc_mresToArray; - if (_new isEqualType "") then {_new = call compile format ["%1", _new];}; - _queryResult set[9,_new]; - - //Position - _queryResult set[10,([_queryResult select 10,1] call DB_fnc_bool)]; - _new = [(_queryResult select 11)] call DB_fnc_mresToArray; - if (_new isEqualType "") then {_new = call compile format ["%1", _new];}; - _queryResult set[11,_new]; - - //Playtime - _new = [(_queryResult select 12)] call DB_fnc_mresToArray; - if (_new isEqualType "") then {_new = call compile format ["%1", _new];}; - _index = TON_fnc_playtime_values_request find [_uid, _new]; - 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, _new]; - } else { - TON_fnc_playtime_values_request pushBack [_uid, _new]; - }; - [_uid,_new 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 independent: { - //Parse Stats - _new = [(_queryResult select 9)] call DB_fnc_mresToArray; - if (_new isEqualType "") then {_new = call compile format ["%1", _new];}; - _queryResult set[9,_new]; - - //Playtime - _new = [(_queryResult select 10)] call DB_fnc_mresToArray; - if (_new isEqualType "") then {_new = call compile format ["%1", _new];}; - _index = TON_fnc_playtime_values_request find [_uid, _new]; - 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, _new]; - } else { - TON_fnc_playtime_values_request pushBack [_uid, _new]; - }; - [_uid,_new select 1] call TON_fnc_setPlayTime; - }; + 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],[]]; +_keyArr = missionNamespace getVariable [format ["%1_KEYS_%2",_uid,_side], []]; _queryResult pushBack _keyArr; - -_queryResult remoteExec ["SOCK_fnc_requestReceived",_ownerID]; +_queryResult remoteExec ["SOCK_fnc_requestReceived", _ownerID]; diff --git a/life_server/Functions/MySQL/fn_updatePartial.sqf b/life_server/Functions/MySQL/fn_updatePartial.sqf old mode 100644 new mode 100755 index 58f161bce..4c573ca66 --- a/life_server/Functions/MySQL/fn_updatePartial.sqf +++ b/life_server/Functions/MySQL/fn_updatePartial.sqf @@ -6,81 +6,68 @@ Takes partial data of a player and updates it, this is meant to be less network intensive towards data flowing through it for updates. */ -private ["_uid","_side","_value","_value1","_value2","_mode","_query"]; -_uid = [_this,0,"",[""]] call BIS_fnc_param; -_side = [_this,1,sideUnknown,[civilian]] call BIS_fnc_param; -_mode = [_this,3,-1,[0]] call BIS_fnc_param; -if (_uid isEqualTo "" || _side isEqualTo sideUnknown) exitWith {}; //Bad. -_query = ""; +params [ + ["_uid", "", [""]], + ["_side", sideUnknown, [civilian]], + "_value", + ["_mode", -1, [0]], + "_value1" +]; + +if (_uid isEqualTo "" || {_side isEqualTo sideUnknown}) exitWith {}; //Bad. +private _query = ""; switch (_mode) do { case 0: { - _value = [_this,2,0,[0]] call BIS_fnc_param; - _value = [_value] call DB_fnc_numberSafe; - _query = format ["UPDATE players SET cash='%1' WHERE pid='%2'",_value,_uid]; + _query = format ["updateCash:%1:%2", _value, _uid]; }; case 1: { - _value = [_this,2,0,[0]] call BIS_fnc_param; - _value = [_value] call DB_fnc_numberSafe; - _query = format ["UPDATE players SET bankacc='%1' WHERE pid='%2'",_value,_uid]; + _query = format ["updateBank:%1:%2",_value,_uid]; }; case 2: { - _value = [_this,2,[],[[]]] call BIS_fnc_param; - //Does something license related but I can't remember I only know it's important? - for "_i" from 0 to count(_value)-1 do { - _bool = [(_value select _i) select 1] call DB_fnc_bool; - _value set[_i,[(_value select _i) select 0,_bool]]; + for "_i" from 0 to (count _value) -1 do { + (_value select _i) params ["_license", "_owned"]; + _value set[_i, [_license, [0, 1] select _owned]]; }; - _value = [_value] call DB_fnc_mresArray; + switch (_side) do { - case west: {_query = format ["UPDATE players SET cop_licenses='%1' WHERE pid='%2'",_value,_uid];}; - case civilian: {_query = format ["UPDATE players SET civ_licenses='%1' WHERE pid='%2'",_value,_uid];}; - case independent: {_query = format ["UPDATE players SET med_licenses='%1' WHERE pid='%2'",_value,_uid];}; + 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: { - _value = [_this,2,[],[[]]] call BIS_fnc_param; - _value = [_value] call DB_fnc_mresArray; switch (_side) do { - case west: {_query = format ["UPDATE players SET cop_gear='%1' WHERE pid='%2'",_value,_uid];}; - case civilian: {_query = format ["UPDATE players SET civ_gear='%1' WHERE pid='%2'",_value,_uid];}; - case independent: {_query = format ["UPDATE players SET med_gear='%1' WHERE pid='%2'",_value,_uid];}; + 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: { - _value = [_this,2,false,[true]] call BIS_fnc_param; - _value = [_value] call DB_fnc_bool; - _value2 = [_this,4,[],[[]]] call BIS_fnc_param; - _value2 = if (count _value2 isEqualTo 3) then {_value2} else {[0,0,0]}; - _value2 = [_value2] call DB_fnc_mresArray; - _query = format ["UPDATE players SET civ_alive='%1', civ_position='%2' WHERE pid='%3'",_value,_value2,_uid]; + _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]; }; case 5: { - _value = [_this,2,false,[true]] call BIS_fnc_param; - _value = [_value] call DB_fnc_bool; - _query = format ["UPDATE players SET arrested='%1' WHERE pid='%2'",_value,_uid]; + _value = [0, 1] select _value; + _query = format ["updateArrested:%1:%2",_value,_uid]; }; case 6: { - _value1 = [_this,2,0,[0]] call BIS_fnc_param; - _value2 = [_this,4,0,[0]] call BIS_fnc_param; - _value1 = [_value1] call DB_fnc_numberSafe; - _value2 = [_value2] call DB_fnc_numberSafe; - _query = format ["UPDATE players SET cash='%1', bankacc='%2' WHERE pid='%3'",_value1,_value2,_uid]; + _query = format ["updateCashAndBank:%1:%2:%3", _value, _value1, _uid]; }; case 7: { - _array = [_this,2,[],[[]]] call BIS_fnc_param; - [_uid,_side,_array,0] call TON_fnc_keyManagement; + [_uid, _side, _value, 0] call TON_fnc_keyManagement; }; }; if (_query isEqualTo "") exitWith {}; -[_query,1] call DB_fnc_asyncCall; +[_query, 1] call DB_fnc_asyncCall; diff --git a/life_server/Functions/MySQL/fn_updateRequest.sqf b/life_server/Functions/MySQL/fn_updateRequest.sqf old mode 100644 new mode 100755 index 884059855..7d0f11668 --- a/life_server/Functions/MySQL/fn_updateRequest.sqf +++ b/life_server/Functions/MySQL/fn_updateRequest.sqf @@ -6,37 +6,34 @@ Updates ALL player information in the database. Information gets passed here from the client side file: core\session\fn_updateRequest.sqf */ -private ["_uid","_side","_cash","_bank","_licenses","_gear","_stats","_name","_alive","_position","_query","_thread"]; -_uid = [_this,0,"",[""]] call BIS_fnc_param; -_name = [_this,1,"",[""]] call BIS_fnc_param; -_side = [_this,2,sideUnknown,[civilian]] call BIS_fnc_param; -_cash = [_this,3,0,[0]] call BIS_fnc_param; -_bank = [_this,4,5000,[0]] call BIS_fnc_param; -_licenses = [_this,5,[],[[]]] call BIS_fnc_param; -_gear = [_this,6,[],[[]]] call BIS_fnc_param; -_stats = [_this,7,[100,100],[[]]] call BIS_fnc_param; -_alive = [_this,9,false,[true]] call BIS_fnc_param; -_position = [_this,10,[],[[]]] call BIS_fnc_param; + +params [ + ["_uid", "", [""]], + ["_name", "", [""]], + ["_side", sideUnknown, [civilian]], + ["_cash", 0, [0]], + ["_bank", 5000, [0]], + ["_licenses", [], [[]]], + ["_gear", [], [[]]], + ["_stats", [100,100],[[]]], + ["_arrested", false, [true]], + ["_alive", false, [true]], + ["_position", [], [[]]] +]; //Get to those error checks. -if ((_uid isEqualTo "") || (_name isEqualTo "")) exitWith {}; +if (_uid isEqualTo "" || {_name isEqualTo ""}) exitWith {}; -//Parse and setup some data. -_name = [_name] call DB_fnc_mresString; -_gear = [_gear] call DB_fnc_mresArray; -_stats = [_stats] call DB_fnc_mresArray; -_cash = [_cash] call DB_fnc_numberSafe; -_bank = [_bank] call DB_fnc_numberSafe; -_position = if (_side isEqualTo civilian) then {[_position] call DB_fnc_mresArray} else {[]}; +//Setup some data. +_position = if (_side isEqualTo civilian) then {_position} else {[]}; +_arrested = [0, 1] select _arrested; +_alive = [0, 1] select _alive; -//Does something license related but I can't remember I only know it's important? -for "_i" from 0 to count(_licenses)-1 do { - _bool = [(_licenses select _i) select 1] call DB_fnc_bool; - _licenses set[_i,[(_licenses select _i) select 0,_bool]]; +for "_i" from 0 to (count _licenses) -1 do { + (_licenses select _i) params ["_license", "_owned"]; + _licenses set[_i, [_license, [0, 1] select _owned]]; }; -_licenses = [_licenses] call DB_fnc_mresArray; - //PLAYTIME _playtime = [_uid] call TON_fnc_getPlayTime; _playtime_update = []; @@ -52,13 +49,11 @@ switch (_side) do { case civilian: {_playtime_update set[2,_playtime];}; case independent: {_playtime_update set[1,_playtime];}; }; -_playtime_update = [_playtime_update] call DB_fnc_mresArray; -switch (_side) do { - case west: {_query = format ["UPDATE players SET name='%1', cash='%2', bankacc='%3', cop_gear='%4', cop_licenses='%5', cop_stats='%6', playtime='%7' WHERE pid='%8'",_name,_cash,_bank,_gear,_licenses,_stats,_playtime_update,_uid];}; - case civilian: {_query = format ["UPDATE players SET name='%1', cash='%2', bankacc='%3', civ_licenses='%4', civ_gear='%5', arrested='%6', civ_stats='%7', civ_alive='%8', civ_position='%9', playtime='%10' WHERE pid='%11'",_name,_cash,_bank,_licenses,_gear,[_this select 8] call DB_fnc_bool,_stats,[_alive] call DB_fnc_bool,_position,_playtime_update,_uid];}; - case independent: {_query = format ["UPDATE players SET name='%1', cash='%2', bankacc='%3', med_licenses='%4', med_gear='%5', med_stats='%6', playtime='%7' WHERE pid='%8'",_name,_cash,_bank,_licenses,_gear,_stats,_playtime_update,_uid];}; +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; +_queryResult = [_query, 1] call DB_fnc_asyncCall; diff --git a/life_server/Functions/Systems/fn_chopShopSell.sqf b/life_server/Functions/Systems/fn_chopShopSell.sqf old mode 100644 new mode 100755 index 100f62901..2522d77d7 --- a/life_server/Functions/Systems/fn_chopShopSell.sqf +++ b/life_server/Functions/Systems/fn_chopShopSell.sqf @@ -6,26 +6,35 @@ Description: Checks whether or not the vehicle is persistent or temp and sells it. */ + params [ - ["_unit",objNull,[objNull]], - ["_vehicle",objNull,[objNull]], - ["_price",500,[0]] + ["_unit", objNull, [objNull]], + ["_vehicle", objNull, [objNull]], + ["_price", 500, [0]], + ["_cash", 0, [0]] ]; //Error checks -if (isNull _vehicle || isNull _unit) exitWith { - [] remoteExecCall ["life_fnc_chopShopSold", remoteExecutedOwner]; +if (isNull _vehicle || {isNull _unit}) exitWith { + life_action_inUse = false; + owner _unit publicVariableClient "life_action_inUse"; }; -private _displayName = FETCH_CONFIG2(getText,"CfgVehicles",typeOf _vehicle, "displayName"); +_displayName = FETCH_CONFIG2(getText, "CfgVehicles", typeOf _vehicle, "displayName"); +_unit = owner _unit; + +_dbInfo = _vehicle getVariable ["dbInfo", []]; +if !(_dbInfo isEqualTo []) then { + _uid = (_dbInfo select 0); + _plate = (_dbInfo select 1); -private _dbInfo = _vehicle getVariable ["dbInfo",[]]; -if (count _dbInfo > 0) then { - _dbInfo params ["_uid","_plate"]; - private _query = format ["UPDATE vehicles SET alive='0' WHERE pid='%1' AND plate='%2'",_uid,_plate]; - [_query,1] call DB_fnc_asyncCall; + _query = format ["deleteVehicle:%1:%2", _uid, _plate]; + _sql = [_query, 1] call DB_fnc_asyncCall; }; deleteVehicle _vehicle; - -[_price,_displayName] remoteExecCall ["life_fnc_chopShopSold", remoteExecutedOwner]; \ No newline at end of file +life_action_inUse = false; +_unit publicVariableClient "life_action_inUse"; +CASH = _cash; +_unit publicVariableClient "life_cash"; +[2, "STR_NOTF_ChopSoldCar", true, [_displayName, [_price] call life_fnc_numberText]] remoteExecCall ["life_fnc_broadcast", _unit]; diff --git a/life_server/Functions/Systems/fn_cleanup.sqf b/life_server/Functions/Systems/fn_cleanup.sqf old mode 100644 new mode 100755 index f3351e81b..99612e4ea --- a/life_server/Functions/Systems/fn_cleanup.sqf +++ b/life_server/Functions/Systems/fn_cleanup.sqf @@ -41,13 +41,12 @@ for "_i" from 0 to 1 step 0 do { }; if (isNull _veh) then { - if (count _dbInfo > 0) then { + if !(_dbInfo isEqualTo []) then { _uid = _dbInfo select 0; _plate = _dbInfo select 1; - _query = format ["UPDATE vehicles SET active='0', fuel='%3' WHERE pid='%1' AND plate='%2'",_uid,_plate,_fuel]; - - [_query,1] call DB_fnc_asyncCall; + _query = format ["cleanupVehicle:%1:%2:%3", _fuel, _uid, _plate]; + [_query, 1] call DB_fnc_asyncCall; }; }; }; diff --git a/life_server/Functions/Systems/fn_getVehicles.sqf b/life_server/Functions/Systems/fn_getVehicles.sqf old mode 100644 new mode 100755 index 9cf95f78a..e89bf0e83 --- a/life_server/Functions/Systems/fn_getVehicles.sqf +++ b/life_server/Functions/Systems/fn_getVehicles.sqf @@ -6,14 +6,16 @@ Description: Sends a request to query the database information and returns vehicles. */ -private ["_pid","_side","_type","_unit","_ret","_tickTime","_queryResult"]; -_pid = [_this,0,"",[""]] call BIS_fnc_param; -_side = [_this,1,sideUnknown,[west]] call BIS_fnc_param; -_type = [_this,2,"",[""]] call BIS_fnc_param; -_unit = [_this,3,objNull,[objNull]] call BIS_fnc_param; + +params [ + ["_pid", "", [""]], + ["_side", sideUnknown, [west]], + ["_type", "", [""]], + ["_unit", objNull, [objNull]] +]; //Error checks -if (_pid isEqualTo "" || _side isEqualTo sideUnknown || _type isEqualTo "" || isNull _unit) exitWith { +if (_pid isEqualTo "" || {_side isEqualTo sideUnknown} || {_type isEqualTo ""} || {isNull _unit}) exitWith { if (!isNull _unit) then { [[]] remoteExec ["life_fnc_impoundMenu",(owner _unit)]; }; @@ -27,26 +29,25 @@ _side = switch (_side) do { default {"Error"}; }; -if (_side == "Error") exitWith { - [[]] remoteExec ["life_fnc_impoundMenu",(owner _unit)]; +if (_side isEqualTo "Error") exitWith { + [[]] remoteExec ["life_fnc_impoundMenu", (owner _unit)]; }; -_query = format ["SELECT id, side, classname, type, pid, alive, active, plate, color FROM vehicles WHERE pid='%1' AND alive='1' AND active='0' AND side='%2' AND type='%3'",_pid,_side,_type]; - +private _query = format ["selectVehicles:%1:%2:%3", _pid, _side, _type]; -_tickTime = diag_tickTime; -_queryResult = [_query,2,true] call DB_fnc_asyncCall; +private _tickTime = diag_tickTime; +private _queryResult = [_query, 2, true] 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 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 "") exitWith { - [[]] remoteExec ["life_fnc_impoundMenu",(owner _unit)]; + [[]] remoteExec ["life_fnc_impoundMenu", (owner _unit)]; }; -[_queryResult] remoteExec ["life_fnc_impoundMenu",_unit]; +[_queryResult] remoteExec ["life_fnc_impoundMenu", _unit]; diff --git a/life_server/Functions/Systems/fn_spawnVehicle.sqf b/life_server/Functions/Systems/fn_spawnVehicle.sqf old mode 100644 new mode 100755 index a03cafb13..3eaddef48 --- a/life_server/Functions/Systems/fn_spawnVehicle.sqf +++ b/life_server/Functions/Systems/fn_spawnVehicle.sqf @@ -7,6 +7,7 @@ Sends the query request to the database, if an array is returned then it creates the vehicle if it's not in use or dead. */ + params [ ["_vid", -1, [0]], ["_pid", "", [""]], @@ -28,10 +29,10 @@ serv_sv_use pushBack _vid; private _servIndex = serv_sv_use find _vid; -private _query = format ["SELECT id, side, classname, type, pid, alive, active, plate, color, inventory, gear, fuel, damage, blacklist FROM vehicles WHERE id='%1' AND pid='%2'",_vid,_pid]; +private _query = format ["selectVehiclesMore:%1:%2", _vid, _pid]; private _tickTime = diag_tickTime; -private _queryResult = [_query,2] call DB_fnc_asyncCall; +private _queryResult = [_query, 2] call DB_fnc_asyncCall; if (EXTDB_SETTING(getNumber,"DebugMode") isEqualTo 1) then { diag_log "------------- Client Query Request -------------"; @@ -45,7 +46,7 @@ if (_queryResult isEqualType "") exitWith {}; private _vInfo = _queryResult; if (isNil "_vInfo") exitWith {serv_sv_use deleteAt _servIndex;}; -if (count _vInfo isEqualTo 0) exitWith {serv_sv_use deleteAt _servIndex;}; +if (_vInfo isEqualTo []) exitWith {serv_sv_use deleteAt _servIndex;}; if ((_vInfo select 5) isEqualTo 0) exitWith { serv_sv_use deleteAt _servIndex; @@ -64,21 +65,21 @@ if !(_sp isEqualType "") then { _nearVehicles = []; }; -if (count _nearVehicles > 0) exitWith { +if !(_nearVehicles isEqualTo []) exitWith { serv_sv_use deleteAt _servIndex; [_price,_unit_return] remoteExecCall ["life_fnc_garageRefund",_unit]; [1,"STR_Garage_SpawnPointError",true] remoteExecCall ["life_fnc_broadcast",_unit]; }; -_query = format ["UPDATE vehicles SET active='1', damage='""[]""' WHERE pid='%1' AND id='%2'",_pid,_vid]; +_query = format ["updateVehicle:%1:%2", _pid, _vid]; -private _trunk = [(_vInfo select 9)] call DB_fnc_mresToArray; -private _gear = [(_vInfo select 10)] call DB_fnc_mresToArray; -private _damage = [call compile (_vInfo select 12)] call DB_fnc_mresToArray; +private _trunk = _vInfo select 9; +private _gear = _vInfo select 10; +private _damage = _vInfo select 12; private _wasIllegal = _vInfo select 13; -_wasIllegal = if (_wasIllegal isEqualTo 1) then { true } else { false }; +_wasIllegal = _wasIllegal isEqualTo 1; -[_query,1] call DB_fnc_asyncCall; +[_query, 1] call DB_fnc_asyncCall; private "_vehicle"; if (_sp isEqualType "") then { @@ -111,42 +112,42 @@ _vehicle disableTIEquipment true; //No Thermals.. They're cheap but addictive. if (LIFE_SETTINGS(getNumber,"save_vehicle_virtualItems") isEqualTo 1) then { _vehicle setVariable ["Trunk",_trunk,true]; - + if (_wasIllegal) then { private _refPoint = if (_sp isEqualType "") then {getMarkerPos _sp;} else {_sp;}; - + private _distance = 100000; private "_location"; { private _tempLocation = nearestLocation [_refPoint, _x]; private _tempDistance = _refPoint distance _tempLocation; - + if (_tempDistance < _distance) then { _location = _tempLocation; _distance = _tempDistance; }; false - + } count ["NameCityCapital", "NameCity", "NameVillage"]; - + _location = text _location; - [1,"STR_NOTF_BlackListedVehicle",true,[_location,_name]] remoteExecCall ["life_fnc_broadcast",west]; + [1, "STR_NOTF_BlackListedVehicle", true, [_location, _name]] remoteExecCall ["life_fnc_broadcast", west]; - _query = format ["UPDATE vehicles SET blacklist='0' WHERE id='%1' AND pid='%2'",_vid,_pid]; - [_query,1] call DB_fnc_asyncCall; + _query = format ["updateVehicleBlacklist:%1:%2", _vid, _pid]; + [_query, 1] call DB_fnc_asyncCall; }; } else { - _vehicle setVariable ["Trunk",[[],0],true]; + _vehicle setVariable ["Trunk", [[], 0], true]; }; if (LIFE_SETTINGS(getNumber,"save_vehicle_fuel") isEqualTo 1) then { _vehicle setFuel (_vInfo select 11); - }else{ +} else { _vehicle setFuel 1; }; -if (count _gear > 0 && (LIFE_SETTINGS(getNumber,"save_vehicle_inventory") isEqualTo 1)) then { +if (!(_gear isEqualTo []) && (LIFE_SETTINGS(getNumber,"save_vehicle_inventory") isEqualTo 1)) then { _items = _gear select 0; _mags = _gear select 1; _weapons = _gear select 2; @@ -166,7 +167,7 @@ if (count _gear > 0 && (LIFE_SETTINGS(getNumber,"save_vehicle_inventory") isEqua }; }; -if (count _damage > 0 && (LIFE_SETTINGS(getNumber,"save_vehicle_damage") isEqualTo 1)) then { +if (!(_damage isEqualTo []) && (LIFE_SETTINGS(getNumber,"save_vehicle_damage") isEqualTo 1)) then { _parts = getAllHitPointsDamage _vehicle; for "_i" from 0 to ((count _damage) - 1) do { diff --git a/life_server/Functions/Systems/fn_vehicleCreate.sqf b/life_server/Functions/Systems/fn_vehicleCreate.sqf old mode 100644 new mode 100755 index 844ec7374..078215457 --- a/life_server/Functions/Systems/fn_vehicleCreate.sqf +++ b/life_server/Functions/Systems/fn_vehicleCreate.sqf @@ -5,17 +5,19 @@ Description: Answers the query request to create the vehicle in the database. */ -private ["_uid","_side","_type","_classname","_color","_plate"]; -_uid = [_this,0,"",[""]] call BIS_fnc_param; -_side = [_this,1,sideUnknown,[west]] call BIS_fnc_param; -_vehicle = [_this,2,objNull,[objNull]] call BIS_fnc_param; -_color = [_this,3,-1,[0]] call BIS_fnc_param; + +params [ + ["_uid", "", [""]], + ["_side", sideUnknown, [west]], + ["_vehicle", objNull, [objNull]], + ["_color", -1, [0]] +]; //Error checks -if (_uid isEqualTo "" || _side isEqualTo sideUnknown || isNull _vehicle) exitWith {}; +if (_uid isEqualTo "" || {_side isEqualTo sideUnknown} || {isNull _vehicle}) exitWith {}; if (!alive _vehicle) exitWith {}; -_className = typeOf _vehicle; -_type = switch (true) do { +private _className = typeOf _vehicle; +private _type = switch (true) do { case (_vehicle isKindOf "Car"): {"Car"}; case (_vehicle isKindOf "Air"): {"Air"}; case (_vehicle isKindOf "Ship"): {"Ship"}; @@ -28,7 +30,7 @@ _side = switch (_side) do { default {"Error"}; }; -_plate = round(random(1000000)); -[_uid,_side,_type,_classname,_color,_plate] call DB_fnc_insertVehicle; +private _plate = round(random(1000000)); +[_uid, _side, _type, _classname, _color, _plate] call DB_fnc_insertVehicle; -_vehicle setVariable ["dbInfo",[_uid,_plate],true]; +_vehicle setVariable ["dbInfo", [_uid, _plate], true]; diff --git a/life_server/Functions/Systems/fn_vehicleDelete.sqf b/life_server/Functions/Systems/fn_vehicleDelete.sqf old mode 100644 new mode 100755 index 09bd48033..a3b3622c5 --- a/life_server/Functions/Systems/fn_vehicleDelete.sqf +++ b/life_server/Functions/Systems/fn_vehicleDelete.sqf @@ -6,16 +6,16 @@ Doesn't actually delete since we don't give our DB user that type of access so instead we set it to alive=0 so it never shows again. */ -private ["_vid","_sp","_pid","_query","_type","_thread"]; -_vid = [_this,0,-1,[0]] call BIS_fnc_param; -_pid = [_this,1,"",[""]] call BIS_fnc_param; -_sp = [_this,2,2500,[0]] call BIS_fnc_param; -_unit = [_this,3,objNull,[objNull]] call BIS_fnc_param; -_type = [_this,4,"",[""]] call BIS_fnc_param; -if (_vid isEqualTo -1 || _pid isEqualTo "" || _sp isEqualTo 0 || isNull _unit || _type isEqualTo "") exitWith {}; -_unit = owner _unit; +params [ + ["_vid", -1, [0]], + ["_pid", "", [""]], + ["_sp", 2500, [0]], + ["_unit", objNull, [objNull]], + ["_type", "", [""]] +]; -_query = format ["UPDATE vehicles SET alive='0' WHERE pid='%1' AND id='%2'",_pid,_vid]; +if (_vid isEqualTo -1 || {_pid isEqualTo ""} || {_sp isEqualTo 0} || {isNull _unit} || {_type isEqualTo ""}) exitWith {}; -_thread = [_query,1] call DB_fnc_asyncCall; \ No newline at end of file +private _query = format ["deleteVehicleID:%1:%2", _pid, _vid]; +private _thread = [_query, 1] call DB_fnc_asyncCall; diff --git a/life_server/Functions/Systems/fn_vehicleStore.sqf b/life_server/Functions/Systems/fn_vehicleStore.sqf old mode 100644 new mode 100755 index f4963f449..b93bf8668 --- a/life_server/Functions/Systems/fn_vehicleStore.sqf +++ b/life_server/Functions/Systems/fn_vehicleStore.sqf @@ -5,39 +5,47 @@ Description: Stores the vehicle in the 'Garage' */ -private ["_vehicle","_impound","_vInfo","_vInfo","_plate","_uid","_query","_sql","_unit","_trunk","_vehItems","_vehMags","_vehWeapons","_vehBackpacks","_cargo","_saveItems","_storetext","_resourceItems","_fuel","_damage","_itemList","_totalweight","_weight","_thread"]; -_vehicle = [_this,0,objNull,[objNull]] call BIS_fnc_param; -_impound = [_this,1,false,[true]] call BIS_fnc_param; -_unit = [_this,2,objNull,[objNull]] call BIS_fnc_param; -_storetext = [_this,3,"",[""]] call BIS_fnc_param; -_resourceItems = LIFE_SETTINGS(getArray,"save_vehicle_items"); -if (isNull _vehicle || isNull _unit) exitWith {life_impound_inuse = false; (owner _unit) publicVariableClient "life_impound_inuse";life_garage_store = false;(owner _unit) publicVariableClient "life_garage_store";}; //Bad data passed. -_vInfo = _vehicle getVariable ["dbInfo",[]]; +params [ + ["_vehicle", objNull, [objNull]], + ["_impound", false, [true]], + ["_unit", objNull, [objNull]], + ["_storetext", "", [""]] +]; -if (count _vInfo > 0) then { +private _resourceItems = LIFE_SETTINGS(getArray,"save_vehicle_items"); + +if (isNull _vehicle || {isNull _unit}) exitWith {life_impound_inuse = false; (owner _unit) publicVariableClient "life_impound_inuse";life_garage_store = false;(owner _unit) publicVariableClient "life_garage_store";}; //Bad data passed. +private _vInfo = _vehicle getVariable ["dbInfo", []]; +private "_plate"; +private "_uid"; + +if !(_vInfo isEqualTo []) then { _plate = _vInfo select 1; _uid = _vInfo select 0; }; // save damage. +private "_damage"; if (LIFE_SETTINGS(getNumber,"save_vehicle_damage") isEqualTo 1) then { _damage = getAllHitPointsDamage _vehicle; _damage = _damage select 2; - } else { +} else { _damage = []; }; -_damage = [_damage] call DB_fnc_mresArray; // because fuel price! +private "_fuel"; if (LIFE_SETTINGS(getNumber,"save_vehicle_fuel") isEqualTo 1) then { _fuel = (fuel _vehicle); - } else { +} else { _fuel = 1; }; +private "_query"; +private "_thread"; if (_impound) exitWith { - if (count _vInfo isEqualTo 0) then { + if (_vInfo isEqualTo []) then { life_impound_inuse = false; (owner _unit) publicVariableClient "life_impound_inuse"; @@ -45,7 +53,7 @@ if (_impound) exitWith { deleteVehicle _vehicle; }; } else { // no free repairs! - _query = format ["UPDATE vehicles SET active='0', fuel='%3', damage='%4' WHERE pid='%1' AND plate='%2'",_uid , _plate, _fuel, _damage]; + _query = format ["updateVehicleFuel:%1:%2:%3:%4", _fuel, _damage, _uid, _plate]; _thread = [_query,1] call DB_fnc_asyncCall; if (!isNil "_vehicle" && {!isNull _vehicle}) then { @@ -58,7 +66,7 @@ if (_impound) exitWith { }; // not persistent so just do this! -if (count _vInfo isEqualTo 0) exitWith { +if (_vInfo isEqualTo []) exitWith { [1,"STR_Garage_Store_NotPersistent",true] remoteExecCall ["life_fnc_broadcast",(owner _unit)]; life_garage_store = false; (owner _unit) publicVariableClient "life_garage_store"; @@ -71,20 +79,20 @@ if !(_uid isEqualTo getPlayerUID _unit) exitWith { }; // sort out whitelisted items! -_trunk = _vehicle getVariable ["Trunk", [[], 0]]; -_itemList = _trunk select 0; -_totalweight = 0; +private _trunk = _vehicle getVariable ["Trunk", [[], 0]]; +private _itemList = _trunk select 0; +private _totalweight = 0; +private "_weight"; _items = []; if (LIFE_SETTINGS(getNumber,"save_vehicle_virtualItems") isEqualTo 1) then { if (LIFE_SETTINGS(getNumber,"save_vehicle_illegal") isEqualTo 1) then { - private ["_isIllegal", "_blacklist"]; - _blacklist = false; - _profileQuery = format ["SELECT name FROM players WHERE pid='%1'", _uid]; + private _blacklist = false; + _profileQuery = format ["selectName:%1", _uid]; _profileName = [_profileQuery, 2] call DB_fnc_asyncCall; _profileName = _profileName select 0; { - _isIllegal = M_CONFIG(getNumber,"VirtualItems",(_x select 0),"illegal"); + private _isIllegal = M_CONFIG(getNumber,"VirtualItems",(_x select 0),"illegal"); _isIllegal = if (_isIllegal isEqualTo 1) then { true } else { false }; @@ -102,7 +110,7 @@ if (LIFE_SETTINGS(getNumber,"save_vehicle_virtualItems") isEqualTo 1) then { if (_blacklist) then { [_uid, _profileName, "481"] remoteExecCall["life_fnc_wantedAdd", RSERV]; - _query = format ["UPDATE vehicles SET blacklist='1' WHERE pid='%1' AND plate='%2'", _uid, _plate]; + _query = format ["updateVehicleBlacklistPlate:%1:%2", _uid, _plate]; _thread = [_query, 1] call DB_fnc_asyncCall; }; @@ -124,23 +132,22 @@ else { _trunk = [[], 0]; }; +private "_cargo"; + if (LIFE_SETTINGS(getNumber,"save_vehicle_inventory") isEqualTo 1) then { - _vehItems = getItemCargo _vehicle; - _vehMags = getMagazineCargo _vehicle; - _vehWeapons = getWeaponCargo _vehicle; - _vehBackpacks = getBackpackCargo _vehicle; - _cargo = [_vehItems,_vehMags,_vehWeapons,_vehBackpacks]; + private _vehItems = getItemCargo _vehicle; + private _vehMags = getMagazineCargo _vehicle; + private _vehWeapons = getWeaponCargo _vehicle; + private _vehBackpacks = getBackpackCargo _vehicle; + _cargo = [_vehItems, _vehMags, _vehWeapons, _vehBackpacks]; // no items? clean the array so the database looks pretty - if ((count (_vehItems select 0) isEqualTo 0) && (count (_vehMags select 0) isEqualTo 0) && (count (_vehWeapons select 0) isEqualTo 0) && (count (_vehBackpacks select 0) isEqualTo 0)) then {_cargo = [];}; + if (((_vehItems select 0) isEqualTo []) && ((_vehMags select 0) isEqualTo []) && ((_vehWeapons select 0) isEqualTo []) && ((_vehBackpacks select 0) isEqualTo [])) then {_cargo = [];}; } else { _cargo = []; }; -// prepare -_trunk = [_trunk] call DB_fnc_mresArray; -_cargo = [_cargo] call DB_fnc_mresArray; // update -_query = format ["UPDATE vehicles SET active='0', inventory='%3', gear='%4', fuel='%5', damage='%6' WHERE pid='%1' AND plate='%2'", _uid, _plate, _trunk, _cargo, _fuel, _damage]; +_query = format ["updateVehicleAll:%1:%2:%3:%4:%5:%6", _trunk, _cargo, _fuel, _damage, _uid, _plate]; _thread = [_query,1] call DB_fnc_asyncCall; if (!isNil "_vehicle" && {!isNull _vehicle}) then { diff --git a/life_server/Functions/Systems/fn_vehicleUpdate.sqf b/life_server/Functions/Systems/fn_vehicleUpdate.sqf old mode 100644 new mode 100755 index bf59eab04..dc685b4f9 --- a/life_server/Functions/Systems/fn_vehicleUpdate.sqf +++ b/life_server/Functions/Systems/fn_vehicleUpdate.sqf @@ -6,51 +6,53 @@ Description: Tells the database that this vehicle need update inventory. */ -private ["_vehicle","_plate","_uid","_query","_sql","_dbInfo","_thread","_cargo","_trunk","_resourceItems","_fuel","_damage","_itemList","_totalweight","_weight"]; -_vehicle = [_this,0,objNull,[objNull]] call BIS_fnc_param; -_mode = [_this,1,1,[0]] call BIS_fnc_param; + +params [ + ["_vehicle", objNull, [objNull]], + ["_mode", 1, [0]] +]; + if (isNull _vehicle) exitWith {}; //NULL -_dbInfo = _vehicle getVariable ["dbInfo",[]]; -if (count _dbInfo isEqualTo 0) exitWith {}; -_uid = _dbInfo select 0; -_plate = _dbInfo select 1; +private _dbInfo = _vehicle getVariable ["dbInfo",[]]; +if (_dbInfo isEqualTo []) exitWith {}; + +private _uid = _dbInfo select 0; +private _plate = _dbInfo select 1; + switch (_mode) do { case 1: { - _vehItems = getItemCargo _vehicle; - _vehMags = getMagazineCargo _vehicle; - _vehWeapons = getWeaponCargo _vehicle; - _vehBackpacks = getBackpackCargo _vehicle; - _cargo = [_vehItems,_vehMags,_vehWeapons,_vehBackpacks]; + private _vehItems = getItemCargo _vehicle; + private _vehMags = getMagazineCargo _vehicle; + private _vehWeapons = getWeaponCargo _vehicle; + private _vehBackpacks = getBackpackCargo _vehicle; + private _cargo = [_vehItems,_vehMags,_vehWeapons,_vehBackpacks]; // Keep it clean! - if ((count (_vehItems select 0) isEqualTo 0) && (count (_vehMags select 0) isEqualTo 0) && (count (_vehWeapons select 0) isEqualTo 0) && (count (_vehBackpacks select 0) isEqualTo 0)) then { + if (((_vehItems select 0) isEqualTo []) && ((_vehMags select 0) isEqualTo []) && ((_vehWeapons select 0) isEqualTo []) && ((_vehBackpacks select 0) isEqualTo [])) then { _cargo = []; }; - _cargo = [_cargo] call DB_fnc_mresArray; - - _query = format ["UPDATE vehicles SET gear='%3' WHERE pid='%1' AND plate='%2'",_uid,_plate,_cargo]; - _thread = [_query,1] call DB_fnc_asyncCall; + private _query = format ["updateVehicleGear:%1:%2:%3", _cargo, _uid, _plate]; + private _thread = [_query, 1] call DB_fnc_asyncCall; }; case 2: { - _resourceItems = LIFE_SETTINGS(getArray,"save_vehicle_items"); - _trunk = _vehicle getVariable ["Trunk",[[],0]]; - _itemList = _trunk select 0; - _totalweight = 0; - _items = []; + private _resourceItems = LIFE_SETTINGS(getArray,"save_vehicle_items"); + private _trunk = _vehicle getVariable ["Trunk",[[],0]]; + private _itemList = _trunk select 0; + private _totalweight = 0; + private _items = []; { if ((_x select 0) in _resourceItems) then { _items pushBack [_x select 0,_x select 1]; - _weight = (ITEM_WEIGHT(_x select 0)) * (_x select 1); + private _weight = (ITEM_WEIGHT(_x select 0)) * (_x select 1); _totalweight = _weight + _totalweight; }; - }forEach _itemList; + } forEach _itemList; _trunk = [_items,_totalweight]; - _trunk = [_trunk] call DB_fnc_mresArray; - _query = format ["UPDATE vehicles SET inventory='%3' WHERE pid='%1' AND plate='%2'",_uid,_plate,_trunk]; - _thread = [_query,1] call DB_fnc_asyncCall; + private _query = format ["updateVehicleTrunk:%1:%2:%3", _trunk, _uid, _plate]; + private _thread = [_query,1] call DB_fnc_asyncCall; }; -}; \ No newline at end of file +}; diff --git a/life_server/Functions/WantedSystem/fn_wantedAdd.sqf b/life_server/Functions/WantedSystem/fn_wantedAdd.sqf old mode 100644 new mode 100755 index 1114c1053..000efff8d --- a/life_server/Functions/WantedSystem/fn_wantedAdd.sqf +++ b/life_server/Functions/WantedSystem/fn_wantedAdd.sqf @@ -8,6 +8,7 @@ Description: Adds or appends a unit to the wanted list. */ + params [ ["_uid","",[""]], ["_name","",[""]], @@ -19,35 +20,33 @@ if (_uid isEqualTo "" || {_type isEqualTo ""} || {_name isEqualTo ""}) exitWith //What is the crime? private _crimesConfig = getArray(missionConfigFile >> "Life_Settings" >> "crimes"); -private _index = [_type,_crimesConfig] call TON_fnc_index; +private _index = [_type, _crimesConfig] call TON_fnc_index; if (_index isEqualTo -1) exitWith {}; _type = [_type, parseNumber ((_crimesConfig select _index) select 1)]; -if (count _type isEqualTo 0) exitWith {}; //Not our information being passed... +if (_type isEqualTo []) exitWith {}; //Not our information being passed... //Is there a custom bounty being sent? Set that as the pricing. if !(_customBounty isEqualTo -1) then {_type set[1,_customBounty];}; //Search the wanted list to make sure they are not on it. -private _query = format ["SELECT wantedID FROM wanted WHERE wantedID='%1'",_uid]; +private _query = format ["selectWantedID:%1", _uid]; private _queryResult = [_query,2,true] call DB_fnc_asyncCall; -private _val = [_type select 1] call DB_fnc_numberSafe; +private _val = _type select 1; private _number = _type select 0; -if !(count _queryResult isEqualTo 0) then { - _query = format ["SELECT wantedCrimes, wantedBounty FROM wanted WHERE wantedID='%1'",_uid]; +if !(_queryResult isEqualTo []) then { + _query = format ["selectWantedCrimes:%1", _uid]; _queryResult = [_query,2] call DB_fnc_asyncCall; - _pastCrimes = [_queryResult select 0] call DB_fnc_mresToArray; + _pastCrimes = _queryResult select 0; if (_pastCrimes isEqualType "") then {_pastCrimes = call compile format ["%1", _pastCrimes];}; _pastCrimes pushBack _number; - _pastCrimes = [_pastCrimes] call DB_fnc_mresArray; - _query = format ["UPDATE wanted SET wantedCrimes = '%1', wantedBounty = wantedBounty + '%2', active = '1' WHERE wantedID='%3'",_pastCrimes,_val,_uid]; + _query = format ["updateWanted:%1:%2:%3", _pastCrimes, _val, _uid]; [_query,1] call DB_fnc_asyncCall; } else { _crime = [_type select 0]; - _crime = [_crime] call DB_fnc_mresArray; - _query = format ["INSERT INTO wanted (wantedID, wantedName, wantedCrimes, wantedBounty, active) VALUES('%1', '%2', '%3', '%4', '1')",_uid,_name,_crime,_val]; + _query = format ["insertWanted:%1:%2:%3:%4", _uid, _name, _crime, _val]; [_query,1] call DB_fnc_asyncCall; }; diff --git a/life_server/Functions/WantedSystem/fn_wantedBounty.sqf b/life_server/Functions/WantedSystem/fn_wantedBounty.sqf old mode 100644 new mode 100755 index 3a41b0080..5cc334532 --- a/life_server/Functions/WantedSystem/fn_wantedBounty.sqf +++ b/life_server/Functions/WantedSystem/fn_wantedBounty.sqf @@ -8,6 +8,7 @@ Description: Checks if the person is on the bounty list and awards the cop for killing them. */ + params [ ["_uid","",[""]], ["_civ",objNull,[objNull]], @@ -17,11 +18,11 @@ params [ if (isNull _civ || isNull _cop) exitWith {}; -private _query = format ["SELECT wantedID, wantedName, wantedCrimes, wantedBounty FROM wanted WHERE active='1' AND wantedID='%1'",_uid]; +private _query = format ["selectWanted:%1", _uid]; private _queryResult = [_query,2] call DB_fnc_asyncCall; private "_amount"; -if !(count _queryResult isEqualTo 0) then { +if !(_queryResult isEqualTo []) then { _amount = _queryResult param [3]; if !(_amount isEqualTo 0) then { if (_half) then { @@ -30,4 +31,4 @@ if !(count _queryResult isEqualTo 0) then { [_amount,_amount] remoteExecCall ["life_fnc_bountyReceive",(owner _cop)]; }; }; -}; \ No newline at end of file +}; diff --git a/life_server/Functions/WantedSystem/fn_wantedCrimes.sqf b/life_server/Functions/WantedSystem/fn_wantedCrimes.sqf old mode 100644 new mode 100755 index 58668a495..176898f0f --- a/life_server/Functions/WantedSystem/fn_wantedCrimes.sqf +++ b/life_server/Functions/WantedSystem/fn_wantedCrimes.sqf @@ -8,6 +8,7 @@ Description: Grabs a list of crimes committed by a person. */ + disableSerialization; params [ @@ -15,12 +16,12 @@ params [ ["_criminal",[],[]] ]; -private _query = format ["SELECT wantedCrimes, wantedBounty FROM wanted WHERE active='1' AND wantedID='%1'",_criminal select 0]; -private _queryResult = [_query,2] call DB_fnc_asyncCall; +private _query = format ["selectWantedActive:%1", _criminal select 0]; +private _queryResult = [_query, 2] call DB_fnc_asyncCall; _ret = owner _ret; -private _type = [_queryResult select 0] call DB_fnc_mresToArray; +private _type = _queryResult select 0; if (_type isEqualType "") then {_type = call compile format ["%1", _type];}; private _crimesArr = []; @@ -30,6 +31,6 @@ private _crimesArr = []; false } count _type; -_queryResult set[0,_crimesArr]; +_queryResult set[0, _crimesArr]; -[_queryResult] remoteExec ["life_fnc_wantedInfo",_ret]; +[_queryResult] remoteExec ["life_fnc_wantedInfo", _ret]; diff --git a/life_server/Functions/WantedSystem/fn_wantedFetch.sqf b/life_server/Functions/WantedSystem/fn_wantedFetch.sqf old mode 100644 new mode 100755 index 826cf8141..f80041657 --- a/life_server/Functions/WantedSystem/fn_wantedFetch.sqf +++ b/life_server/Functions/WantedSystem/fn_wantedFetch.sqf @@ -9,7 +9,11 @@ Description: Displays wanted list information sent from the server. */ -private _ret = param [0,objNull,[objNull]]; + +params [ + ["_ret", objNull, [objNull]] +]; + if (isNull _ret) exitWith {}; _ret = owner _ret; private _inStatement = ""; @@ -20,7 +24,7 @@ private _units = []; false } count playableUnits; -if (count _units isEqualTo 0) exitWith {[_list] remoteExec ["life_fnc_wantedList",_ret];}; +if (_units isEqualTo []) exitWith {[_list] remoteExec ["life_fnc_wantedList",_ret];}; { if (count _units > 1) then { @@ -34,7 +38,7 @@ if (count _units isEqualTo 0) exitWith {[_list] remoteExec ["life_fnc_wantedList }; } forEach _units; -private _query = format ["SELECT wantedID, wantedName FROM wanted WHERE active='1' AND wantedID in (%1)",_inStatement]; +private _query = format ["selectWantedActiveID:%1", _inStatement]; private _queryResult = [_query,2,true] call DB_fnc_asyncCall; if (EXTDB_SETTING(getNumber,"DebugMode") isEqualTo 1) then { diag_log format ["Query: %1",_query]; @@ -45,6 +49,6 @@ if (EXTDB_SETTING(getNumber,"DebugMode") isEqualTo 1) then { false } count _queryResult; -if (count _list isEqualTo 0) exitWith {[_list] remoteExec ["life_fnc_wantedList",_ret];}; +if (_list isEqualTo []) exitWith {[_list] remoteExec ["life_fnc_wantedList",_ret];}; [_list] remoteExec ["life_fnc_wantedList",_ret]; diff --git a/life_server/Functions/WantedSystem/fn_wantedPerson.sqf b/life_server/Functions/WantedSystem/fn_wantedPerson.sqf old mode 100644 new mode 100755 index 4c5b6e663..f057a4307 --- a/life_server/Functions/WantedSystem/fn_wantedPerson.sqf +++ b/life_server/Functions/WantedSystem/fn_wantedPerson.sqf @@ -8,13 +8,16 @@ Description: Fetches a specific person from the wanted array. */ -private _unit = param [0,objNull,[objNull]]; + +params [ + ["_unit", objNull, [objNull]] +]; if (isNull _unit) exitWith {[]}; private _uid = getPlayerUID _unit; -private _query = format ["SELECT wantedID, wantedName, wantedBounty FROM wanted WHERE active='1' AND wantedID='%1'",_uid]; +private _query = format ["selectWantedBounty:%1", _uid]; private _queryResult = [_query,2] call DB_fnc_asyncCall; -if (count _queryResult isEqualTo 0) exitWith {[]}; +if (_queryResult isEqualTo []) exitWith {[]}; _queryResult; diff --git a/life_server/Functions/WantedSystem/fn_wantedProfUpdate.sqf b/life_server/Functions/WantedSystem/fn_wantedProfUpdate.sqf old mode 100644 new mode 100755 index e472a6cc9..cb89c4804 --- a/life_server/Functions/WantedSystem/fn_wantedProfUpdate.sqf +++ b/life_server/Functions/WantedSystem/fn_wantedProfUpdate.sqf @@ -6,20 +6,20 @@ Description: Updates name of player if they change profiles */ -private ["_query","_tickTime","_wantedCheck","_wantedQuery"]; + params [ ["_uid","",[""]], ["_name","",[""]] ]; //Bad data check -if (_uid isEqualTo "" || {_name isEqualTo ""}) exitWith {}; +if (_uid isEqualTo "" || {_name isEqualTo ""}) exitWith {}; -_wantedCheck = format ["SELECT wantedName FROM wanted WHERE wantedID='%1'",_uid]; -_wantedQuery = [_wantedCheck,2] call DB_fnc_asyncCall; -if (count _wantedQuery isEqualTo 0) exitWith {}; +private _wantedCheck = format ["selectWantedName:%1", _uid]; +private _wantedQuery = [_wantedCheck, 2] call DB_fnc_asyncCall; +if (_wantedQuery isEqualTo []) exitWith {}; if !(_name isEqualTo (_wantedQuery select 0)) then { - _query = format ["UPDATE wanted SET wantedName='%1' WHERE wantedID='%2'",_name,_uid]; - [_query,2] call DB_fnc_asyncCall; + private _query = format ["updateWantedName:%1:%2", _name, _uid]; + [_query, 2] call DB_fnc_asyncCall; }; diff --git a/life_server/Functions/WantedSystem/fn_wantedRemove.sqf b/life_server/Functions/WantedSystem/fn_wantedRemove.sqf old mode 100644 new mode 100755 index 0b1ffaacd..c5af59c5b --- a/life_server/Functions/WantedSystem/fn_wantedRemove.sqf +++ b/life_server/Functions/WantedSystem/fn_wantedRemove.sqf @@ -8,9 +8,12 @@ Description: Removes a person from the wanted list. */ -private _uid = param [0,"",[""]]; + +params [ + ["_uid", "", [""]] +]; if (_uid isEqualTo "") exitWith {}; //Bad data -private _query = format ["UPDATE wanted SET active = '0', wantedCrimes = '[]', wantedBounty = 0 WHERE wantedID='%1'",_uid]; -[_query,2] call DB_fnc_asyncCall; \ No newline at end of file +private _query = format ["deleteWanted:%1", _uid]; +[_query, 2] call DB_fnc_asyncCall; diff --git a/life_server/config.cpp b/life_server/config.cpp index 57adf021b..3456d3693 100644 --- a/life_server/config.cpp +++ b/life_server/config.cpp @@ -15,16 +15,11 @@ class CfgFunctions { class MySQL { file = "\life_server\Functions\MySQL"; - class numberSafe {}; - class mresArray {}; class queryRequest{}; class asyncCall{}; class insertRequest{}; class updateRequest{}; - class mresToArray {}; class insertVehicle {}; - class bool {}; - class mresString {}; class updatePartial {}; }; }; diff --git a/life_server/init.sqf b/life_server/init.sqf index 73b571e22..e6303119c 100644 --- a/life_server/init.sqf +++ b/life_server/init.sqf @@ -43,7 +43,7 @@ if (isNil {uiNamespace getVariable "life_sql_id"}) then { try { _result = EXTDB format ["9:ADD_DATABASE:%1",EXTDB_SETTING(getText,"DatabaseName")]; if (!(_result isEqualTo "[1]")) then {throw "extDB3: Error with Database Connection"}; - _result = EXTDB format ["9:ADD_DATABASE_PROTOCOL:%2:SQL:%1:TEXT2",FETCH_CONST(life_sql_id),EXTDB_SETTING(getText,"DatabaseName")]; + _result = EXTDB format ["9:ADD_DATABASE_PROTOCOL:%2:SQL_CUSTOM:%1:AL.ini",FETCH_CONST(life_sql_id),EXTDB_SETTING(getText,"DatabaseName")]; if (!(_result isEqualTo "[1]")) then {throw "extDB3: Error with Database Connection"}; } catch { diag_log _exception; @@ -67,10 +67,10 @@ life_server_extDB_notLoaded = false; publicVariable "life_server_extDB_notLoaded"; /* Run stored procedures for SQL side cleanup */ -["CALL resetLifeVehicles",1] call DB_fnc_asyncCall; -["CALL deleteDeadVehicles",1] call DB_fnc_asyncCall; -["CALL deleteOldHouses",1] call DB_fnc_asyncCall; -["CALL deleteOldGangs",1] call DB_fnc_asyncCall; +["resetLifeVehicles", 1] call DB_fnc_asyncCall; +["deleteDeadVehicles", 1] call DB_fnc_asyncCall; +["deleteOldHouses", 1] call DB_fnc_asyncCall; +["deleteOldGangs", 1] call DB_fnc_asyncCall; _timeStamp = diag_tickTime; diag_log "----------------------------------------------------------------------------------------------------"; @@ -80,7 +80,7 @@ diag_log "---------------------------------------------------------------------- if (LIFE_SETTINGS(getNumber,"save_civilian_position_restart") isEqualTo 1) then { [] spawn { - _query = "UPDATE players SET civ_alive = '0' WHERE civ_alive = '1'"; + ["updateCivAlive", 1] call DB_fnc_asyncCall; [_query,1] call DB_fnc_asyncCall; }; }; From 19a097b70d468cfd3ffacdd4de663c90f328b0f3 Mon Sep 17 00:00:00 2001 From: Jason Hall Date: Mon, 30 Dec 2019 17:31:59 +0000 Subject: [PATCH 02/12] Remove references to houseCleanup --- life_hc/config.cpp | 1 - life_hc/initHC.sqf | 1 - 2 files changed, 2 deletions(-) diff --git a/life_hc/config.cpp b/life_hc/config.cpp index 1d1f4a057..da33046a0 100755 --- a/life_hc/config.cpp +++ b/life_hc/config.cpp @@ -48,7 +48,6 @@ class CfgFunctions class addHouse {}; class deleteDBContainer {}; class fetchPlayerHouses {}; - class houseCleanup {}; class sellHouse {}; class sellHouseContainer {}; class updateHouseContainers {}; diff --git a/life_hc/initHC.sqf b/life_hc/initHC.sqf index 916ff8d5f..9e2c55569 100644 --- a/life_hc/initHC.sqf +++ b/life_hc/initHC.sqf @@ -86,7 +86,6 @@ HC_MPAllowedFuncs = [ "hc_fnc_addhouse", "hc_fnc_deletedbcontainer", "hc_fnc_fetchplayerhouses", - "hc_fnc_housecleanup", "hc_fnc_sellhouse", "hc_fnc_sellhousecontainer", "hc_fnc_updatehousecontainers", From 1c2d3413aa9fd96ccdfcea6f187c242ca6e96022 Mon Sep 17 00:00:00 2001 From: Jason Hall Date: Mon, 30 Dec 2019 17:39:58 +0000 Subject: [PATCH 03/12] Update SQL file to previous consistency --- altislife.sql | 201 ++++++++++++++++++++++++++++---------------------- 1 file changed, 113 insertions(+), 88 deletions(-) diff --git a/altislife.sql b/altislife.sql index 578b8d7ed..810f3e74e 100755 --- a/altislife.sql +++ b/altislife.sql @@ -73,37 +73,39 @@ DELIMITER ; -- CREATE TABLE IF NOT EXISTS `players` ( - `uid` int(6) NOT NULL AUTO_INCREMENT, - `name` varchar(32) NOT NULL, - `aliases` text NOT NULL, - `pid` varchar(17) NOT NULL, - `cash` int(100) NOT NULL DEFAULT '0', - `bankacc` int(100) 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(32) NOT NULL DEFAULT '[100,100,0]', - `cop_stats` varchar(32) NOT NULL DEFAULT '[100,100,0]', - `med_stats` varchar(32) NOT NULL DEFAULT '[100,100,0]', - `arrested` tinyint(1) 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(1) NOT NULL DEFAULT '0', - `civ_alive` tinyint(1) NOT NULL DEFAULT '0', - `civ_position` varchar(64) 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 (`uid`), - UNIQUE KEY `pid` (`pid`), - KEY `name` (`name`), - KEY `blacklist` (`blacklist`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=12 ; + `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; + -- -------------------------------------------------------- @@ -112,26 +114,30 @@ CREATE TABLE IF NOT EXISTS `players` ( -- CREATE TABLE IF NOT EXISTS `vehicles` ( - `id` int(6) NOT NULL AUTO_INCREMENT, - `side` varchar(16) NOT NULL, - `classname` varchar(64) NOT NULL, - `type` varchar(16) NOT NULL, - `pid` varchar(17) NOT NULL, - `alive` tinyint(1) NOT NULL DEFAULT '1', - `blacklist` tinyint(1) NOT NULL DEFAULT '0', - `active` tinyint(1) NOT NULL DEFAULT '0', - `plate` int(20) NOT NULL, - `color` int(20) 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`), - KEY `side` (`side`), - KEY `pid` (`pid`), - KEY `type` (`type`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=2 ; + `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; -- -------------------------------------------------------- @@ -141,14 +147,19 @@ CREATE TABLE IF NOT EXISTS `vehicles` ( -- CREATE TABLE IF NOT EXISTS `houses` ( - `id` int(6) NOT NULL AUTO_INCREMENT, - `pid` varchar(17) NOT NULL, - `pos` varchar(64) DEFAULT NULL, - `owned` tinyint(1) DEFAULT '0', - `garage` tinyint(1) NOT NULL DEFAULT '0', - `insert_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY (`id`,`pid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=4 ; + `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; -- -------------------------------------------------------- @@ -158,16 +169,21 @@ CREATE TABLE IF NOT EXISTS `houses` ( -- CREATE TABLE IF NOT EXISTS `gangs` ( - `id` int(6) NOT NULL AUTO_INCREMENT, - `owner` varchar(32) DEFAULT NULL, - `name` varchar(32) DEFAULT NULL, - `members` text, - `maxmembers` int(3) DEFAULT '8', - `bank` int(100) DEFAULT '0', - `active` tinyint(1) DEFAULT '1', - `insert_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY (`id`), - UNIQUE KEY `name_UNIQUE` (`name`) + `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; -- -------------------------------------------------------- @@ -178,18 +194,23 @@ CREATE TABLE IF NOT EXISTS `gangs` ( -- CREATE TABLE IF NOT EXISTS `containers` ( - `id` int(6) NOT NULL AUTO_INCREMENT, - `pid` varchar(17) NOT NULL, - `classname` varchar(32) NOT NULL, - `pos` varchar(64) DEFAULT NULL, - `inventory` text NOT NULL, - `gear` text NOT NULL, - `dir` varchar(128) DEFAULT NULL, - `active` tinyint(1) NOT NULL DEFAULT '0', - `owned` tinyint(1) DEFAULT '0', - `insert_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY (`id`,`pid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=4; + `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; -- -------------------------------------------------------- @@ -199,13 +220,17 @@ CREATE TABLE IF NOT EXISTS `containers` ( -- CREATE TABLE IF NOT EXISTS `wanted` ( - `wantedID` varchar(64) NOT NULL, - `wantedName` varchar(32) NOT NULL, - `wantedCrimes` text NOT NULL, - `wantedBounty` int(100) NOT NULL, - `active` tinyint(1) NOT NULL DEFAULT '0', - `insert_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY (`wantedID`) + `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; -- -------------------------------------------------------- From 571d6d473c73223ddcb6f0233c8df8b3cadcbd5d Mon Sep 17 00:00:00 2001 From: Jason Hall Date: Mon, 30 Dec 2019 18:04:42 +0000 Subject: [PATCH 04/12] Add removed code for processing gang funds --- life_hc/MySQL/Gangs/fn_updateGang.sqf | 33 +++++++++++++++++++ life_server/Functions/Gangs/fn_updateGang.sqf | 33 +++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/life_hc/MySQL/Gangs/fn_updateGang.sqf b/life_hc/MySQL/Gangs/fn_updateGang.sqf index 460435aec..f820d682b 100755 --- a/life_hc/MySQL/Gangs/fn_updateGang.sqf +++ b/life_hc/MySQL/Gangs/fn_updateGang.sqf @@ -32,6 +32,39 @@ switch (_mode) do { }; case 1: { + params [ + "", + "", + ["_deposit",false,[false]], + ["_value",0,[0]], + ["_unit",objNull,[objNull]], + ["_cash",0,[0]] + ]; + + private _funds = _group getVariable ["gang_bank",0]; + if (_deposit) then { + _funds = _funds + _value; + _group setVariable ["gang_bank",_funds,true]; + [1,"STR_ATM_DepositSuccessG",true,[_value]] remoteExecCall ["life_fnc_broadcast",remoteExecutedOwner]; + _cash = _cash - _value; + } else { + if (_value > _funds) exitWith { + [1,"STR_ATM_NotEnoughFundsG",true] remoteExecCall ["life_fnc_broadcast",remoteExecutedOwner]; + breakOut ""; + }; + _funds = _funds - _value; + _group setVariable ["gang_bank",_funds,true]; + [_value] remoteExecCall ["life_fnc_gangBankResponse",remoteExecutedOwner]; + _cash = _cash + _value; + }; + if (LIFE_SETTINGS(getNumber,"player_moneyLog") isEqualTo 1) then { + if (LIFE_SETTINGS(getNumber,"battlEye_friendlyLogging") isEqualTo 1) then { + diag_log (format [localize "STR_DL_ML_withdrewGang_BEF",_value,[_funds] call life_fnc_numberText,[0] call life_fnc_numberText,[_cash] call life_fnc_numberText]); + } else { + diag_log (format [localize "STR_DL_ML_withdrewGang",name _unit,(getPlayerUID _unit),_value,[_funds] call life_fnc_numberText,[0] call life_fnc_numberText,[_cash] call life_fnc_numberText]); + }; + }; + [getPlayerUID _unit,side _unit,_cash,0] call HC_fnc_updatePartial; _query = format ["updateGangBank:%1:%2", _group getVariable ["gang_bank", 0], _groupID]; }; diff --git a/life_server/Functions/Gangs/fn_updateGang.sqf b/life_server/Functions/Gangs/fn_updateGang.sqf index 6263a09df..17d121a98 100755 --- a/life_server/Functions/Gangs/fn_updateGang.sqf +++ b/life_server/Functions/Gangs/fn_updateGang.sqf @@ -30,6 +30,39 @@ switch (_mode) do { }; case 1: { + params [ + "", + "", + ["_deposit",false,[false]], + ["_value",0,[0]], + ["_unit",objNull,[objNull]], + ["_cash",0,[0]] + ]; + + private _funds = _group getVariable ["gang_bank",0]; + if (_deposit) then { + _funds = _funds + _value; + _group setVariable ["gang_bank",_funds,true]; + [1,"STR_ATM_DepositSuccessG",true,[_value]] remoteExecCall ["life_fnc_broadcast",remoteExecutedOwner]; + _cash = _cash - _value; + } else { + if (_value > _funds) exitWith { + [1,"STR_ATM_NotEnoughFundsG",true] remoteExecCall ["life_fnc_broadcast",remoteExecutedOwner]; + breakOut ""; + }; + _funds = _funds - _value; + _group setVariable ["gang_bank",_funds,true]; + [_value] remoteExecCall ["life_fnc_gangBankResponse",remoteExecutedOwner]; + _cash = _cash + _value; + }; + if (LIFE_SETTINGS(getNumber,"player_moneyLog") isEqualTo 1) then { + if (LIFE_SETTINGS(getNumber,"battlEye_friendlyLogging") isEqualTo 1) then { + diag_log (format [localize "STR_DL_ML_withdrewGang_BEF",_value,[_funds] call life_fnc_numberText,[0] call life_fnc_numberText,[_cash] call life_fnc_numberText]); + } else { + diag_log (format [localize "STR_DL_ML_withdrewGang",name _unit,(getPlayerUID _unit),_value,[_funds] call life_fnc_numberText,[0] call life_fnc_numberText,[_cash] call life_fnc_numberText]); + }; + }; + [getPlayerUID _unit,side _unit,_cash,0] call DB_fnc_updatePartial; _query = format ["updateGangBank:%1:%2", _group getVariable ["gang_bank", 0], _groupID]; }; From a647ced4f67f83ed0f218535e82a8f8e8f42c05b Mon Sep 17 00:00:00 2001 From: Jason Hall Date: Mon, 30 Dec 2019 18:19:09 +0000 Subject: [PATCH 05/12] Use the correct function prefix for the HC --- life_hc/initHC.sqf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/life_hc/initHC.sqf b/life_hc/initHC.sqf index 9e2c55569..1655c96f9 100644 --- a/life_hc/initHC.sqf +++ b/life_hc/initHC.sqf @@ -48,10 +48,10 @@ if (_extDBNotLoaded isEqualType []) then { if (_extDBNotLoaded isEqualType []) exitWith {}; //extDB3-HC did not fully initialize so terminate the rest of the initialization process. -["resetLifeVehicles", 1] call DB_fnc_asyncCall; -["deleteDeadVehicles", 1] call DB_fnc_asyncCall; -["deleteOldHouses", 1] call DB_fnc_asyncCall; -["deleteOldGangs", 1] call DB_fnc_asyncCall; +["resetLifeVehicles", 1] call HC_fnc_asyncCall; +["deleteDeadVehicles", 1] call HC_fnc_asyncCall; +["deleteOldHouses", 1] call HC_fnc_asyncCall; +["deleteOldGangs", 1] call HC_fnc_asyncCall; _timeStamp = diag_tickTime; diag_log "----------------------------------------------------------------------------------------------------"; From 0f942264868fb8418d2011e632b9296912b4044f Mon Sep 17 00:00:00 2001 From: Jason Hall Date: Mon, 30 Dec 2019 18:47:57 +0000 Subject: [PATCH 06/12] Update houseCleanup to current standards --- life_server/Functions/Housing/fn_houseCleanup.sqf | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/life_server/Functions/Housing/fn_houseCleanup.sqf b/life_server/Functions/Housing/fn_houseCleanup.sqf index de84c1da6..177272f1a 100755 --- a/life_server/Functions/Housing/fn_houseCleanup.sqf +++ b/life_server/Functions/Housing/fn_houseCleanup.sqf @@ -1,19 +1,20 @@ /* File: fn_houseCleanup.sqf Author: NiiRoZz - Description: Cleans up containers inside in house of player. */ +params [ + ["_uid","",[""]] +]; private _query = format ["selectContainerPositions:%1", _this]; -private _containers = [_query, 2, true] call DB_fnc_asyncCall; +private _containers = [_query,2,true] call DB_fnc_asyncCall; -if (_containers isEqualTo []) exitWith {}; { - _pos = call compile format ["%1", _x select 1]; - _container = nearestObjects[_pos, ["Box_IND_Grenades_F", "B_supplyCrate_F"], 12]; + _x params ["_pos"]; + _pos = parseSimpleArray _pos; { deleteVehicle _x; - } forEach _container; -} forEach _containers; + } forEach (nearestObjects[_pos,["Box_IND_Grenades_F","B_supplyCrate_F"],12]); +} forEach _containers; \ No newline at end of file From 81aa6053f8a6cef136a0307c32069f50ca76ebf1 Mon Sep 17 00:00:00 2001 From: Jason Hall Date: Mon, 30 Dec 2019 20:42:13 +0000 Subject: [PATCH 07/12] Add macros to updateGang files --- life_hc/MySQL/Gangs/fn_updateGang.sqf | 1 + life_server/Functions/Gangs/fn_updateGang.sqf | 1 + 2 files changed, 2 insertions(+) diff --git a/life_hc/MySQL/Gangs/fn_updateGang.sqf b/life_hc/MySQL/Gangs/fn_updateGang.sqf index f820d682b..e6bb5c245 100755 --- a/life_hc/MySQL/Gangs/fn_updateGang.sqf +++ b/life_hc/MySQL/Gangs/fn_updateGang.sqf @@ -1,3 +1,4 @@ +#include "\life_hc\hc_macros.hpp" /* File: fn_updateGang.sqf Author: Bryan "Tonic" Boardwine diff --git a/life_server/Functions/Gangs/fn_updateGang.sqf b/life_server/Functions/Gangs/fn_updateGang.sqf index 17d121a98..01c25aa42 100755 --- a/life_server/Functions/Gangs/fn_updateGang.sqf +++ b/life_server/Functions/Gangs/fn_updateGang.sqf @@ -1,3 +1,4 @@ +#include "\life_server\script_macros.hpp" /* File: fn_updateGang.sqf Author: Bryan "Tonic" Boardwine From 8f4383d6fa063364e8b295470ca5e68958661339 Mon Sep 17 00:00:00 2001 From: Jason Hall Date: Tue, 31 Dec 2019 00:37:46 +0000 Subject: [PATCH 08/12] Update chop shop files to current --- life_hc/MySQL/Vehicles/fn_chopShopSell.sqf | 35 +++++++++++++++++++ .../Functions/Systems/fn_chopShopSell.sqf | 34 +++++++----------- 2 files changed, 47 insertions(+), 22 deletions(-) diff --git a/life_hc/MySQL/Vehicles/fn_chopShopSell.sqf b/life_hc/MySQL/Vehicles/fn_chopShopSell.sqf index 85a7d7927..a04526aef 100755 --- a/life_hc/MySQL/Vehicles/fn_chopShopSell.sqf +++ b/life_hc/MySQL/Vehicles/fn_chopShopSell.sqf @@ -41,3 +41,38 @@ _ownerUnit publicVariableClient "life_action_inUse"; CASH = _cash; _ownerUnit publicVariableClient "life_cash"; [2, "STR_NOTF_ChopSoldCar", true, [_displayName, [_price] call life_fnc_numberText]] remoteExecCall ["life_fnc_broadcast", _unit]; + + +#include "\life_hc\hc_macros.hpp" +/* + File: fn_chopShopSell.sqf + Author: Bryan "Tonic" Boardwine + + This file is for Nanou's HeadlessClient. + + Description: + Checks whether or not the vehicle is persistent or temp and sells it. +*/ +params [ + ["_unit",objNull,[objNull]], + ["_vehicle",objNull,[objNull]], + ["_price",500,[0]] +]; + +//Error checks +if (isNull _vehicle || isNull _unit) exitWith { + [] remoteExecCall ["life_fnc_chopShopSold", remoteExecutedOwner]; +}; + +private _displayName = FETCH_CONFIG2(getText,"CfgVehicles",typeOf _vehicle, "displayName"); + +private _dbInfo = _vehicle getVariable ["dbInfo",[]]; +if (count _dbInfo > 0) then { + _dbInfo params ["_uid","_plate"]; + private _query = format ["deleteVehicle:%1:%2", _uid, _plate]; + [_query,1] call HC_fnc_asyncCall; +}; + +deleteVehicle _vehicle; + +[_price,_displayName] remoteExecCall ["life_fnc_chopShopSold", remoteExecutedOwner]; diff --git a/life_server/Functions/Systems/fn_chopShopSell.sqf b/life_server/Functions/Systems/fn_chopShopSell.sqf index 2522d77d7..512d65394 100755 --- a/life_server/Functions/Systems/fn_chopShopSell.sqf +++ b/life_server/Functions/Systems/fn_chopShopSell.sqf @@ -2,39 +2,29 @@ /* File: fn_chopShopSell.sqf Author: Bryan "Tonic" Boardwine - Description: Checks whether or not the vehicle is persistent or temp and sells it. */ - params [ - ["_unit", objNull, [objNull]], - ["_vehicle", objNull, [objNull]], - ["_price", 500, [0]], - ["_cash", 0, [0]] + ["_unit",objNull,[objNull]], + ["_vehicle",objNull,[objNull]], + ["_price",500,[0]] ]; //Error checks -if (isNull _vehicle || {isNull _unit}) exitWith { - life_action_inUse = false; - owner _unit publicVariableClient "life_action_inUse"; +if (isNull _vehicle || isNull _unit) exitWith { + [] remoteExecCall ["life_fnc_chopShopSold", remoteExecutedOwner]; }; -_displayName = FETCH_CONFIG2(getText, "CfgVehicles", typeOf _vehicle, "displayName"); -_unit = owner _unit; - -_dbInfo = _vehicle getVariable ["dbInfo", []]; -if !(_dbInfo isEqualTo []) then { - _uid = (_dbInfo select 0); - _plate = (_dbInfo select 1); +private _displayName = FETCH_CONFIG2(getText,"CfgVehicles",typeOf _vehicle, "displayName"); +private _dbInfo = _vehicle getVariable ["dbInfo",[]]; +if (count _dbInfo > 0) then { + _dbInfo params ["_uid","_plate"]; _query = format ["deleteVehicle:%1:%2", _uid, _plate]; - _sql = [_query, 1] call DB_fnc_asyncCall; + [_query,1] call DB_fnc_asyncCall; }; deleteVehicle _vehicle; -life_action_inUse = false; -_unit publicVariableClient "life_action_inUse"; -CASH = _cash; -_unit publicVariableClient "life_cash"; -[2, "STR_NOTF_ChopSoldCar", true, [_displayName, [_price] call life_fnc_numberText]] remoteExecCall ["life_fnc_broadcast", _unit]; + +[_price,_displayName] remoteExecCall ["life_fnc_chopShopSold", remoteExecutedOwner]; \ No newline at end of file From 7cf122dd1752c720b07d107719b6ccf071a514c4 Mon Sep 17 00:00:00 2001 From: Jason Hall Date: Tue, 31 Dec 2019 00:40:39 +0000 Subject: [PATCH 09/12] Remove duplication --- life_hc/MySQL/Vehicles/fn_chopShopSell.sqf | 45 ---------------------- 1 file changed, 45 deletions(-) diff --git a/life_hc/MySQL/Vehicles/fn_chopShopSell.sqf b/life_hc/MySQL/Vehicles/fn_chopShopSell.sqf index a04526aef..1628eb5ec 100755 --- a/life_hc/MySQL/Vehicles/fn_chopShopSell.sqf +++ b/life_hc/MySQL/Vehicles/fn_chopShopSell.sqf @@ -1,48 +1,3 @@ -#include "\life_hc\hc_macros.hpp" -/* - File: fn_chopShopSell.sqf - Author: Bryan "Tonic" Boardwine - - This file is for Nanou's HeadlessClient. - - Description: - Checks whether or not the vehicle is persistent or temp and sells it. -*/ - -params [ - ["_unit", objNull, [objNull]], - ["_vehicle", objNull, [objNull]], - ["_price", 500, [0]], - ["_cash", 0, [0]] -]; - -_ownerUnit = _ownerUnit getVariable "life_clientID"; - -//Error checks -if (isNull _vehicle || {isNull _unit}) exitWith { - life_action_inUse = false; - _ownerUnit publicVariableClient "life_action_inUse"; -}; - -_displayName = FETCH_CONFIG2(getText, "CfgVehicles", typeOf _vehicle, "displayName"); - -_dbInfo = _vehicle getVariable ["dbInfo", []]; -if !(_dbInfo isEqualTo []) then { - _uid = (_dbInfo select 0); - _plate = (_dbInfo select 1); - - _query = format ["deleteVehicle:%1:%2", _uid, _plate]; - _sql = [_query, 1] call HC_fnc_asyncCall; -}; - -deleteVehicle _vehicle; -life_action_inUse = false; -_ownerUnit publicVariableClient "life_action_inUse"; -CASH = _cash; -_ownerUnit publicVariableClient "life_cash"; -[2, "STR_NOTF_ChopSoldCar", true, [_displayName, [_price] call life_fnc_numberText]] remoteExecCall ["life_fnc_broadcast", _unit]; - - #include "\life_hc\hc_macros.hpp" /* File: fn_chopShopSell.sqf From c130a99a0086bb5954cd336da64626b01b84d0ec Mon Sep 17 00:00:00 2001 From: Jason Hall Date: Tue, 31 Dec 2019 15:21:49 +0000 Subject: [PATCH 10/12] Fix gang disbanding and remove additional call to procedure --- life_hc/MySQL/Gangs/fn_removeGang.sqf | 10 +++------- life_server/Functions/Gangs/fn_removeGang.sqf | 10 +++------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/life_hc/MySQL/Gangs/fn_removeGang.sqf b/life_hc/MySQL/Gangs/fn_removeGang.sqf index 213516045..1b734170f 100755 --- a/life_hc/MySQL/Gangs/fn_removeGang.sqf +++ b/life_hc/MySQL/Gangs/fn_removeGang.sqf @@ -20,10 +20,6 @@ if (_groupID isEqualTo -1) exitWith {}; [format ["deleteGang:%1", _groupID], 1] call HC_fnc_asyncCall; -_result = [format ["selectGang:%1", _groupID], 2] call HC_fnc_asyncCall; -if (_result isEqualTo []) then { - [_group] remoteExecCall ["life_fnc_gangDisbanded",(units _group)]; - sleep 5; - deleteGroup _group; -}; -["deleteOldGangs", 1] call HC_fnc_asyncCall; +[_group] remoteExecCall ["life_fnc_gangDisbanded",(units _group)]; +uiSleep 5; +deleteGroup _group; diff --git a/life_server/Functions/Gangs/fn_removeGang.sqf b/life_server/Functions/Gangs/fn_removeGang.sqf index b4c01bd07..ea8accae0 100755 --- a/life_server/Functions/Gangs/fn_removeGang.sqf +++ b/life_server/Functions/Gangs/fn_removeGang.sqf @@ -18,10 +18,6 @@ if (_groupID isEqualTo -1) exitWith {}; [format ["deleteGang:%1", _groupID], 1] call DB_fnc_asyncCall; -_result = [format ["selectGang:%1", _groupID], 2] call DB_fnc_asyncCall; -if (_result isEqualTo []) then { - [_group] remoteExecCall ["life_fnc_gangDisbanded",(units _group)]; - uiSleep 5; - deleteGroup _group; -}; -["deleteOldGangs", 1] call DB_fnc_asyncCall; +[_group] remoteExecCall ["life_fnc_gangDisbanded", (units _group)]; +uiSleep 5; +deleteGroup _group; \ No newline at end of file From e6e5cf17b54ae4dc46ef3c366e3e7d5f9372ebad Mon Sep 17 00:00:00 2001 From: Jason Hall Date: Tue, 31 Dec 2019 15:25:56 +0000 Subject: [PATCH 11/12] Remove query from ini file --- AL.ini | 4 ---- 1 file changed, 4 deletions(-) diff --git a/AL.ini b/AL.ini index 3a1ad728b..b23904e72 100755 --- a/AL.ini +++ b/AL.ini @@ -122,10 +122,6 @@ SQL1_INPUTS = 1, 2, 3 -[selectGang] -SQL1_1 = SELECT id FROM gangs WHERE active = '1' AND id = ? -SQL1_INPUTS = 1 - [selectPlayerGang] SQL1_1 = SELECT id, owner, name, maxmembers, bank, members FROM gangs WHERE active = '1' AND members LIKE ? SQL1_INPUTS = 1 From f1d26d470b52e478aea35bf59eda63f33f9b8014 Mon Sep 17 00:00:00 2001 From: Jason Hall Date: Tue, 31 Dec 2019 16:00:56 +0000 Subject: [PATCH 12/12] Gang disband fix --- Altis_Life.Altis/core/gangs/fn_gangDisbanded.sqf | 6 +----- life_hc/MySQL/Gangs/fn_removeGang.sqf | 3 ++- life_server/Functions/Gangs/fn_removeGang.sqf | 1 + 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Altis_Life.Altis/core/gangs/fn_gangDisbanded.sqf b/Altis_Life.Altis/core/gangs/fn_gangDisbanded.sqf index 5dfef7638..7d1765ad4 100644 --- a/Altis_Life.Altis/core/gangs/fn_gangDisbanded.sqf +++ b/Altis_Life.Altis/core/gangs/fn_gangDisbanded.sqf @@ -11,8 +11,4 @@ if (isNull _group) exitWith {}; //Fail horn please. if (!isNull (findDisplay 2620)) then {closeDialog 2620}; hint localize "STR_GNOTF_DisbandWarn_2"; -[player] joinSilent (createGroup civilian); - -if (units _group isEqualTo []) then { - deleteGroup _group; -}; +[player] joinSilent (createGroup civilian); \ No newline at end of file diff --git a/life_hc/MySQL/Gangs/fn_removeGang.sqf b/life_hc/MySQL/Gangs/fn_removeGang.sqf index 1b734170f..6b24e7988 100755 --- a/life_hc/MySQL/Gangs/fn_removeGang.sqf +++ b/life_hc/MySQL/Gangs/fn_removeGang.sqf @@ -18,8 +18,9 @@ if (isNull _group) exitWith {}; private _groupID = _group getVariable ["gang_id",-1]; if (_groupID isEqualTo -1) exitWith {}; +_group setVariable ["gang_owner",nil,true]; [format ["deleteGang:%1", _groupID], 1] call HC_fnc_asyncCall; [_group] remoteExecCall ["life_fnc_gangDisbanded",(units _group)]; uiSleep 5; -deleteGroup _group; +deleteGroup _group; \ No newline at end of file diff --git a/life_server/Functions/Gangs/fn_removeGang.sqf b/life_server/Functions/Gangs/fn_removeGang.sqf index ea8accae0..cb5eb0c7a 100755 --- a/life_server/Functions/Gangs/fn_removeGang.sqf +++ b/life_server/Functions/Gangs/fn_removeGang.sqf @@ -16,6 +16,7 @@ if (isNull _group) exitWith {}; private _groupID = _group getVariable ["gang_id",-1]; if (_groupID isEqualTo -1) exitWith {}; +_group setVariable ["gang_owner",nil,true]; [format ["deleteGang:%1", _groupID], 1] call DB_fnc_asyncCall; [_group] remoteExecCall ["life_fnc_gangDisbanded", (units _group)];