diff --git a/server-data/resources/[bpt_addons]/bpt_farmer/client/animated.lua b/server-data/resources/[bpt_addons]/bpt_farmer/client/animated.lua index 67452b960..d365f2aa8 100644 --- a/server-data/resources/[bpt_addons]/bpt_farmer/client/animated.lua +++ b/server-data/resources/[bpt_addons]/bpt_farmer/client/animated.lua @@ -1,23 +1,23 @@ local playerPed -RegisterNetEvent('farmer:freeze') -AddEventHandler('farmer:freeze', function() +RegisterNetEvent("farmer:freeze") +AddEventHandler("farmer:freeze", function() playerPed = PlayerPedId() ClearPedTasks(PlayerPedId()) FreezeEntityPosition(playerPed, true) end) -RegisterNetEvent('farmer:unfreeze') -AddEventHandler('farmer:freeze', function() +RegisterNetEvent("farmer:unfreeze") +AddEventHandler("farmer:freeze", function() playerPed = PlayerPedId() FreezeEntityPosition(playerPed, false) ClearPedTasks(PlayerPedId()) end) -RegisterNetEvent('farmer:anim') -AddEventHandler('farmer:anim', function() - local lib, anim = 'amb@prop_human_bum_bin@idle_b', 'idle_d' - ESX.Streaming.RequestAnimDict(lib, function() - TaskPlayAnim(PlayerPedId(), lib, anim, 1.0, -3.0, 5000, 0, 0, false, false, false) - end) -end) \ No newline at end of file +RegisterNetEvent("farmer:anim") +AddEventHandler("farmer:anim", function() + local lib, anim = "amb@prop_human_bum_bin@idle_b", "idle_d" + ESX.Streaming.RequestAnimDict(lib, function() + TaskPlayAnim(PlayerPedId(), lib, anim, 1.0, -3.0, 5000, 0, 0, false, false, false) + end) +end) diff --git a/server-data/resources/[bpt_addons]/bpt_farmer/client/main.lua b/server-data/resources/[bpt_addons]/bpt_farmer/client/main.lua index d68d86b51..8086c5c61 100644 --- a/server-data/resources/[bpt_addons]/bpt_farmer/client/main.lua +++ b/server-data/resources/[bpt_addons]/bpt_farmer/client/main.lua @@ -1,21 +1,87 @@ local Keys = { - ["ESC"] = 322, ["F1"] = 288, ["F2"] = 289, ["F3"] = 170, ["F5"] = 166, ["F6"] = 167, ["F7"] = 168, ["F8"] = 169, ["F9"] = 56, ["F10"] = 57, - ["~"] = 243, ["1"] = 157, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["-"] = 84, ["="] = 83, ["BACKSPACE"] = 177, - ["TAB"] = 37, ["Q"] = 44, ["W"] = 32, ["E"] = 38, ["R"] = 45, ["T"] = 245, ["Y"] = 246, ["U"] = 303, ["P"] = 199, ["["] = 39, ["]"] = 40, ["ENTER"] = 18, - ["CAPS"] = 137, ["A"] = 34, ["S"] = 8, ["D"] = 9, ["F"] = 23, ["G"] = 47, ["H"] = 74, ["K"] = 311, ["L"] = 182, - ["LEFTSHIFT"] = 21, ["Z"] = 20, ["X"] = 73, ["C"] = 26, ["V"] = 0, ["B"] = 29, ["N"] = 249, ["M"] = 244, [","] = 82, ["."] = 81, - ["LEFTCTRL"] = 36, ["LEFTALT"] = 19, ["SPACE"] = 22, ["RIGHTCTRL"] = 70, - ["HOME"] = 213, ["PAGEUP"] = 10, ["PAGEDOWN"] = 11, ["DELETE"] = 178, - ["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173, - ["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118 + ["ESC"] = 322, + ["F1"] = 288, + ["F2"] = 289, + ["F3"] = 170, + ["F5"] = 166, + ["F6"] = 167, + ["F7"] = 168, + ["F8"] = 169, + ["F9"] = 56, + ["F10"] = 57, + ["~"] = 243, + ["1"] = 157, + ["2"] = 158, + ["3"] = 160, + ["4"] = 164, + ["5"] = 165, + ["6"] = 159, + ["7"] = 161, + ["8"] = 162, + ["9"] = 163, + ["-"] = 84, + ["="] = 83, + ["BACKSPACE"] = 177, + ["TAB"] = 37, + ["Q"] = 44, + ["W"] = 32, + ["E"] = 38, + ["R"] = 45, + ["T"] = 245, + ["Y"] = 246, + ["U"] = 303, + ["P"] = 199, + ["["] = 39, + ["]"] = 40, + ["ENTER"] = 18, + ["CAPS"] = 137, + ["A"] = 34, + ["S"] = 8, + ["D"] = 9, + ["F"] = 23, + ["G"] = 47, + ["H"] = 74, + ["K"] = 311, + ["L"] = 182, + ["LEFTSHIFT"] = 21, + ["Z"] = 20, + ["X"] = 73, + ["C"] = 26, + ["V"] = 0, + ["B"] = 29, + ["N"] = 249, + ["M"] = 244, + [","] = 82, + ["."] = 81, + ["LEFTCTRL"] = 36, + ["LEFTALT"] = 19, + ["SPACE"] = 22, + ["RIGHTCTRL"] = 70, + ["HOME"] = 213, + ["PAGEUP"] = 10, + ["PAGEDOWN"] = 11, + ["DELETE"] = 178, + ["LEFT"] = 174, + ["RIGHT"] = 175, + ["TOP"] = 27, + ["DOWN"] = 173, + ["NENTER"] = 201, + ["N4"] = 108, + ["N5"] = 60, + ["N6"] = 107, + ["N+"] = 96, + ["N-"] = 97, + ["N7"] = 117, + ["N8"] = 61, + ["N9"] = 118, } local incollect = false ESX = exports["es_extended"]:getSharedObject() -RegisterNetEvent('esx:playerLoaded') -AddEventHandler('esx:playerLoaded', function(xPlayer) - PlayerData = xPlayer +RegisterNetEvent("esx:playerLoaded") +AddEventHandler("esx:playerLoaded", function(xPlayer) + PlayerData = xPlayer end) function DrawText3D(x, y, z, text, scale) @@ -32,144 +98,143 @@ function DrawText3D(x, y, z, text, scale) AddTextComponentString(text) DrawText(_x, _y) - local factor = (string.len(text)) / 370 - DrawRect(_x, _y + 0.0125, 0.015 + factor, 0.03, 41, 11, 41, 90) + local factor = (string.len(text)) / 370 + DrawRect(_x, _y + 0.0125, 0.015 + factor, 0.03, 41, 11, 41, 90) end -- collection potato CreateThread(function() - while true do - Wait(0) + while true do + Wait(0) local coords = GetEntityCoords(PlayerPedId()) - if (GetDistanceBetweenCoords(coords, 2233.21, 5081.3, 48.08, true) < 10.0) then - DrawText3D(2233.21, 5081.3, 48.08, _U('press_collect'), 0.4) - if ESX.GetPlayerData().job.name then - if (GetDistanceBetweenCoords(coords, 2233.21, 5081.3, 48.08, true) < 5.0) then - if IsControlJustReleased(0, Keys['E']) then - if incollect == false then - collectionpotato() - end - end - end - end - end - end + if GetDistanceBetweenCoords(coords, 2233.21, 5081.3, 48.08, true) < 10.0 then + DrawText3D(2233.21, 5081.3, 48.08, _U("press_collect"), 0.4) + if ESX.GetPlayerData().job.name then + if GetDistanceBetweenCoords(coords, 2233.21, 5081.3, 48.08, true) < 5.0 then + if IsControlJustReleased(0, Keys["E"]) then + if incollect == false then + collectionpotato() + end + end + end + end + end + end end) -- collection cotton CreateThread(function() - while true do - Wait(0) + while true do + Wait(0) local coords = GetEntityCoords(PlayerPedId()) - if (GetDistanceBetweenCoords(coords, 1582.035156, 2167.279053, 79.307007, true) < 10.0) then - DrawText3D(1582.035156, 2167.279053, 79.307007, _U('press_collect'), 0.4) - if ESX.GetPlayerData().job.name then - if (GetDistanceBetweenCoords(coords, 1582.035156, 2167.279053, 79.307007, true) < 5.0) then - if IsControlJustReleased(0, Keys['E']) then - if incollect == false then - collectioncotton() - end - end - end - end - end - end + if GetDistanceBetweenCoords(coords, 1582.035156, 2167.279053, 79.307007, true) < 10.0 then + DrawText3D(1582.035156, 2167.279053, 79.307007, _U("press_collect"), 0.4) + if ESX.GetPlayerData().job.name then + if GetDistanceBetweenCoords(coords, 1582.035156, 2167.279053, 79.307007, true) < 5.0 then + if IsControlJustReleased(0, Keys["E"]) then + if incollect == false then + collectioncotton() + end + end + end + end + end + end end) -- collection apple CreateThread(function() - while true do - Wait(0) + while true do + Wait(0) local coords = GetEntityCoords(PlayerPedId()) - if (GetDistanceBetweenCoords(coords, 2343.850586, 4756.087891, 34.806641, true) < 10.0) then - DrawText3D(2343.850586, 4756.087891, 34.806641, _U('press_collect'), 0.4) - if ESX.GetPlayerData().job.name then - if (GetDistanceBetweenCoords(coords, 2343.850586, 4756.087891, 34.806641, true) < 5.0) then - if IsControlJustReleased(0, Keys['E']) then - if incollect == false then - collectionapple() - end - end - end - end - end - end + if GetDistanceBetweenCoords(coords, 2343.850586, 4756.087891, 34.806641, true) < 10.0 then + DrawText3D(2343.850586, 4756.087891, 34.806641, _U("press_collect"), 0.4) + if ESX.GetPlayerData().job.name then + if GetDistanceBetweenCoords(coords, 2343.850586, 4756.087891, 34.806641, true) < 5.0 then + if IsControlJustReleased(0, Keys["E"]) then + if incollect == false then + collectionapple() + end + end + end + end + end + end end) -- collection grain CreateThread(function() - while true do - Wait(0) + while true do + Wait(0) local coords = GetEntityCoords(PlayerPedId()) - if (GetDistanceBetweenCoords(coords, 2607.942871, 4399.490234, 40.973633, true) < 10.0) then - DrawText3D(2607.942871, 4399.490234, 40.973633, _U('press_collect'), 0.4) - if ESX.GetPlayerData().job.name then - if (GetDistanceBetweenCoords(coords, 2607.942871, 4399.490234, 40.973633, true) < 5.0) then - if IsControlJustReleased(0, Keys['E']) then - if incollect == false then - collectiongrain() - end - end - end - end - end - end + if GetDistanceBetweenCoords(coords, 2607.942871, 4399.490234, 40.973633, true) < 10.0 then + DrawText3D(2607.942871, 4399.490234, 40.973633, _U("press_collect"), 0.4) + if ESX.GetPlayerData().job.name then + if GetDistanceBetweenCoords(coords, 2607.942871, 4399.490234, 40.973633, true) < 5.0 then + if IsControlJustReleased(0, Keys["E"]) then + if incollect == false then + collectiongrain() + end + end + end + end + end + end end) - local blips = { - {title="Potato harvest", colour=0, id=398, x = 2233.21, y = 5081.3, z = 48.08}, - {title="Cotton harvesting", colour=0, id=398, x = 1582.035156, y = 2167.279053, z = 79.307007}, - {title="Apple picking", colour=0, id=398, x = 2343.850586, y = 4756.087891, z = 34.806641}, - {title="Wheat harvest", colour=0, id=398, x = 2607.942871, y = 4399.490234, z = 40.973633} + { title = "Potato harvest", colour = 0, id = 398, x = 2233.21, y = 5081.3, z = 48.08 }, + { title = "Cotton harvesting", colour = 0, id = 398, x = 1582.035156, y = 2167.279053, z = 79.307007 }, + { title = "Apple picking", colour = 0, id = 398, x = 2343.850586, y = 4756.087891, z = 34.806641 }, + { title = "Wheat harvest", colour = 0, id = 398, x = 2607.942871, y = 4399.490234, z = 40.973633 }, } CreateThread(function() - for _, info in pairs(blips) do - info.blip = AddBlipForCoord(info.x, info.y, info.z) - SetBlipSprite(info.blip, info.id) - SetBlipDisplay(info.blip, 4) - SetBlipScale(info.blip, 0.85) - SetBlipColour(info.blip, info.colour) - SetBlipAsShortRange(info.blip, true) - BeginTextCommandSetBlipName("STRING") - AddTextComponentString(info.title) - EndTextCommandSetBlipName(info.blip) - end + for _, info in pairs(blips) do + info.blip = AddBlipForCoord(info.x, info.y, info.z) + SetBlipSprite(info.blip, info.id) + SetBlipDisplay(info.blip, 4) + SetBlipScale(info.blip, 0.85) + SetBlipColour(info.blip, info.colour) + SetBlipAsShortRange(info.blip, true) + BeginTextCommandSetBlipName("STRING") + AddTextComponentString(info.title) + EndTextCommandSetBlipName(info.blip) + end end) --potato function collectionpotato() - TriggerServerEvent('farmer:collectionpotato') - exports["esx_notify"]:Notify("info", 3000, _U('collection_progress')) - incollect = true - Wait(6000) - incollect = false + TriggerServerEvent("farmer:collectionpotato") + exports["esx_notify"]:Notify("info", 3000, _U("collection_progress")) + incollect = true + Wait(6000) + incollect = false end -- cotton function collectioncotton() - TriggerServerEvent('farmer:collectioncotton') - exports["esx_notify"]:Notify("info", 3000, _U('collection_progress')) - incollect = true - Wait(6000) - incollect = false + TriggerServerEvent("farmer:collectioncotton") + exports["esx_notify"]:Notify("info", 3000, _U("collection_progress")) + incollect = true + Wait(6000) + incollect = false end -- apple function collectionapple() - TriggerServerEvent('farmer:collectionapple') - exports["esx_notify"]:Notify("info", 3000, _U('collection_progress')) - incollect = true - Wait(6000) - incollect = false + TriggerServerEvent("farmer:collectionapple") + exports["esx_notify"]:Notify("info", 3000, _U("collection_progress")) + incollect = true + Wait(6000) + incollect = false end -- grain function collectiongrain() - TriggerServerEvent('farmer:collectiongrain') - exports["esx_notify"]:Notify("info", 3000, _U('collection_progress')) - incollect = true - Wait(6000) - incollect = false -end \ No newline at end of file + TriggerServerEvent("farmer:collectiongrain") + exports["esx_notify"]:Notify("info", 3000, _U("collection_progress")) + incollect = true + Wait(6000) + incollect = false +end diff --git a/server-data/resources/[bpt_addons]/bpt_farmer/config.lua b/server-data/resources/[bpt_addons]/bpt_farmer/config.lua index 78ca21f1d..adb7fc406 100644 --- a/server-data/resources/[bpt_addons]/bpt_farmer/config.lua +++ b/server-data/resources/[bpt_addons]/bpt_farmer/config.lua @@ -1,2 +1,2 @@ Config = {} -Config.Locale = 'en' \ No newline at end of file +Config.Locale = "en" diff --git a/server-data/resources/[bpt_addons]/bpt_farmer/fxmanifest.lua b/server-data/resources/[bpt_addons]/bpt_farmer/fxmanifest.lua index 74dc4b5ef..08a257ac6 100644 --- a/server-data/resources/[bpt_addons]/bpt_farmer/fxmanifest.lua +++ b/server-data/resources/[bpt_addons]/bpt_farmer/fxmanifest.lua @@ -1,22 +1,22 @@ -fx_version 'adamant' -game 'gta5' -description 'bpt_farmer, introduces various collection points for the crafting system (not a job)' -author 'bitpredator' -version '1.0.0' +fx_version("adamant") +game("gta5") +description("bpt_farmer, introduces various collection points for the crafting system (not a job)") +author("bitpredator") +version("1.0.1") -shared_script '@es_extended/imports.lua' +shared_script("@es_extended/imports.lua") -client_script { - '@es_extended/locale.lua', - 'client/*.lua', - 'locales/*.lua', - 'config.lua', -} +client_script({ + "@es_extended/locale.lua", + "client/*.lua", + "locales/*.lua", + "config.lua", +}) -server_scripts { - '@es_extended/locale.lua', - 'server/*.lua', - '@oxmysql/lib/MySQL.lua', - 'locales/*.lua', - 'config.lua', -} \ No newline at end of file +server_scripts({ + "@es_extended/locale.lua", + "server/*.lua", + "@oxmysql/lib/MySQL.lua", + "locales/*.lua", + "config.lua", +}) diff --git a/server-data/resources/[bpt_addons]/bpt_farmer/locales/en.lua b/server-data/resources/[bpt_addons]/bpt_farmer/locales/en.lua index 288334ec1..8a5f1e8e4 100644 --- a/server-data/resources/[bpt_addons]/bpt_farmer/locales/en.lua +++ b/server-data/resources/[bpt_addons]/bpt_farmer/locales/en.lua @@ -1,4 +1,4 @@ -Locales['en'] = { - ['press_collect'] = 'Press ~b~[E] to collect', - ['collection_progress'] = 'Collection in progress' -} \ No newline at end of file +Locales["en"] = { + ["press_collect"] = "Press ~b~[E] to collect", + ["collection_progress"] = "Collection in progress", +} diff --git a/server-data/resources/[bpt_addons]/bpt_farmer/locales/it.lua b/server-data/resources/[bpt_addons]/bpt_farmer/locales/it.lua index 6d2ed296a..fe7872122 100644 --- a/server-data/resources/[bpt_addons]/bpt_farmer/locales/it.lua +++ b/server-data/resources/[bpt_addons]/bpt_farmer/locales/it.lua @@ -1,4 +1,4 @@ -Locales['en'] = { - ['press_collect'] = 'Premi ~b~[E] per raccogliere', - ['collection_progress'] = 'Raccolta in corso' -} \ No newline at end of file +Locales["en"] = { + ["press_collect"] = "Premi ~b~[E] per raccogliere", + ["collection_progress"] = "Raccolta in corso", +} diff --git a/server-data/resources/[bpt_addons]/bpt_farmer/server/main.lua b/server-data/resources/[bpt_addons]/bpt_farmer/server/main.lua index b84776485..a69bb1850 100644 --- a/server-data/resources/[bpt_addons]/bpt_farmer/server/main.lua +++ b/server-data/resources/[bpt_addons]/bpt_farmer/server/main.lua @@ -1,61 +1,61 @@ ESX = exports["es_extended"]:getSharedObject() -- collection potato -RegisterServerEvent('farmer:collectionpotato') -AddEventHandler('farmer:collectionpotato', function() +RegisterServerEvent("farmer:collectionpotato") +AddEventHandler("farmer:collectionpotato", function() local _source = source - local xPlayer = ESX.GetPlayerFromId(_source) - local potato = xPlayer.getInventoryItem('potato').count - if potato < 50 then - TriggerClientEvent('farmer:anim', _source) - Wait(5000) - local countpotato = math.random(1,5) - xPlayer.addInventoryItem('potato', countpotato) - TriggerClientEvent('farmer:unfreeze', _source) - end + local xPlayer = ESX.GetPlayerFromId(_source) + local potato = xPlayer.getInventoryItem("potato").count + if potato < 50 then + TriggerClientEvent("farmer:anim", _source) + Wait(5000) + local countpotato = math.random(1, 5) + xPlayer.addInventoryItem("potato", countpotato) + TriggerClientEvent("farmer:unfreeze", _source) + end end) -- collection cotton -RegisterServerEvent('farmer:collectioncotton') -AddEventHandler('farmer:collectioncotton', function() +RegisterServerEvent("farmer:collectioncotton") +AddEventHandler("farmer:collectioncotton", function() local _source = source - local xPlayer = ESX.GetPlayerFromId(_source) - local cotton = xPlayer.getInventoryItem('cotton').count - if cotton < 50 then - TriggerClientEvent('farmer:anim', _source) - Wait(5000) - local countcotton = math.random(1,5) - xPlayer.addInventoryItem('cotton', countcotton) - TriggerClientEvent('farmer:unfreeze', _source) - end + local xPlayer = ESX.GetPlayerFromId(_source) + local cotton = xPlayer.getInventoryItem("cotton").count + if cotton < 50 then + TriggerClientEvent("farmer:anim", _source) + Wait(5000) + local countcotton = math.random(1, 5) + xPlayer.addInventoryItem("cotton", countcotton) + TriggerClientEvent("farmer:unfreeze", _source) + end end) -- collection apple -RegisterServerEvent('farmer:collectionapple') -AddEventHandler('farmer:collectionapple', function() +RegisterServerEvent("farmer:collectionapple") +AddEventHandler("farmer:collectionapple", function() local _source = source - local xPlayer = ESX.GetPlayerFromId(_source) - local apple = xPlayer.getInventoryItem('apple').count - if apple < 50 then - TriggerClientEvent('farmer:anim', _source) - Wait(5000) - local countapple = math.random(1,5) - xPlayer.addInventoryItem('apple', countapple) - TriggerClientEvent('farmer:unfreeze', _source) - end + local xPlayer = ESX.GetPlayerFromId(_source) + local apple = xPlayer.getInventoryItem("apple").count + if apple < 50 then + TriggerClientEvent("farmer:anim", _source) + Wait(5000) + local countapple = math.random(1, 5) + xPlayer.addInventoryItem("apple", countapple) + TriggerClientEvent("farmer:unfreeze", _source) + end end) -- collection grain -RegisterServerEvent('farmer:collectiongrain') -AddEventHandler('farmer:collectiongrain', function() +RegisterServerEvent("farmer:collectiongrain") +AddEventHandler("farmer:collectiongrain", function() local _source = source - local xPlayer = ESX.GetPlayerFromId(_source) - local grain = xPlayer.getInventoryItem('grain').count - if grain < 50 then - TriggerClientEvent('farmer:anim', _source) - Wait(5000) - local countgrain = math.random(1,5) - xPlayer.addInventoryItem('grain', countgrain) - TriggerClientEvent('farmer:unfreeze', _source) - end -end) \ No newline at end of file + local xPlayer = ESX.GetPlayerFromId(_source) + local grain = xPlayer.getInventoryItem("grain").count + if grain < 50 then + TriggerClientEvent("farmer:anim", _source) + Wait(5000) + local countgrain = math.random(1, 5) + xPlayer.addInventoryItem("grain", countgrain) + TriggerClientEvent("farmer:unfreeze", _source) + end +end)