Skip to content

Commit

Permalink
chore: fixed formatting errors in some functions
Browse files Browse the repository at this point in the history
  • Loading branch information
bitpredator committed Sep 1, 2024
1 parent 1225b61 commit 42ee486
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ AddEventHandler("esx:setJob", function(j)
grade = j.grade
end)

function isNearWorkbench()
function IsNearWorkbench()
local ped = PlayerPedId()
local coords = GetEntityCoords(ped)
local near = false
Expand All @@ -126,7 +126,7 @@ CreateThread(function()
while true do
Wait(1000)
if craftingQueue[1] ~= nil then
if not Config.CraftingStopWithDistance or (Config.CraftingStopWithDistance and isNearWorkbench()) then
if not Config.CraftingStopWithDistance or (Config.CraftingStopWithDistance and IsNearWorkbench()) then
craftingQueue[1].time = craftingQueue[1].time - 1

SendNUIMessage({
Expand All @@ -145,7 +145,7 @@ CreateThread(function()
end
end)

function openWorkbench(val)
function OpenWorkbench(val)
ESX.TriggerServerCallback("bpt_crafting:getXP", function(xp)
SetNuiFocus(true, true)
TriggerScreenblurFadeIn(1000)
Expand Down Expand Up @@ -200,7 +200,7 @@ CreateThread(function()
end

if open or #v.jobs == 0 then
openWorkbench(v)
OpenWorkbench(v)
else
ESX.ShowNotification(TranslateCap("wrong_job"))
end
Expand Down
2 changes: 1 addition & 1 deletion server-data/resources/[bpt_addons]/bpt_crafting/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ Config = {
requireBlueprint = false,
Time = 60,
Ingredients = {
["iron"] = 4,
["iron"] = 2,
["wood"] = 1,
},
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// eslint-disable-next-line no-unused-vars
let timeout;
let opened;
let recipes;
Expand Down Expand Up @@ -102,7 +101,6 @@ function openCategory() {

}

// eslint-disable-next-line no-unused-vars
function openCrafting(t) {

$('#main').html('');
Expand Down Expand Up @@ -287,7 +285,6 @@ function addToQueue(item, time, id) {

}

// eslint-disable-next-line no-unused-vars
function craft(t) {
const item = t.dataset.item;
$.post('https://bpt_crafting/craft', JSON.stringify({
Expand All @@ -299,11 +296,9 @@ function setProgress(p) {
const prog = (398 / 100) * p;
$('#u136').animate({
width: prog,
// eslint-disable-next-line no-empty-function
}, 500, function() {});
}

// eslint-disable-next-line no-unused-vars
function inspect(t) {
if (opened != t) {
opened = t;
Expand Down
20 changes: 10 additions & 10 deletions server-data/resources/[bpt_addons]/bpt_crafting/server/main.lua
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
ESX = exports["es_extended"]:getSharedObject()
function setCraftingLevel(identifier, level)
function SetCraftingLevel(identifier, level)
MySQL.Async.execute(
"UPDATE `users` SET `crafting_level`= @xp WHERE `identifier` = @identifier",
{ ["@xp"] = level, ["@identifier"] = identifier },
function() end
)
end

function getCraftingLevel(identifier)
function GetCraftingLevel(identifier)
return tonumber(
MySQL.Sync.fetchScalar(
"SELECT `crafting_level` FROM users WHERE identifier = @identifier ",
Expand All @@ -16,7 +16,7 @@ function getCraftingLevel(identifier)
)
end

function giveCraftingLevel(identifier, level)
function GiveCraftingLevel(identifier, level)
MySQL.Async.execute(
"UPDATE `users` SET `crafting_level`= `crafting_level` + @xp WHERE `identifier` = @identifier",
{ ["@xp"] = level, ["@identifier"] = identifier },
Expand All @@ -26,15 +26,15 @@ end

RegisterServerEvent("bpt_crafting:setExperiance")
AddEventHandler("bpt_crafting:setExperiance", function(identifier, xp)
setCraftingLevel(identifier, xp)
SetCraftingLevel(identifier, xp)
end)

RegisterServerEvent("bpt_crafting:giveExperiance")
AddEventHandler("bpt_crafting:giveExperiance", function(identifier, xp)
giveCraftingLevel(identifier, xp)
GiveCraftingLevel(identifier, xp)
end)

function craft(src, item, retrying)
function Craft(src, item, retrying)
local xPlayer = ESX.GetPlayerFromId(src)
local cancraft = true

Expand Down Expand Up @@ -111,7 +111,7 @@ AddEventHandler("bpt_crafting:itemCrafted", function(item, count)
xPlayer.addInventoryItem(item, count)
end
TriggerClientEvent("bpt_crafting:sendMessage", src, TranslateCap("item_crafted"))
giveCraftingLevel(xPlayer.identifier, Config.ExperiancePerCraft)
GiveCraftingLevel(xPlayer.identifier, Config.ExperiancePerCraft)
else
TriggerEvent("bpt_crafting:craft", item)
TriggerClientEvent("bpt_crafting:sendMessage", src, TranslateCap("inv_limit_exceed"))
Expand All @@ -124,7 +124,7 @@ AddEventHandler("bpt_crafting:itemCrafted", function(item, count)
xPlayer.addInventoryItem(item, count)
end
TriggerClientEvent("bpt_crafting:sendMessage", src, TranslateCap("item_crafted"))
giveCraftingLevel(xPlayer.identifier, Config.ExperiancePerCraft)
GiveCraftingLevel(xPlayer.identifier, Config.ExperiancePerCraft)
else
TriggerClientEvent("bpt_crafting:sendMessage", src, TranslateCap("inv_limit_exceed"))
end
Expand All @@ -137,13 +137,13 @@ end)
RegisterServerEvent("bpt_crafting:craft")
AddEventHandler("bpt_crafting:craft", function(item, retrying)
local src = source
craft(src, item, retrying)
Craft(src, item, retrying)
end)

ESX.RegisterServerCallback("bpt_crafting:getXP", function(source, cb)
local xPlayer = ESX.GetPlayerFromId(source)

cb(getCraftingLevel(xPlayer.identifier))
cb(GetCraftingLevel(xPlayer.identifier))
end)

ESX.RegisterServerCallback("bpt_crafting:getItemNames", function(_, cb)
Expand Down

0 comments on commit 42ee486

Please sign in to comment.