From 901fbc2ab5596fba9190aef0bea179c79409353a Mon Sep 17 00:00:00 2001 From: TRClassic Date: Wed, 6 Apr 2022 21:21:45 -0400 Subject: [PATCH] Washing Stone Fix # 1.0.1 Update *Forgot to readd the item check for washing the stones before I published it that's my fault* Updated the readme for CD_Drawtext users --- README.md | 18 ++++++++++++------ client/main.lua | 38 ++++++++++++++++++++++---------------- fxmanifest.lua | 2 +- server/main.lua | 11 +++++++++++ 4 files changed, 46 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 541ceae..74489e9 100644 --- a/README.md +++ b/README.md @@ -48,26 +48,32 @@ If you use another Drawtext like cd_drawtextui for example change the following **Before** DRAWTEXT ``` - exports['qb-core']:DrawText(Config.Text['MiningAlert'], 'left') +exports['qb-core']:DrawText(Config.Text['MiningAlert'], 'left') - exports['qb-core']:DrawText(Config.Text['StartMining'],'left') +exports['qb-core']:DrawText(Config.Text['StartMining'],'left') ``` **After** ``` - TriggerEvent('cd_drawtextui:ShowUI', 'show', Config.Text['MiningAlert']) +TriggerEvent('cd_drawtextui:ShowUI', 'show', Config.Text['MiningAlert']) - TriggerEvent('cd_drawtextui:ShowUI', 'show', Config.Text['StartMining']) +TriggerEvent('cd_drawtextui:ShowUI', 'show', Config.Text['StartMining']) ``` **Before** HIDETEXT ``` - exports['qb-core']:HideText() +exports['qb-core']:HideText() ``` **After** ``` - TriggerEvent('cd_drawtextui:HideUI') +TriggerEvent('cd_drawtextui:HideUI') +``` + +**You will also need to remove this line if you are using CD_Drawtextui** +**Line 160** +``` +exports['qb-core']:KeyPressed() ``` ## **Drawtext Ui Files will be provided if you don't have it installed in your core** diff --git a/client/main.lua b/client/main.lua index 3ad8544..3555639 100644 --- a/client/main.lua +++ b/client/main.lua @@ -177,22 +177,28 @@ end RegisterNetEvent('tr-mining:washingrocks', function() QBCore.Functions.TriggerCallback('tr-mining:washpan', function(washingpancheck) if washingpancheck then - local playerPed = PlayerPedId() - local coords = GetEntityCoords(playerPed) - local rockwash = MiningJob.WashingTimer - TaskStartScenarioInPlace(playerPed, 'WORLD_HUMAN_BUM_WASH', 0, false) - QBCore.Functions.Progressbar('Washing Stones', Config.Text['Washing_Rocks'], rockwash, false, true, { -- Name | Label | Time | useWhileDead | canCancel - disableMovement = true, - disableCarMovement = true, - disableMouse = false, - disableCombat = true, - }, { - }, {}, {}, function() - ClearPedTasks(PlayerPedId()) - TriggerServerEvent("tr-mining:receivedReward") - end, function() - QBCore.Functions.Notify(Config.Text['cancel'], "error") - end) + QBCore.Functions.TriggerCallback('tr-mining:stonesbruf', function(stonesbruf) + if stonesbruf then + local playerPed = PlayerPedId() + local coords = GetEntityCoords(playerPed) + local rockwash = MiningJob.WashingTimer + TaskStartScenarioInPlace(playerPed, 'WORLD_HUMAN_BUM_WASH', 0, false) + QBCore.Functions.Progressbar('Washing Stones', Config.Text['Washing_Rocks'], rockwash, false, true, { -- Name | Label | Time | useWhileDead | canCancel + disableMovement = true, + disableCarMovement = true, + disableMouse = false, + disableCombat = true, + }, { + }, {}, {}, function() + ClearPedTasks(PlayerPedId()) + TriggerServerEvent("tr-mining:receivedReward") + end, function() + QBCore.Functions.Notify(Config.Text['cancel'], "error") + end) + elseif not stonesbruf then + QBCore.Functions.Notify(Config.Text['error_minerstone'], "error") + end + end) elseif not washingpancheck then Wait(500) QBCore.Functions.Notify(Config.Text['error_washpan'], "error", 3000) diff --git a/fxmanifest.lua b/fxmanifest.lua index 64e491e..bdfd912 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -3,7 +3,7 @@ game 'gta5' author 'TRClassic#0001' description 'Mining script for QBCore' -version '1.0.0' +version '1.0.1' client_script { '@PolyZone/client.lua', diff --git a/server/main.lua b/server/main.lua index cd5957a..163ab05 100644 --- a/server/main.lua +++ b/server/main.lua @@ -116,6 +116,17 @@ RegisterNetEvent('tr-mining:setMiningStage', function(stage, state, k) TriggerClientEvent('tr-mining:getMiningstage', -1, stage, state, k) end) +QBCore.Functions.CreateCallback('tr-mining:stonesbruf', function(source, cb) + local Player = QBCore.Functions.GetPlayer(source) + if Player ~= nil then + if Player.Functions.GetItemByName("mining_stone") ~= nil then + cb(true) + else + cb(false) + end + end +end) + RegisterNetEvent('tr-mining:setMiningTimer', function() if not mining then