From 964f0004b1d19059c7b11b29ab9ae9e49d8674e1 Mon Sep 17 00:00:00 2001 From: Dolu <47056777+dolutattoo@users.noreply.github.com> Date: Fri, 9 Sep 2022 04:48:00 +0200 Subject: [PATCH 1/4] fix(esx_property): price not showing up when buying furniture Price was not showing up when confirming furniture placement --- [esx_addons]/esx_property/locales/en.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/[esx_addons]/esx_property/locales/en.lua b/[esx_addons]/esx_property/locales/en.lua index 50d4de9c..de9eeb8a 100644 --- a/[esx_addons]/esx_property/locales/en.lua +++ b/[esx_addons]/esx_property/locales/en.lua @@ -18,7 +18,7 @@ Locales['en'] = { ["place"] = "Place Furniture", ["delete_furni"] = "Delete", ["confirm_buy"] = "Do You Want To Buy %s ?", - ["price"] = "Price: $&s", + ["price"] = "Price: $%s", ["yes"] = "Yes", ["no"] = "No", ["action"] = "You %s ~b~%s~s~ !", From f621ab2a29787303512a52c24c8241c0888b04bd Mon Sep 17 00:00:00 2001 From: Dolu <47056777+dolutattoo@users.noreply.github.com> Date: Fri, 9 Sep 2022 04:48:59 +0200 Subject: [PATCH 2/4] fix(locales): 'Enter' button was set to 'Inventory' --- [esx_addons]/esx_property/locales/en.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/[esx_addons]/esx_property/locales/en.lua b/[esx_addons]/esx_property/locales/en.lua index de9eeb8a..6f402c68 100644 --- a/[esx_addons]/esx_property/locales/en.lua +++ b/[esx_addons]/esx_property/locales/en.lua @@ -108,7 +108,7 @@ Locales['en'] = { ["wardrobe_desc"] = "Change Position of Property Wardrobe.", ["Furniture_title"] = "Furniture", ["Furniture_desc"] = "Change Position of Property Wardrobe.", - ["enter_title"] = "Inventory", + ["enter_title"] = "Enter", ["knock_title"] = "Knock On Door", ["buy_title"] = "Buy", ["buy_desc"] = "Buy This Property For $%s", From d9659ef15104d6d357dc0472b9238fa69d1fa84b Mon Sep 17 00:00:00 2001 From: Dolu <47056777+dolutattoo@users.noreply.github.com> Date: Fri, 9 Sep 2022 04:51:58 +0200 Subject: [PATCH 3/4] fix(locales): use 'price' locale instead of raw english --- [esx_addons]/esx_property/client/furniture.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/[esx_addons]/esx_property/client/furniture.lua b/[esx_addons]/esx_property/client/furniture.lua index 1d718e2d..4c15bada 100644 --- a/[esx_addons]/esx_property/client/furniture.lua +++ b/[esx_addons]/esx_property/client/furniture.lua @@ -267,7 +267,7 @@ if Config.Furniture.Enabled then {title = _U("back"), value = "go-back", icon = "fas fa-arrow-left"}} for k, v in pairs(Config.FurnitureCatagories[Catagory]) do - table.insert(Items, {title = v.title, value = v.name, index = k, description = "Price: " .. v.price, icon = "fas fa-shopping-cart"}) + table.insert(Items, {title = v.title, value = v.name, index = k, description = _U("price", v.price), icon = "fas fa-shopping-cart"}) end ESX.OpenContext("right", Items, function(data, element) From 891e8e8aad5de4a5acd21d02b4f8a27128e6f6db Mon Sep 17 00:00:00 2001 From: Dolu <47056777+dolutattoo@users.noreply.github.com> Date: Fri, 9 Sep 2022 06:00:30 +0200 Subject: [PATCH 4/4] refactor(esx_property): refactor SQL part Check if `datastore` & `addon_account` tables exists before to insert stuff in it (to prevent console error) Use transactions to insert job grades + fix console print, because they were printing everytime the resource started. Now they only print when a row changed in database --- [esx_addons]/esx_property/server/main.lua | 100 ++++++++++++---------- 1 file changed, 53 insertions(+), 47 deletions(-) diff --git a/[esx_addons]/esx_property/server/main.lua b/[esx_addons]/esx_property/server/main.lua index 440ad971..5f840352 100644 --- a/[esx_addons]/esx_property/server/main.lua +++ b/[esx_addons]/esx_property/server/main.lua @@ -95,54 +95,60 @@ function IsPlayerAdmin(player, action) end CreateThread(function() - Wait(3000) - PropertiesRefresh() - MySQL.query("ALTER TABLE `users` ADD COLUMN IF NOT EXISTS `last_property` LONGTEXT NULL", function(result) - if result then - print("[^2INFO^7] Adding ^5last_property^7 column to users table") - end - end) - MySQL.insert("INSERT IGNORE INTO `datastore` (name, label, shared) VALUES ('property', 'Property' , 1)", function(result) - if result then - print("[^2INFO^7] Adding ^5Property^7 into ^5datastore^7 table") - end - end) - MySQL.insert("INSERT IGNORE INTO `datastore_data` (name, owner, data) VALUES ('property', NULL, '{}')", function(result) - if result then - print("[^2INFO^7] Adding ^5Property^7 into ^5datastore_data^7 table") - end - end) - if PM.Enabled then - MySQL.insert("INSERT IGNORE INTO `addon_account` (name, label, shared) VALUES (?, ? , 1)", {PM.society, PM.joblabel}, function(result) - if result then - print("[^2INFO^7] Adding ^5" .. PM.society .. " - " .. PM.joblabel .. "^7 into ^5addon_account^7 table") - end - end) - local Existance = ESX.DoesJobExist(PM.job, 0) - if not Existance then - MySQL.query("INSERT INTO `jobs` VALUES (?, ?, 1)", {PM.job, PM.joblabel}, function(result) - if result then - print("[^2INFO^7] Inserting ^5" .. PM.job .. " - " .. PM.joblabel .. "^7 into ^5jobs^7 table") - end - end) - end - for i = 1, #PM.jobRanks do - local Existance = ESX.DoesJobExist(PM.job, PM.jobRanks[i].grade) - if not Existance then - MySQL.query("INSERT INTO `job_grades` (job_name, grade, name, label, salary, skin_male, skin_female) VALUES (?, ?,?, ?, ?,'{}','{}')", - {PM.job, PM.jobRanks[i].grade, PM.jobRanks[i].name, PM.jobRanks[i].label, PM.jobRanks[i].salary}, function(result) - if result then - print("[^2INFO^7] Inserting ^5" .. PM.job .. " - " .. PM.jobRanks[i].grade .. " - " .. PM.jobRanks[i].label .. - "^7 into ^5job_grades^7 table") + Wait(3000) + PropertiesRefresh() + + MySQL.query("ALTER TABLE `users` ADD COLUMN IF NOT EXISTS `last_property` LONGTEXT NULL", function(result) + if result?.affectedRows > 0 then + print("[^2INFO^7] Added ^5last_property^7 column to users table") + end + end) + + -- Check if datastore table exists before to insert values. + if MySQL.scalar.await("SELECT EXISTS (SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_TYPE LIKE 'BASE TABLE' AND TABLE_NAME = 'datastore')") > 0 then + MySQL.insert("INSERT IGNORE INTO `datastore` (name, label, shared) VALUES ('property', 'Property' , 1)", function(affectedRows) + if affectedRows > 0 then + print("[^2INFO^7] Added ^5Property^7 into ^5datastore^7 table") + end + end) + MySQL.insert("INSERT IGNORE INTO `datastore_data` (name, owner, data) VALUES ('property', NULL, '{}')", function(affectedRows) + if affectedRows > 0 then + print("[^2INFO^7] Added ^5Property^7 into ^5datastore_data^7 table") + end + end) + end + + if PM.Enabled then + if MySQL.scalar.await("SELECT EXISTS (SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_TYPE LIKE 'BASE TABLE' AND TABLE_NAME = 'datastore')") > 0 then + MySQL.insert("INSERT IGNORE INTO `addon_account` (name, label, shared) VALUES (?, ? , 1)", {PM.society, PM.joblabel}, function(affectedRows) + if affectedRows > 0 then + print("[^2INFO^7] Added ^5" .. PM.society .. " - " .. PM.joblabel .. "^7 into ^5addon_account^7 table") + end + end) end - end) - end - end - Wait(10) - ESX.RefreshJobs() - TriggerEvent('esx_society:registerSociety', 'realestateagent', 'realestateagent', 'society_realestateagent', 'society_realestateagent', - 'society_realestateagent', {type = 'private'}) - end + if not ESX.DoesJobExist(PM.job, 0) then + MySQL.insert("INSERT INTO `jobs` SET name = ?, label = ?, whitelisted = 1", {PM.job, PM.joblabel}, function(affectedRows) + if affectedRows > 0 then + print("[^2INFO^7] Inserted ^5" .. PM.job .. " - " .. PM.joblabel .. "^7 into ^5jobs^7 table") + end + end) + end + + local QUERIES = {} + for i = 1, #PM.jobRanks do + if not ESX.DoesJobExist(PM.job, PM.jobRanks[i].grade) then + QUERIES[i] = { + query = "INSERT INTO `job_grades` SET job_name = ?, grade = ?, name = ?, label = ?, salary = ?, skin_male = '{}', skin_female = '{}'", + parameters = { PM.job, PM.jobRanks[i].grade, PM.jobRanks[i].name, PM.jobRanks[i].label, PM.jobRanks[i].salary } + } + end + end + MySQL.transaction(QUERIES) + + Wait(10) + ESX.RefreshJobs() + TriggerEvent('esx_society:registerSociety', 'realestateagent', 'realestateagent', 'society_realestateagent', 'society_realestateagent', 'society_realestateagent', {type = 'private'}) + end end) AddEventHandler("esx:playerLoaded", function(playerId, xPlayer)