diff --git a/client/binoculars.lua b/client/binoculars.lua index c744502..9fa34b2 100644 --- a/client/binoculars.lua +++ b/client/binoculars.lua @@ -4,48 +4,48 @@ local zoomspeed = 10.0 -- camera zoom speed local speed_lr = 8.0 -- speed by which the camera pans left-right local speed_ud = 8.0 -- speed by which the camera pans up-down local binoculars = false -local fov = (fov_max+fov_min)*0.5 +local fov = (fov_max + fov_min) * 0.5 local storeBinoclarKey = 177 -- Backspace --FUNCTIONS-- -local function CheckInputRotation(cam, zoomvalue) +local function checkInputRotation(cam, zoomvalue) local rightAxisX = GetControlNormal(0, 220) local rightAxisY = GetControlNormal(0, 221) local rotation = GetCamRot(cam, 2) if rightAxisX ~= 0.0 or rightAxisY ~= 0.0 then - local new_z = rotation.z + rightAxisX*-1.0*(speed_ud)*(zoomvalue+0.1) - local new_x = math.max(math.min(20.0, rotation.x + rightAxisY*-1.0*(speed_lr)*(zoomvalue+0.1)), -89.5) + local new_z = rotation.z + rightAxisX * -1.0 * (speed_ud) * (zoomvalue + 0.1) + local new_x = math.max(math.min(20.0, rotation.x + rightAxisY * -1.0 * (speed_lr) * (zoomvalue + 0.1)), -89.5) SetCamRot(cam, new_x, 0.0, new_z, 2) - SetEntityHeading(cache.ped,new_z) + SetEntityHeading(cache.ped, new_z) end end -local function HandleZoom(cam) +local function handleZoom(cam) if not IsPedSittingInAnyVehicle(cache.ped) then - if IsControlJustPressed(0,241) then -- Scrollup + if IsControlJustPressed(0, 241) then -- Scrollup fov = math.max(fov - zoomspeed, fov_min) end - if IsControlJustPressed(0,242) then + if IsControlJustPressed(0, 242) then fov = math.min(fov + zoomspeed, fov_max) -- ScrollDown end local current_fov = GetCamFov(cam) if math.abs(fov-current_fov) < 0.1 then fov = current_fov end - SetCamFov(cam, current_fov + (fov - current_fov)*0.05) + SetCamFov(cam, current_fov + (fov - current_fov) * 0.05) else - if IsControlJustPressed(0,17) then -- Scrollup + if IsControlJustPressed(0, 17) then -- Scrollup fov = math.max(fov - zoomspeed, fov_min) end - if IsControlJustPressed(0,16) then + if IsControlJustPressed(0, 16) then fov = math.min(fov + zoomspeed, fov_max) -- ScrollDown end local current_fov = GetCamFov(cam) if math.abs(fov-current_fov) < 0.1 then -- the difference is too small, just set the value directly to avoid unneeded updates to FOV of order 10^-5 fov = current_fov end - SetCamFov(cam, current_fov + (fov - current_fov)*0.05) -- Smoothing of camera zoom + SetCamFov(cam, current_fov + (fov - current_fov) * 0.05) -- Smoothing of camera zoom end end @@ -61,8 +61,8 @@ RegisterNetEvent('binoculars:Toggle', function() if binoculars then TaskStartScenarioInPlace(cache.ped, 'WORLD_HUMAN_BINOCULARS', 0, true) cam = CreateCam('DEFAULT_SCRIPTED_CAMERA', true) - AttachCamToEntity(cam, cache.ped, 0.0,0.0,1.0, true) - SetCamRot(cam, 0.0,0.0, GetEntityHeading(cache.ped), 2) + AttachCamToEntity(cam, cache.ped, 0.0, 0.0, 1.0, true) + SetCamRot(cam, 0.0, 0.0, GetEntityHeading(cache.ped), 2) RenderScriptCams(true, false, 5000, true, false) else ClearPedTasks(cache.ped) @@ -74,10 +74,7 @@ RegisterNetEvent('binoculars:Toggle', function() while binoculars do - scaleform = RequestScaleformMovie('BINOCULARS') - while not HasScaleformMovieLoaded(scaleform) do - Wait(10) - end + scaleform = lib.requestScaleformMovie('BINOCULARS') BeginScaleformMovieMethod(scaleform, 'SET_CAM_LOGO') ScaleformMovieMethodAddParamInt(0) -- 0 for nothing, 1 for LSPD logo @@ -92,9 +89,9 @@ RegisterNetEvent('binoculars:Toggle', function() cam = nil end - local zoomvalue = (1.0/(fov_max-fov_min))*(fov-fov_min) - CheckInputRotation(cam, zoomvalue) - HandleZoom(cam) + local zoomvalue = (1.0 / (fov_max-fov_min)) * (fov-fov_min) + checkInputRotation(cam, zoomvalue) + handleZoom(cam) DrawScaleformMovieFullscreen(scaleform, 255, 255, 255, 255, 0) Wait(0) end diff --git a/client/carwash.lua b/client/carwash.lua index 1febe22..0eb6749 100644 --- a/client/carwash.lua +++ b/client/carwash.lua @@ -1,21 +1,5 @@ -local QBCore = exports['qbx-core']:GetCoreObject() local washingVehicle = false -local function DrawText3Ds(x, y, z, text) - SetTextScale(0.35, 0.35) - SetTextFont(4) - SetTextProportional(true) - SetTextColour(255, 255, 255, 215) - BeginTextCommandDisplayText('STRING') - SetTextCentre(true) - AddTextComponentSubstringPlayerName(text) - SetDrawOrigin(x,y,z, 0) - EndTextCommandDisplayText(0.0, 0.0) - local factor = (string.len(text)) / 370 - DrawRect(0.0, 0.0+0.0125, 0.017+ factor, 0.03, 0, 0, 0, 75) - ClearDrawOrigin() -end - RegisterNetEvent('qb-carwash:client:washCar', function() washingVehicle = true if lib.progressBar({ @@ -35,7 +19,7 @@ RegisterNetEvent('qb-carwash:client:washCar', function() WashDecalsFromVehicle(cache.vehicle, 1.0) washingVehicle = false else -- if cancel - QBCore.Functions.Notify('Washing canceled ..', 'error') + QBCore.Functions.Notify('Washing canceled...', 'error') washingVehicle = false end end) @@ -53,7 +37,7 @@ CreateThread(function() if dist <= 7.5 and driver then sleep = 0 if not washingVehicle then - DrawText3Ds(carWashCoords.x, carWashCoords.y, carWashCoords.z, '~g~E~w~ - Wash the car ($'..Config.CarWash.defaultPrice..')') + DrawText3D('~g~E~w~ - Wash the car ($'..Config.CarWash.defaultPrice..')', carWashCoords) if IsControlJustPressed(0, 38) then if dirtLevel > Config.CarWash.dirtLevel then TriggerServerEvent('qb-carwash:server:washCar') @@ -62,7 +46,7 @@ CreateThread(function() end end else - DrawText3Ds(carWashCoords.x, carWashCoords.y, carWashCoords.z, 'The car wash is not available...') + DrawText3D('The car wash is not available...', carWashCoords) end end end diff --git a/client/consumables.lua b/client/consumables.lua index fdd7e04..6fd314f 100644 --- a/client/consumables.lua +++ b/client/consumables.lua @@ -1,17 +1,15 @@ -- Variables - -local QBCore = exports['qbx-core']:GetCoreObject() -local alcoholCount, ParachuteEquiped, currentVest, currentVestTexture, healing, SmokingWeed, RelieveCount = 0, false, nil, nil, false, false, 0 +local alcoholCount, parachuteEquipped, currentVest, currentVestTexture, healing, smokingWeed, relieveCount = 0, false, nil, nil, false, false, 0 -- Functions -local function EquipParachuteAnim() +local function equipParachuteAnim() local hasLoaded = lib.requestAnimDict('clothingshirt') if not hasLoaded then return end TaskPlayAnim(cache.ped, 'clothingshirt', 'try_shirt_positive_d', 8.0, 1.0, -1, 49, 0, false, false, false) end -local function HealOxy() +local function healOxy() if not healing then healing = true else @@ -27,7 +25,7 @@ local function HealOxy() healing = false end -local function TrevorEffect() +local function trevorEffect() AnimpostfxPlay('DrugsTrevorClownsFightIn', 3.0, 0) Wait(3000) AnimpostfxPlay('DrugsTrevorClownsFight', 3.0, 0) @@ -38,30 +36,30 @@ local function TrevorEffect() AnimpostfxStop('DrugsTrevorClownsFightOut') end -local function MethBagEffect() +local function methBagEffect() local startStamina = 8 - TrevorEffect() - SetRunSprintMultiplierForPlayer(PlayerId(), 1.49) + trevorEffect() + SetRunSprintMultiplierForPlayer(cache.playerId, 1.49) while startStamina > 0 do Wait(1000) if math.random(5, 100) < 10 then - RestorePlayerStamina(PlayerId(), 1.0) + RestorePlayerStamina(cache.playerId, 1.0) end startStamina = startStamina - 1 if math.random(5, 100) < 51 then - TrevorEffect() + trevorEffect() end end - SetRunSprintMultiplierForPlayer(PlayerId(), 1.0) + SetRunSprintMultiplierForPlayer(cache.playerId, 1.0) end -local function EcstasyEffect() +local function ecstasyEffect() local startStamina = 30 SetFlash(0, 0, 500, 7000, 500) while startStamina > 0 do Wait(1000) startStamina -= 1 - RestorePlayerStamina(PlayerId(), 1.0) + RestorePlayerStamina(cache.playerId, 1.0) if math.random(1, 100) < 51 then SetFlash(0, 0, 500, 7000, 500) ShakeGameplayCam('SMALL_EXPLOSION_SHAKE', 0.08) @@ -72,7 +70,7 @@ local function EcstasyEffect() end end -local function AlienEffect() +local function alienEffect() AnimpostfxPlay('DrugsMichaelAliensFightIn', 3.0, 0) Wait(math.random(5000, 8000)) AnimpostfxPlay('DrugsMichaelAliensFight', 3.0, 0) @@ -83,64 +81,64 @@ local function AlienEffect() AnimpostfxStop('DrugsMichaelAliensFightOut') end -local function CrackBaggyEffect() +local function crackBaggyEffect() local startStamina = 8 - AlienEffect() - SetRunSprintMultiplierForPlayer(PlayerId(), 1.3) + alienEffect() + SetRunSprintMultiplierForPlayer(cache.playerId, 1.3) while startStamina > 0 do Wait(1000) if math.random(1, 100) < 10 then - RestorePlayerStamina(PlayerId(), 1.0) + RestorePlayerStamina(cache.playerId, 1.0) end startStamina -= 1 if math.random(1, 100) < 60 and IsPedRunning(cache.ped) then SetPedToRagdoll(cache.ped, math.random(1000, 2000), math.random(1000, 2000), 3, false, false, false) end if math.random(1, 100) < 51 then - AlienEffect() + alienEffect() end end if IsPedRunning(cache.ped) then SetPedToRagdoll(cache.ped, math.random(1000, 3000), math.random(1000, 3000), 3, false, false, false) end - SetRunSprintMultiplierForPlayer(PlayerId(), 1.0) + SetRunSprintMultiplierForPlayer(cache.playerId, 1.0) end -local function CokeBaggyEffect() +local function cokeBaggyEffect() local startStamina = 20 - AlienEffect() - SetRunSprintMultiplierForPlayer(PlayerId(), 1.1) + alienEffect() + SetRunSprintMultiplierForPlayer(cache.playerId, 1.1) while startStamina > 0 do Wait(1000) if math.random(1, 100) < 20 then - RestorePlayerStamina(PlayerId(), 1.0) + RestorePlayerStamina(cache.playerId, 1.0) end startStamina -= 1 if math.random(1, 100) < 10 and IsPedRunning(cache.ped) then SetPedToRagdoll(cache.ped, math.random(1000, 3000), math.random(1000, 3000), 3, false, false, false) end if math.random(1, 300) < 10 then - AlienEffect() + alienEffect() Wait(math.random(3000, 6000)) end end if IsPedRunning(cache.ped) then SetPedToRagdoll(cache.ped, math.random(1000, 3000), math.random(1000, 3000), 3, false, false, false) end - SetRunSprintMultiplierForPlayer(PlayerId(), 1.0) + SetRunSprintMultiplierForPlayer(cache.playerId, 1.0) end -local function SmokeWeed() +local function smokeWeed() CreateThread(function() - while SmokingWeed do + while smokingWeed do Wait(10000) TriggerServerEvent('hud:server:RelieveStress', math.random(15, 18)) - RelieveCount += 1 - if RelieveCount == 6 then + relieveCount += 1 + if relieveCount == 6 then exports.scully_emotemenu:cancelEmote() - if SmokingWeed then - SmokingWeed = false - RelieveCount = 0 + if smokingWeed then + smokingWeed = false + relieveCount = 0 end end end @@ -151,45 +149,63 @@ end RegisterNetEvent('consumables:client:Eat', function(itemName) exports.scully_emotemenu:playEmoteByCommand('eat') - QBCore.Functions.Progressbar('eat_something', 'Eating..', 5000, false, true, { - disableMovement = false, - disableCarMovement = false, - disableMouse = false, - disableCombat = true, - }, {}, {}, {}, function() -- Done + if lib.progressBar({ + duration = 5000, + label = 'Eating...', + useWhileDead = false, + canCancel = true, + disable = { + move = false, + car = false, + mouse = false, + combat = true + } + }) then -- if completed TriggerEvent('inventory:client:ItemBox', QBCore.Shared.Items[itemName], 'remove') exports.scully_emotemenu:cancelEmote() - TriggerServerEvent('consumables:server:addHunger', QBCore.Functions.GetPlayerData().metadata['hunger'] + ConsumablesEat[itemName]) + TriggerServerEvent('consumables:server:addHunger', PlayerData.metadata.hunger + ConsumablesEat[itemName]) TriggerServerEvent('hud:server:RelieveStress', math.random(2, 4)) - end) + end end) RegisterNetEvent('consumables:client:Drink', function(itemName) exports.scully_emotemenu:playEmoteByCommand('drink') - QBCore.Functions.Progressbar('drink_something', 'Drinking..', 5000, false, true, { - disableMovement = false, - disableCarMovement = false, - disableMouse = false, - disableCombat = true, - }, {}, {}, {}, function() -- Done + if lib.progressBar({ + duration = 5000, + label = 'Drinking...', + useWhileDead = false, + canCancel = true, + disable = { + move = false, + car = false, + mouse = false, + combat = true + } + }) then -- if completed TriggerEvent('inventory:client:ItemBox', QBCore.Shared.Items[itemName], 'remove') exports.scully_emotemenu:cancelEmote() - TriggerServerEvent('consumables:server:addThirst', QBCore.Functions.GetPlayerData().metadata['thirst'] + ConsumablesDrink[itemName]) - end) + TriggerServerEvent('consumables:server:addThirst', PlayerData.metadata.thirst + ConsumablesDrink[itemName]) + end end) RegisterNetEvent('consumables:client:DrinkAlcohol', function(itemName) exports.scully_emotemenu:playEmoteByCommand('beer7') - QBCore.Functions.Progressbar('snort_coke', 'Drinking liquor..', math.random(3000, 6000), false, true, { - disableMovement = false, - disableCarMovement = false, - disableMouse = false, - disableCombat = true, - }, {}, {}, {}, function() -- Done + if lib.progressBar({ + duration = math.random(3000, 6000), + label = 'Drinking liquor...', + useWhileDead = false, + canCancel = true, + disable = { + move = false, + car = false, + mouse = false, + combat = true + } + }) then -- if completed exports.scully_emotemenu:cancelEmote() TriggerEvent('inventory:client:ItemBox', QBCore.Shared.Items[itemName], 'remove') TriggerServerEvent('consumables:server:drinkAlcohol', itemName) - TriggerServerEvent('consumables:server:addThirst', QBCore.Functions.GetPlayerData().metadata['thirst'] + ConsumablesAlcohol[itemName]) + TriggerServerEvent('consumables:server:addThirst', PlayerData.metadata.thirst + ConsumablesAlcohol[itemName]) TriggerServerEvent('hud:server:RelieveStress', math.random(2, 4)) alcoholCount += 1 if alcoholCount > 1 and alcoholCount < 4 then @@ -197,207 +213,255 @@ RegisterNetEvent('consumables:client:DrinkAlcohol', function(itemName) elseif alcoholCount >= 4 then TriggerEvent('evidence:client:SetStatus', 'heavyalcohol', 200) end - - end, function() -- Cancel + else -- if canceled exports.scully_emotemenu:cancelEmote() - QBCore.Functions.Notify('Cancelled..', 'error') - end) + QBCore.Functions.Notify('Canceled...', 'error') + end end) RegisterNetEvent('consumables:client:Cokebaggy', function() - QBCore.Functions.Progressbar('snort_coke', 'Quick sniff..', math.random(5000, 8000), false, true, { - disableMovement = false, - disableCarMovement = false, - disableMouse = false, - disableCombat = true, - }, { - animDict = 'switch@trevor@trev_smoking_meth', - anim = 'trev_smoking_meth_loop', - flags = 49, - }, {}, {}, function() -- Done - StopAnimTask(cache.ped, 'switch@trevor@trev_smoking_meth', 'trev_smoking_meth_loop', 1.0) + if lib.progressBar({ + duration = math.random(5000, 8000), + label = 'Quick sniff...', + useWhileDead = false, + canCancel = true, + disable = { + move = false, + car = false, + mouse = false, + combat = true + }, + anim = { + dict = 'switch@trevor@trev_smoking_meth', + clip = 'trev_smoking_meth_loop', + flag = 49 + } + }) then -- if completed TriggerServerEvent('consumables:server:useCokeBaggy') TriggerEvent('inventory:client:ItemBox', QBCore.Shared.Items['cokebaggy'], 'remove') TriggerEvent('evidence:client:SetStatus', 'widepupils', 200) - CokeBaggyEffect() - end, function() -- Cancel - StopAnimTask(cache.ped, 'switch@trevor@trev_smoking_meth', 'trev_smoking_meth_loop', 1.0) - QBCore.Functions.Notify('Canceled..', 'error') - end) + cokeBaggyEffect() + else -- if canceled + QBCore.Functions.Notify('Canceled...', 'error') + end end) RegisterNetEvent('consumables:client:Crackbaggy', function() - QBCore.Functions.Progressbar('snort_coke', 'Smoking crack..', math.random(7000, 10000), false, true, { - disableMovement = false, - disableCarMovement = false, - disableMouse = false, - disableCombat = true, - }, { - animDict = 'switch@trevor@trev_smoking_meth', - anim = 'trev_smoking_meth_loop', - flags = 49, - }, {}, {}, function() -- Done - StopAnimTask(cache.ped, 'switch@trevor@trev_smoking_meth', 'trev_smoking_meth_loop', 1.0) + if lib.progressBar({ + duration = math.random(7000, 10000), + label = 'Smoking crack...', + useWhileDead = false, + canCancel = true, + disable = { + move = false, + car = false, + mouse = false, + combat = true + }, + anim = { + dict = 'switch@trevor@trev_smoking_meth', + clip = 'trev_smoking_meth_loop', + flag = 49 + } + }) then -- if completed TriggerServerEvent('consumables:server:useCrackBaggy') TriggerEvent('inventory:client:ItemBox', QBCore.Shared.Items['crack_baggy'], 'remove') TriggerEvent('evidence:client:SetStatus', 'widepupils', 300) - CrackBaggyEffect() - end, function() -- Cancel - StopAnimTask(cache.ped, 'switch@trevor@trev_smoking_meth', 'trev_smoking_meth_loop', 1.0) - QBCore.Functions.Notify('Canceled..', 'error') - end) + crackBaggyEffect() + else -- if canceled + QBCore.Functions.Notify('Canceled...', 'error') + end end) RegisterNetEvent('consumables:client:EcstasyBaggy', function() - QBCore.Functions.Progressbar('use_ecstasy', 'Pops Pills', 3000, false, true, { - disableMovement = false, - disableCarMovement = false, - disableMouse = false, - disableCombat = true, - }, { - animDict = 'mp_suicide', - anim = 'pill', - flags = 49, - }, {}, {}, function() -- Done - StopAnimTask(cache.ped, 'mp_suicide', 'pill', 1.0) + if lib.progressBar({ + duration = 3000, + label = 'Popping pills...', + useWhileDead = false, + canCancel = true, + disable = { + move = false, + car = false, + mouse = false, + combat = true + }, + anim = { + dict = 'mp_suicide', + clip = 'pill', + flag = 49 + } + }) then -- if completed TriggerServerEvent('consumables:server:useXTCBaggy') - TriggerEvent('inventory:client:ItemBox', QBCore.Shared.Items['xtcbaggy'], 'remove') - EcstasyEffect() - end, function() -- Cancel - StopAnimTask(cache.ped, 'mp_suicide', 'pill', 1.0) - QBCore.Functions.Notify('Failed', 'error') - end) + TriggerEvent('inventory:client:ItemBox', QBCore.Shared.Items.xtcbaggy, 'remove') + ecstasyEffect() + else -- if canceled + QBCore.Functions.Notify('Canceled...', 'error') + end end) RegisterNetEvent('consumables:client:oxy', function() - QBCore.Functions.Progressbar('use_oxy', 'Healing', 2000, false, true, { - disableMovement = false, - disableCarMovement = false, - disableMouse = false, - disableCombat = true, - }, { - animDict = 'mp_suicide', - anim = 'pill', - flags = 49, - }, {}, {}, function() -- Done - StopAnimTask(cache.ped, 'mp_suicide', 'pill', 1.0) + if lib.progressBar({ + duration = 2000, + label = 'Healing...', + useWhileDead = false, + canCancel = true, + disable = { + move = false, + car = false, + mouse = false, + combat = true + }, + anim = { + dict = 'mp_suicide', + clip = 'pill', + flag = 49 + } + }) then -- if completed TriggerServerEvent('consumables:server:useOxy') TriggerEvent('inventory:client:ItemBox', QBCore.Shared.Items['oxy'], 'remove') ClearPedBloodDamage(cache.ped) - HealOxy() - end, function() -- Cancel - StopAnimTask(cache.ped, 'mp_suicide', 'pill', 1.0) + healOxy() + else -- if canceled QBCore.Functions.Notify('Canceled', 'error') - end) + end end) RegisterNetEvent('consumables:client:meth', function() - QBCore.Functions.Progressbar('snort_meth', 'Smoking Ass Meth', 1500, false, true, { - disableMovement = false, - disableCarMovement = false, - disableMouse = false, - disableCombat = true, - }, { - animDict = 'switch@trevor@trev_smoking_meth', - anim = 'trev_smoking_meth_loop', - flags = 49, - }, {}, {}, function() -- Done - StopAnimTask(cache.ped, 'switch@trevor@trev_smoking_meth', 'trev_smoking_meth_loop', 1.0) + if lib.progressBar({ + duration = 1500, + label = 'Smoking meth...', + useWhileDead = false, + canCancel = true, + disable = { + move = false, + car = false, + mouse = false, + combat = true + }, + anim = { + dict = 'switch@trevor@trev_smoking_meth', + clip = 'trev_smoking_meth_loop', + flag = 49 + } + }) then -- if completed TriggerServerEvent('consumables:server:useMeth') TriggerEvent('inventory:client:ItemBox', QBCore.Shared.Items['meth'], 'remove') TriggerEvent('evidence:client:SetStatus', 'widepupils', 300) TriggerEvent('evidence:client:SetStatus', 'agitated', 300) - MethBagEffect() - end, function() -- Cancel - StopAnimTask(cache.ped, 'switch@trevor@trev_smoking_meth', 'trev_smoking_meth_loop', 1.0) - QBCore.Functions.Notify('Canceled..', 'error') - end) + methBagEffect() + else -- if canceled + QBCore.Functions.Notify('Canceled...', 'error') + end end) RegisterNetEvent('consumables:client:UseJoint', function() - QBCore.Functions.Progressbar('smoke_joint', 'Lighting joint..', 1500, false, true, { - disableMovement = false, - disableCarMovement = false, - disableMouse = false, - disableCombat = true, - }, {}, {}, {}, function() -- Done + if lib.progressBar({ + duration = 1500, + label = 'Lighting joint...', + useWhileDead = false, + canCancel = true, + disable = { + move = false, + car = false, + mouse = false, + combat = true + } + }) then -- if completed TriggerEvent('inventory:client:ItemBox', QBCore.Shared.Items['joint'], 'remove') exports.scully_emotemenu:playEmoteByCommand('joint') TriggerEvent('evidence:client:SetStatus', 'weedsmell', 300) - SmokeWeed() - end) + smokeWeed() + end end) RegisterNetEvent('consumables:client:UseParachute', function() - EquipParachuteAnim() - QBCore.Functions.Progressbar('use_parachute', 'Putting on parachute..', 5000, false, true, { - disableMovement = false, - disableCarMovement = false, - disableMouse = false, - disableCombat = true, - }, {}, {}, {}, function() -- Done + equipParachuteAnim() + if lib.progressBar({ + duration = 5000, + label = 'Putting on parachute...', + useWhileDead = false, + canCancel = true, + disable = { + move = false, + car = false, + mouse = false, + combat = true + } + }) then -- if completed TriggerEvent('inventory:client:ItemBox', QBCore.Shared.Items['parachute'], 'remove') GiveWeaponToPed(cache.ped, `GADGET_PARACHUTE`, 1, false, false) - local ParachuteData = { - outfitData = { - ['bag'] = { item = 7, texture = 0}, -- Adding Parachute Clothing - } + local parachuteData = { + outfitData = {['bag'] = {item = 7, texture = 0}} -- Adding Parachute Clothing } - TriggerEvent('qb-clothing:client:loadOutfit', ParachuteData) - ParachuteEquiped = true + TriggerEvent('qb-clothing:client:loadOutfit', parachuteData) + parachuteEquipped = true TaskPlayAnim(cache.ped, 'clothingshirt', 'exit', 8.0, 1.0, -1, 49, 0, false, false, false) - end) + end end) RegisterNetEvent('consumables:client:ResetParachute', function() - if ParachuteEquiped then - EquipParachuteAnim() - QBCore.Functions.Progressbar('reset_parachute', 'Packing parachute..', 40000, false, true, { - disableMovement = false, - disableCarMovement = false, - disableMouse = false, - disableCombat = true, - }, {}, {}, {}, function() -- Done - TriggerEvent('inventory:client:ItemBox', QBCore.Shared.Items['parachute'], 'add') - local ParachuteRemoveData = { - outfitData = { - ['bag'] = { item = 0, texture = 0} -- Removing Parachute Clothing - } + if parachuteEquipped then + equipParachuteAnim() + if lib.progressBar({ + duration = 40000, + label = 'Packing parachute...', + useWhileDead = false, + canCancel = true, + disable = { + move = false, + car = false, + mouse = false, + combat = true + } + }) then -- if completed + local parachuteRemoveData = { + outfitData = {['bag'] = {item = 0, texture = 0}} -- Removing Parachute Clothing } - TriggerEvent('qb-clothing:client:loadOutfit', ParachuteRemoveData) + TriggerEvent('qb-clothing:client:loadOutfit', parachuteRemoveData) TaskPlayAnim(cache.ped, 'clothingshirt', 'exit', 8.0, 1.0, -1, 49, 0, false, false, false) TriggerServerEvent('qb-smallpenis:server:AddParachute') - ParachuteEquiped = false - end) + parachuteEquipped = false + end else - QBCore.Functions.Notify('You dont have a parachute!', 'error') + QBCore.Functions.Notify('You don\'t have a parachute...', 'error') end end) RegisterNetEvent('consumables:client:UseArmor', function() if GetPedArmour(cache.ped) >= 75 then QBCore.Functions.Notify('You already have enough armor on!', 'error') return end - QBCore.Functions.Progressbar('use_armor', 'Putting on the body armour..', 5000, false, true, { - disableMovement = false, - disableCarMovement = false, - disableMouse = false, - disableCombat = true, - }, {}, {}, {}, function() -- Done + if lib.progressBar({ + duration = 5000, + label = 'Putting on the body armour...', + useWhileDead = false, + canCancel = true, + disable = { + move = false, + car = false, + mouse = false, + combat = true + } + }) then -- if completed TriggerEvent('inventory:client:ItemBox', QBCore.Shared.Items['armor'], 'remove') TriggerServerEvent('hospital:server:SetArmor', 75) TriggerServerEvent('consumables:server:useArmor') SetPedArmour(cache.ped, 75) - end) + end end) RegisterNetEvent('consumables:client:UseHeavyArmor', function() if GetPedArmour(cache.ped) == 100 then QBCore.Functions.Notify('You already have enough armor on!', 'error') return end - local PlayerData = QBCore.Functions.GetPlayerData() - QBCore.Functions.Progressbar('use_heavyarmor', 'Putting on body armour..', 5000, false, true, { - disableMovement = false, - disableCarMovement = false, - disableMouse = false, - disableCombat = true, - }, {}, {}, {}, function() -- Done + if lib.progressBar({ + duration = 5000, + label = 'Putting on body armor...', + useWhileDead = false, + canCancel = true, + disable = { + move = false, + car = false, + mouse = false, + combat = true + } + }) then -- if completed if PlayerData.charinfo.gender == 0 then currentVest = GetPedDrawableVariation(cache.ped, 9) currentVestTexture = GetPedTextureVariation(cache.ped, 9) @@ -414,24 +478,30 @@ RegisterNetEvent('consumables:client:UseHeavyArmor', function() TriggerEvent('inventory:client:ItemBox', QBCore.Shared.Items['heavyarmor'], 'remove') TriggerServerEvent('consumables:server:useHeavyArmor') SetPedArmour(cache.ped, 100) - end) + end end) RegisterNetEvent('consumables:client:ResetArmor', function() if currentVest ~= nil and currentVestTexture ~= nil then - QBCore.Functions.Progressbar('remove_armor', 'Removing the body armour..', 2500, false, true, { - disableMovement = false, - disableCarMovement = false, - disableMouse = false, - disableCombat = true, - }, {}, {}, {}, function() -- Done + if lib.progressBar({ + duration = 2500, + label = 'Removing the body armour...', + useWhileDead = false, + canCancel = true, + disable = { + move = false, + car = false, + mouse = false, + combat = true + } + }) then -- if completed SetPedComponentVariation(cache.ped, 9, currentVest, currentVestTexture, 2) SetPedArmour(cache.ped, 0) TriggerEvent('inventory:client:ItemBox', QBCore.Shared.Items['heavyarmor'], 'add') TriggerServerEvent('consumables:server:resetArmor') - end) + end else - QBCore.Functions.Notify('You\'re not wearing a vest..', 'error') + QBCore.Functions.Notify('You\'re not wearing a vest...', 'error') end end) @@ -447,4 +517,4 @@ CreateThread(function() Wait(2000) end end -end) +end) \ No newline at end of file diff --git a/client/cruise.lua b/client/cruise.lua index 1eceb57..401a0a8 100644 --- a/client/cruise.lua +++ b/client/cruise.lua @@ -1,5 +1,4 @@ -local QBCore = exports['qbx-core']:GetCoreObject() -local CruisedSpeed = 0 +local cruisedSpeed = 0 local vehicleClasses = { [0] = true, [1] = true, @@ -26,40 +25,39 @@ local vehicleClasses = { } local function TriggerCruiseControl() - if CruisedSpeed == 0 and cache.seat == -1 then - CruisedSpeed = GetEntitySpeed(cache.vehicle) + if cruisedSpeed == 0 and cache.seat == -1 then + cruisedSpeed = GetEntitySpeed(cache.vehicle) - if CruisedSpeed > 0 and GetVehicleCurrentGear(cache.vehicle) > 0 then - local cruiseSpeed = CruisedSpeed * 2.23694 + if cruisedSpeed > 0 and GetVehicleCurrentGear(cache.vehicle) > 0 then TriggerEvent('seatbelt:client:ToggleCruise') QBCore.Functions.Notify('Cruise control enabled!', 'success') CreateThread(function() - while CruisedSpeed > 0 and cache.vehicle do + while cruisedSpeed > 0 and cache.vehicle do Wait(0) local speed = GetEntitySpeed(cache.vehicle) local turningOrBraking = IsControlPressed(2, 76) or IsControlPressed(2, 63) or IsControlPressed(2, 64) - if not turningOrBraking and speed < (CruisedSpeed - 1.5) then - CruisedSpeed = 0 + if not turningOrBraking and speed < (cruisedSpeed - 1.5) then + cruisedSpeed = 0 TriggerEvent('seatbelt:client:ToggleCruise') QBCore.Functions.Notify('Cruise control disabled!', 'error') Wait(500) break end - if not turningOrBraking and IsVehicleOnAllWheels(cache.vehicle) and speed < CruisedSpeed then - SetVehicleForwardSpeed(cache.vehicle, CruisedSpeed) + if not turningOrBraking and IsVehicleOnAllWheels(cache.vehicle) and speed < cruisedSpeed then + SetVehicleForwardSpeed(cache.vehicle, cruisedSpeed) end if IsControlJustPressed(1, 246) then TriggerEvent('seatbelt:client:ToggleCruise') - CruisedSpeed = GetEntitySpeed(cache.vehicle) + cruisedSpeed = GetEntitySpeed(cache.vehicle) end if IsControlJustPressed(2, 72) then - CruisedSpeed = 0 + cruisedSpeed = 0 TriggerEvent('seatbelt:client:ToggleCruise') QBCore.Functions.Notify('Cruise control disabled!', 'error') Wait(500) diff --git a/client/fireworks.lua b/client/fireworks.lua index 38cfd0d..4b1235c 100644 --- a/client/fireworks.lua +++ b/client/fireworks.lua @@ -1,8 +1,6 @@ -local QBCore = exports['qbx-core']:GetCoreObject() local fireworkTime = 0 local fireworkLoc = nil - -local FireworkList = { +local fireworkList = { ['proj_xmas_firework'] = { 'scr_firework_xmas_ring_burst_rgw', 'scr_firework_xmas_burst_rgw', @@ -36,22 +34,7 @@ local FireworkList = { }, } -local function DrawText3Ds(x, y, z, text) - SetTextScale(0.35, 0.35) - SetTextFont(4) - SetTextProportional(true) - SetTextColour(255, 255, 255, 215) - BeginTextCommandDisplayText('STRING') - SetTextCentre(true) - AddTextComponentSubstringPlayerName(text) - SetDrawOrigin(x,y,z, 0) - EndTextCommandDisplayText(0.0, 0.0) - local factor = (string.len(text)) / 370 - DrawRect(0.0, 0.0+0.0125, 0.017+ factor, 0.03, 0, 0, 0, 75) - ClearDrawOrigin() -end - -local function DoFireWork(asset, coords) +local function doFirework(asset, coords) fireworkTime = 5 fireworkLoc = {x = coords.x, y = coords.y, z = coords.z} CreateThread(function() @@ -61,7 +44,7 @@ local function DoFireWork(asset, coords) end UseParticleFxAsset('scr_indep_fireworks') for _ = 1, math.random(5, 10), 1 do - local firework = FireworkList[asset][math.random(1, #FireworkList[asset])] + local firework = fireworkList[asset][math.random(1, #fireworkList[asset])] UseParticleFxAsset(asset) StartNetworkedParticleFxNonLoopedAtCoord(firework, fireworkLoc.x, fireworkLoc.y, fireworkLoc.z + 42.5, 0.0, 0.0, 0.0, math.random() * 0.3 + 0.5, false, false, false) Wait(math.random()*500) @@ -71,60 +54,48 @@ local function DoFireWork(asset, coords) end CreateThread(function() - local asset = 'scr_indep_fireworks' - if not HasNamedPtfxAssetLoaded(asset) then - RequestNamedPtfxAsset(asset) - while not HasNamedPtfxAssetLoaded(asset) do - Wait(10) - end - end - local asset2 = 'proj_xmas_firework' - if not HasNamedPtfxAssetLoaded(asset2) then - RequestNamedPtfxAsset(asset2) - while not HasNamedPtfxAssetLoaded(asset2) do - Wait(10) - end - end - local asset3 = 'proj_indep_firework_v2' - if not HasNamedPtfxAssetLoaded(asset3) then - RequestNamedPtfxAsset(asset3) - while not HasNamedPtfxAssetLoaded(asset3) do - Wait(10) - end - end - local asset4 = 'proj_indep_firework' - if not HasNamedPtfxAssetLoaded(asset4) then - RequestNamedPtfxAsset(asset4) - while not HasNamedPtfxAssetLoaded(asset4) do - Wait(10) - end + local assets = { + 'scr_indep_fireworks', + 'proj_xmas_firework', + 'proj_indep_firework_v2', + 'proj_indep_firework' + } + + for i = 1, #assets do + lib.requestNamedPtfxAsset(assets[i]) end + while true do Wait(700) if fireworkTime > 0 and fireworkLoc then - DrawText3Ds(fireworkLoc.x, fireworkLoc.y, fireworkLoc.z, 'Firework over ~r~'..fireworkTime) + DrawText3D('Firework over ~r~'..fireworkTime, fireworkLoc) end end end) RegisterNetEvent('fireworks:client:UseFirework', function(itemName, assetName) - QBCore.Functions.Progressbar('spawn_object', 'Placing object..', 3000, false, true, { - disableMovement = true, - disableCarMovement = true, - disableMouse = false, - disableCombat = true, - }, { - animDict = 'anim@narcotics@trash', - anim = 'drop_front', - flags = 16, - }, {}, {}, function() -- Done - StopAnimTask(cache.ped, 'anim@narcotics@trash', 'drop_front', 1.0) + if lib.progressBar({ + duration = 3000, + label = 'Placing firework...', + useWhileDead = false, + canCancel = true, + disable = { + move = true, + car = true, + mouse = false, + combat = true + }, + anim = { + dict = 'anim@narcotics@trash', + clip = 'drop_front', + flag = 16 + }, + }) then TriggerServerEvent('consumables:server:UseFirework', itemName) TriggerEvent('inventory:client:ItemBox', QBCore.Shared.Items[itemName], 'remove') local pos = GetEntityCoords(cache.ped) - DoFireWork(assetName, pos) - end, function() -- Cancel - StopAnimTask(cache.ped, 'anim@narcotics@trash', 'drop_front', 1.0) - QBCore.Functions.Notify('Canceled..', 'error') - end) + doFirework(assetName, pos) + else + QBCore.Functions.Notify('Canceled...', 'error') + end end) diff --git a/client/recoil.lua b/client/recoil.lua index 1628e36..0c36d46 100644 --- a/client/recoil.lua +++ b/client/recoil.lua @@ -133,7 +133,7 @@ CreateThread(function() repeat Wait(0) local p = GetGameplayCamRelativePitch() - SetGameplayCamRelativePitch(p+0.1, 0.2) + SetGameplayCamRelativePitch(p + 0.1, 0.2) tv += 0.1 until tv >= recoils[wep] else @@ -141,10 +141,10 @@ CreateThread(function() Wait(0) local p = GetGameplayCamRelativePitch() if recoils[wep] > 0.1 then - SetGameplayCamRelativePitch(p+0.6, 1.2) + SetGameplayCamRelativePitch(p + 0.6, 1.2) tv += 0.6 else - SetGameplayCamRelativePitch(p+0.016, 0.333) + SetGameplayCamRelativePitch(p + 0.016, 0.333) tv += 0.1 end until tv >= recoils[wep] diff --git a/client/seatbelt.lua b/client/seatbelt.lua index 0bcae1a..3fd4d54 100644 --- a/client/seatbelt.lua +++ b/client/seatbelt.lua @@ -1,4 +1,3 @@ -local QBCore = exports['qbx-core']:GetCoreObject() local seatbeltOn = false local harnessOn = false local harnessHp = 20 @@ -29,7 +28,7 @@ local function ejectFromVehicle() SetEntityCoords(cache.ped, coords.x, coords.y, coords.z) Wait(1) SetPedToRagdoll(cache.ped, 5511, 5511, 0, false, false, false) - SetEntityVelocity(cache.ped, veloc.x*4,veloc.y*4,veloc.z*4) + SetEntityVelocity(cache.ped, veloc.x * 4,veloc.y * 4,veloc.z * 4) local ejectspeed = math.ceil(GetEntitySpeed(cache.ped) * 8) if GetEntityHealth(cache.ped) - ejectspeed > 0 then SetEntityHealth(cache.ped, GetEntityHealth(cache.ped) - ejectspeed) diff --git a/client/suicide.lua b/client/suicide.lua index 3e16e79..66a35fd 100644 --- a/client/suicide.lua +++ b/client/suicide.lua @@ -1,4 +1,3 @@ -local QBCore = exports['qbx-core']:GetCoreObject() local suicideWeapons = { `WEAPON_PISTOL`, `WEAPON_PISTOL_MK2`, diff --git a/client/tackle.lua b/client/tackle.lua index 388419f..49dc49b 100644 --- a/client/tackle.lua +++ b/client/tackle.lua @@ -1,12 +1,10 @@ -local QBCore = exports['qbx-core']:GetCoreObject() - lib.addKeybind({ name = 'tackle', description = 'Tackle', defaultKey = 'E', onReleased = function(self) if cache.vehicle then return end - if QBCore.Functions.GetPlayerData().metadata["ishandcuffed"] then return end + if PlayerData.metadata.ishandcuffed then return end if IsPedSprinting(cache.ped) or IsPedRunning(cache.ped) then local coords = GetEntityCoords(cache.ped) local targetId, targetPed, _ = lib.getClosestPlayer(coords, 1.6, false) @@ -15,7 +13,7 @@ lib.addKeybind({ self:disable(true) TriggerServerEvent('tackle:server:TacklePlayer', GetPlayerServerId(targetId)) lib.requestAnimDict('swimming@first_person@diving') - TaskPlayAnim(cache.ped, 'swimming@first_person@diving', 'dive_run_fwd_-45_loop' ,3.0, 3.0, -1, 49, 0, false, false, false) + TaskPlayAnim(cache.ped, 'swimming@first_person@diving', 'dive_run_fwd_-45_loop', 3.0, 3.0, -1, 49, 0, false, false, false) Wait(250) ClearPedTasks(cache.ped) SetPedToRagdoll(cache.ped, 150, 150, 0, 0, 0, 0) diff --git a/client/teleports.lua b/client/teleports.lua index c601be5..e3466fd 100644 --- a/client/teleports.lua +++ b/client/teleports.lua @@ -1,24 +1,8 @@ -local function DrawText3Ds(x, y, z, text) - SetTextScale(0.35, 0.35) - SetTextFont(4) - SetTextProportional(true) - SetTextColour(255, 255, 255, 215) - BeginTextCommandDisplayText('STRING') - SetTextCentre(true) - AddTextComponentSubstringPlayerName(text) - SetDrawOrigin(x,y,z, 0) - EndTextCommandDisplayText(0.0, 0.0) - local factor = (string.len(text)) / 370 - DrawRect(0.0, 0.0+0.0125, 0.017+ factor, 0.03, 0, 0, 0, 75) - ClearDrawOrigin() -end - CreateThread(function() local sleep while true do sleep = 1000 - local ped = PlayerPedId() - local pos = GetEntityCoords(ped) + local pos = GetEntityCoords(cache.ped) for loc in pairs(Config.Teleports) do for k, v in pairs(Config.Teleports[loc]) do @@ -28,27 +12,27 @@ CreateThread(function() DrawMarker(2, v.coords.x, v.coords.y, v.coords.z, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.3, 0.3, 0.15, 255, 255, 255, 255, false, false, 0, true, nil, nil, false) if dist < 1 then - DrawText3Ds(v.coords.x, v.coords.y, v.coords.z, v.drawText) + DrawText3D(v.drawText, v.coords) if IsControlJustReleased(0, 51) then if k == 1 then if v.AllowVehicle then - SetPedCoordsKeepVehicle(ped, Config.Teleports[loc][2].coords.x, Config.Teleports[loc][2].coords.y, Config.Teleports[loc][2].coords.z) + SetPedCoordsKeepVehicle(cache.ped, Config.Teleports[loc][2].coords.x, Config.Teleports[loc][2].coords.y, Config.Teleports[loc][2].coords.z) else - SetEntityCoords(ped, Config.Teleports[loc][2].coords.x, Config.Teleports[loc][2].coords.y, Config.Teleports[loc][2].coords.z) + SetEntityCoords(cache.ped, Config.Teleports[loc][2].coords.x, Config.Teleports[loc][2].coords.y, Config.Teleports[loc][2].coords.z) end if type(Config.Teleports[loc][2].coords) == 'vector4' then - SetEntityHeading(ped, Config.Teleports[loc][2].coords.w) + SetEntityHeading(cache.ped, Config.Teleports[loc][2].coords.w) end elseif k == 2 then if v.AllowVehicle then - SetPedCoordsKeepVehicle(ped, Config.Teleports[loc][1].coords.x, Config.Teleports[loc][1].coords.y, Config.Teleports[loc][1].coords.z) + SetPedCoordsKeepVehicle(cache.ped, Config.Teleports[loc][1].coords.x, Config.Teleports[loc][1].coords.y, Config.Teleports[loc][1].coords.z) else - SetEntityCoords(ped, Config.Teleports[loc][1].coords.x, Config.Teleports[loc][1].coords.y, Config.Teleports[loc][1].coords.z) + SetEntityCoords(cache.ped, Config.Teleports[loc][1].coords.x, Config.Teleports[loc][1].coords.y, Config.Teleports[loc][1].coords.z) end if type(Config.Teleports[loc][1].coords) == 'vector4' then - SetEntityHeading(ped, Config.Teleports[loc][1].coords.w) + SetEntityHeading(cache.ped, Config.Teleports[loc][1].coords.w) end end end diff --git a/client/vehiclepush.lua b/client/vehiclepush.lua index 2b8076d..2bf5229 100644 --- a/client/vehiclepush.lua +++ b/client/vehiclepush.lua @@ -1,5 +1,3 @@ -local QBCore = exports['qbx-core']:GetCoreObject() - local Vehicle = { Coords = nil, Vehicle = nil, @@ -7,32 +5,16 @@ local Vehicle = { IsInFront = false } -local function DrawText3Ds(x, y, z, text) - SetTextScale(0.35, 0.35) - SetTextFont(4) - SetTextProportional(true) - SetTextColour(255, 255, 255, 215) - BeginTextCommandDisplayText('STRING') - SetTextCentre(true) - AddTextComponentSubstringPlayerName(text) - SetDrawOrigin(x,y,z, 0) - EndTextCommandDisplayText(0.0, 0.0) - local factor = (string.len(text)) / 370 - DrawRect(0.0, 0.0+0.0125, 0.017+ factor, 0.03, 0, 0, 0, 75) - ClearDrawOrigin() -end - CreateThread(function() while true do Wait(1000) - local vehicle = QBCore.Functions.GetClosestVehicle() + local pos = GetEntityCoords(cache.ped) + local vehicle = lib.getClosestVehicle(pos, 3.0) if vehicle and vehicle ~= 0 then - local ped = PlayerPedId() - local pos = GetEntityCoords(ped) local vehpos = GetEntityCoords(vehicle) local dimension = GetModelDimensions(GetEntityModel(vehicle)) - if #(pos - vehpos) < 3.0 and not IsPedInAnyVehicle(ped, false) then + if #(pos - vehpos) < 3.0 and not IsPedInAnyVehicle(cache.ped, false) then Vehicle.Coords = vehpos Vehicle.Dimensions = dimension Vehicle.Vehicle = vehicle @@ -59,43 +41,42 @@ CreateThread(function() while true do sleep = 250 if Vehicle.Vehicle then - local ped = PlayerPedId() local vehClass = GetVehicleClass(Vehicle.Vehicle) sleep = 0 if IsVehicleSeatFree(Vehicle.Vehicle, -1) and GetVehicleEngineHealth(Vehicle.Vehicle) <= Config.DamageNeeded and GetVehicleEngineHealth(Vehicle.Vehicle) >= 0 then if vehClass ~= 13 or vehClass ~= 14 or vehClass ~= 15 or vehClass ~= 16 then - DrawText3Ds(Vehicle.Coords.x, Vehicle.Coords.y, Vehicle.Coords.z, 'Press [~g~SHIFT~w~] and [~g~E~w~] to push the vehicle') + DrawText3D('Press [~g~SHIFT~w~] and [~g~E~w~] to push the vehicle', Vehicle.Coords) end end if IsControlPressed(0, 21) and IsVehicleSeatFree(Vehicle.Vehicle, -1) and - not IsEntityAttachedToEntity(ped, Vehicle.Vehicle) and IsControlJustPressed(0, 38) and + not IsEntityAttachedToEntity(cache.ped, Vehicle.Vehicle) and IsControlJustPressed(0, 38) and GetVehicleEngineHealth(Vehicle.Vehicle) <= Config.DamageNeeded then NetworkRequestControlOfEntity(Vehicle.Vehicle) if Vehicle.IsInFront then - AttachEntityToEntity(ped, Vehicle.Vehicle, GetPedBoneIndex(ped, 6286), 0.0, + AttachEntityToEntity(cache.ped, Vehicle.Vehicle, GetPedBoneIndex(cache.ped, 6286), 0.0, Vehicle.Dimensions.y * -1 + 0.1, Vehicle.Dimensions.z + 1.0, 0.0, 0.0, 180.0, false, false, false, true, 0, true) else - AttachEntityToEntity(ped, Vehicle.Vehicle, GetPedBoneIndex(ped, 6286), 0.0, + AttachEntityToEntity(cache.ped, Vehicle.Vehicle, GetPedBoneIndex(cache.ped, 6286), 0.0, Vehicle.Dimensions.y - 0.3, Vehicle.Dimensions.z + 1.0, 0.0, 0.0, 0.0, false, false, false, true, 0, true) end lib.requestAnimDict('missfinale_c2ig_11') - TaskPlayAnim(ped, 'missfinale_c2ig_11', 'pushcar_offcliff_m', 2.0, -8.0, -1, 35, 0, false, false, false) + TaskPlayAnim(cache.ped, 'missfinale_c2ig_11', 'pushcar_offcliff_m', 2.0, -8.0, -1, 35, 0, false, false, false) Wait(200) local currentVehicle = Vehicle.Vehicle while true do Wait(0) if IsDisabledControlPressed(0, 34) then - TaskVehicleTempAction(ped, currentVehicle, 11, 1000) + TaskVehicleTempAction(cache.ped, currentVehicle, 11, 1000) end if IsDisabledControlPressed(0, 9) then - TaskVehicleTempAction(ped, currentVehicle, 10, 1000) + TaskVehicleTempAction(cache.ped, currentVehicle, 10, 1000) end if Vehicle.IsInFront then @@ -109,9 +90,9 @@ CreateThread(function() end if not IsDisabledControlPressed(0, 38) then - DetachEntity(ped, false, false) - StopAnimTask(ped, 'missfinale_c2ig_11', 'pushcar_offcliff_m', 2.0) - FreezeEntityPosition(ped, false) + DetachEntity(cache.ped, false, false) + StopAnimTask(cache.ped, 'missfinale_c2ig_11', 'pushcar_offcliff_m', 2.0) + FreezeEntityPosition(cache.ped, false) break end end @@ -119,4 +100,4 @@ CreateThread(function() end Wait(sleep) end -end) +end) \ No newline at end of file diff --git a/client/vehicletext.lua b/client/vehicletext.lua index 2264b31..d440deb 100644 --- a/client/vehicletext.lua +++ b/client/vehicletext.lua @@ -1,15 +1,13 @@ -local QBCore = exports['qbx-core']:GetCoreObject() - CreateThread(function() - for _, v in pairs(QBCore.Shared.Vehicles) do - local text - if v['brand'] then - text = v['brand'] .. ' ' .. v['name'] - else - text = v['name'] - end - if v['hash'] ~= 0 and v['hash'] ~= nil then - AddTextEntryByHash(v['hash'],text) - end - end + for _, v in pairs(QBCore.Shared.Vehicles) do + local text + if v.brand then + text = v.brand .. ' ' .. v.name + else + text = v.name + end + if v.hash ~= 0 and v.hash ~= nil then + AddTextEntryByHash(v.hash, text) + end + end end) diff --git a/client/weapdrop.lua b/client/weapdrop.lua index f4b9195..302a979 100644 --- a/client/weapdrop.lua +++ b/client/weapdrop.lua @@ -87,6 +87,6 @@ local disabledPickups = { CreateThread(function() for _, hash in pairs(disabledPickups) do - ToggleUsePickupsForPlayer(PlayerId(), hash, false) + ToggleUsePickupsForPlayer(cache.playerId, hash, false) end end) diff --git a/fxmanifest.lua b/fxmanifest.lua index 7b74191..8d506b3 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -1,11 +1,16 @@ fx_version 'cerulean' game 'gta5' -description 'QB-SmallResources' +description 'Collection of small scripts' +repository 'https://github.com/Qbox-project/qbx-smallresources' version '1.1.0' -shared_script 'config.lua' -shared_script '@ox_lib/init.lua' +shared_scripts { + '@qbx-core/import.lua', + '@ox_lib/init.lua', + 'config.lua' +} + server_script 'server/*.lua' client_script 'client/*.lua' @@ -18,5 +23,11 @@ files { 'relationships.dat' } +modules { + 'qbx-core:core', + 'qbx-core:playerdata', + 'qbx-core:utils' +} + lua54 'yes' use_experimental_fxv2_oal 'yes' diff --git a/server/afk.lua b/server/afk.lua index f93e587..e7f4f13 100644 --- a/server/afk.lua +++ b/server/afk.lua @@ -1,4 +1,3 @@ -local QBCore = exports['qbx-core']:GetCoreObject() local loggedInPlayers = {} local checkUser = {} local previousPos = {} diff --git a/server/consumables.lua b/server/consumables.lua index 62a6196..e3f073a 100644 --- a/server/consumables.lua +++ b/server/consumables.lua @@ -1,11 +1,9 @@ -local QBCore = exports['qbx-core']:GetCoreObject() - ----------- / alcohol for cAl in pairs(ConsumablesAlcohol) do QBCore.Functions.CreateUseableItem(cAl, function(source, item) local src = source - local Player = QBCore.Functions.GetPlayer(src) - if Player.Functions.RemoveItem(item.name, 1, item.slot) then + local player = QBCore.Functions.GetPlayer(src) + if player.Functions.RemoveItem(item.name, 1, item.slot) then TriggerClientEvent('consumables:client:DrinkAlcohol', src, item.name) end end) @@ -15,8 +13,8 @@ end for cDr in pairs(ConsumablesDrink) do QBCore.Functions.CreateUseableItem(cDr, function(source, item) local src = source - local Player = QBCore.Functions.GetPlayer(src) - if Player.Functions.RemoveItem(item.name, 1, item.slot) then + local player = QBCore.Functions.GetPlayer(src) + if player.Functions.RemoveItem(item.name, 1, item.slot) then TriggerClientEvent('consumables:client:Drink', src, item.name) end end) @@ -26,8 +24,8 @@ end for cEa in pairs(ConsumablesEat) do QBCore.Functions.CreateUseableItem(cEa, function(source, item) local src = source - local Player = QBCore.Functions.GetPlayer(src) - if Player.Functions.RemoveItem(item.name, 1, item.slot) then + local player = QBCore.Functions.GetPlayer(src) + if player.Functions.RemoveItem(item.name, 1, item.slot) then TriggerClientEvent('consumables:client:Eat', src, item.name) end end) @@ -36,8 +34,8 @@ end ----------- / Drug QBCore.Functions.CreateUseableItem('joint', function(source, item) - local Player = QBCore.Functions.GetPlayer(source) - if not Player.Functions.RemoveItem(item.name, 1, item.slot) then return end + local player = QBCore.Functions.GetPlayer(source) + if not player.Functions.RemoveItem(item.name, 1, item.slot) then return end TriggerClientEvent('consumables:client:UseJoint', source) end) @@ -87,8 +85,8 @@ QBCore.Functions.CreateUseableItem('binoculars', function(source) end) QBCore.Functions.CreateUseableItem('parachute', function(source, item) - local Player = QBCore.Functions.GetPlayer(source) - if not Player.Functions.RemoveItem(item.name, 1, item.slot) then return end + local player = QBCore.Functions.GetPlayer(source) + if not player.Functions.RemoveItem(item.name, 1, item.slot) then return end TriggerClientEvent('consumables:client:UseParachute', source) end) @@ -99,11 +97,11 @@ lib.addCommand('resetparachute', { end) RegisterNetEvent('qb-smallpenis:server:AddParachute', function() - local Player = QBCore.Functions.GetPlayer(source) + local player = QBCore.Functions.GetPlayer(source) - if not Player then return end + if not player then return end - Player.Functions.AddItem('parachute', 1) + player.Functions.AddItem('parachute', 1) end) ----------- / Firework @@ -143,81 +141,81 @@ end) ----------- / Unused -- QBCore.Functions.CreateUseableItem('smoketrailred', function(source, item) --- local Player = QBCore.Functions.GetPlayer(source) --- if not Player.Functions.RemoveItem(item.name, 1, item.slot) then return end +-- local player = QBCore.Functions.GetPlayer(source) +-- if not player.Functions.RemoveItem(item.name, 1, item.slot) then return end -- TriggerClientEvent('consumables:client:UseRedSmoke', source) -- end) -- Events for adding and removing specific items to fix some exploits RegisterNetEvent('consumables:server:resetArmor', function() - local Player = QBCore.Functions.GetPlayer(source) + local player = QBCore.Functions.GetPlayer(source) - if not Player then return end + if not player then return end - Player.Functions.AddItem('heavyarmor', 1) + player.Functions.AddItem('heavyarmor', 1) end) RegisterNetEvent('consumables:server:useHeavyArmor', function() - local Player = QBCore.Functions.GetPlayer(source) + local player = QBCore.Functions.GetPlayer(source) - if not Player then return end + if not player then return end - Player.Functions.RemoveItem('heavyarmor', 1) + player.Functions.RemoveItem('heavyarmor', 1) end) RegisterNetEvent('consumables:server:useArmor', function() - local Player = QBCore.Functions.GetPlayer(source) + local player = QBCore.Functions.GetPlayer(source) - if not Player then return end + if not player then return end - Player.Functions.RemoveItem('armor', 1) + player.Functions.RemoveItem('armor', 1) end) RegisterNetEvent('consumables:server:useMeth', function() - local Player = QBCore.Functions.GetPlayer(source) + local player = QBCore.Functions.GetPlayer(source) - if not Player then return end + if not player then return end - Player.Functions.RemoveItem('meth', 1) + player.Functions.RemoveItem('meth', 1) end) RegisterNetEvent('consumables:server:useOxy', function() - local Player = QBCore.Functions.GetPlayer(source) + local player = QBCore.Functions.GetPlayer(source) - if not Player then return end + if not player then return end - Player.Functions.RemoveItem('oxy', 1) + player.Functions.RemoveItem('oxy', 1) end) RegisterNetEvent('consumables:server:useXTCBaggy', function() - local Player = QBCore.Functions.GetPlayer(source) + local player = QBCore.Functions.GetPlayer(source) - if not Player then return end + if not player then return end - Player.Functions.RemoveItem('xtcbaggy', 1) + player.Functions.RemoveItem('xtcbaggy', 1) end) RegisterNetEvent('consumables:server:useCrackBaggy', function() - local Player = QBCore.Functions.GetPlayer(source) + local player = QBCore.Functions.GetPlayer(source) - if not Player then return end + if not player then return end - Player.Functions.RemoveItem('crack_baggy', 1) + player.Functions.RemoveItem('crack_baggy', 1) end) RegisterNetEvent('consumables:server:useCokeBaggy', function() - local Player = QBCore.Functions.GetPlayer(source) + local player = QBCore.Functions.GetPlayer(source) - if not Player then return end + if not player then return end - Player.Functions.RemoveItem('cokebaggy', 1) + player.Functions.RemoveItem('cokebaggy', 1) end) RegisterNetEvent('consumables:server:drinkAlcohol', function(item) - local Player = QBCore.Functions.GetPlayer(source) + local player = QBCore.Functions.GetPlayer(source) - if not Player then return end + if not player then return end local foundItem = nil @@ -230,13 +228,13 @@ RegisterNetEvent('consumables:server:drinkAlcohol', function(item) if not foundItem then return end - Player.Functions.RemoveItem(foundItem, 1) + player.Functions.RemoveItem(foundItem, 1) end) RegisterNetEvent('consumables:server:UseFirework', function(item) - local Player = QBCore.Functions.GetPlayer(source) + local player = QBCore.Functions.GetPlayer(source) - if not Player then return end + if not player then return end local foundItem = nil @@ -249,23 +247,23 @@ RegisterNetEvent('consumables:server:UseFirework', function(item) if not foundItem then return end - Player.Functions.RemoveItem(foundItem, 1) + player.Functions.RemoveItem(foundItem, 1) end) RegisterNetEvent('consumables:server:addThirst', function(amount) - local Player = QBCore.Functions.GetPlayer(source) + local player = QBCore.Functions.GetPlayer(source) - if not Player then return end + if not player then return end - Player.Functions.SetMetaData('thirst', amount) - TriggerClientEvent('hud:client:UpdateNeeds', source, Player.PlayerData.metadata.hunger, amount) + player.Functions.SetMetaData('thirst', amount) + TriggerClientEvent('hud:client:UpdateNeeds', source, player.PlayerData.metadata.hunger, amount) end) RegisterNetEvent('consumables:server:addHunger', function(amount) - local Player = QBCore.Functions.GetPlayer(source) + local player = QBCore.Functions.GetPlayer(source) - if not Player then return end + if not player then return end - Player.Functions.SetMetaData('hunger', amount) - TriggerClientEvent('hud:client:UpdateNeeds', source, amount, Player.PlayerData.metadata.thirst) + player.Functions.SetMetaData('hunger', amount) + TriggerClientEvent('hud:client:UpdateNeeds', source, amount, player.PlayerData.metadata.thirst) end) diff --git a/server/logs.lua b/server/logs.lua index 146d8c3..5ff9879 100644 --- a/server/logs.lua +++ b/server/logs.lua @@ -1,4 +1,3 @@ -local QBCore = exports['qbx-core']:GetCoreObject() local logQueue, isProcessingQueue, logCount = {}, false, 0 local lastRequestTime, requestDelay = 0, 0 diff --git a/server/main.lua b/server/main.lua index 57f25bd..ec2587c 100644 --- a/server/main.lua +++ b/server/main.lua @@ -1,6 +1,3 @@ -local QBCore = exports['qbx-core']:GetCoreObject() -local VehicleNitrous = {} - RegisterNetEvent('tackle:server:TacklePlayer', function(playerId) TriggerClientEvent('tackle:client:GetTackled', playerId) end) @@ -17,9 +14,9 @@ end) RegisterNetEvent('equip:harness', function(item) local src = source - local Player = QBCore.Functions.GetPlayer(src) + local player = QBCore.Functions.GetPlayer(src) - if not Player then return end + if not player then return end if item.metadata.harnessuses == nil then item.metadata.harnessuses = 19 @@ -34,11 +31,11 @@ end) RegisterNetEvent('seatbelt:DoHarnessDamage', function(hp, data) local src = source - local Player = QBCore.Functions.GetPlayer(src) + local player = QBCore.Functions.GetPlayer(src) local harness = exports.ox_inventory:Search(src, 1, 'harness') - if not Player then return end + if not player then return end if hp == 0 then exports.ox_inventory:RemoveItem(src, 'harness', 1, data.metadata, data.slot) @@ -50,13 +47,13 @@ end) RegisterNetEvent('qb-carwash:server:washCar', function() local src = source - local Player = QBCore.Functions.GetPlayer(src) + local player = QBCore.Functions.GetPlayer(src) - if not Player then return end + if not player then return end - if Player.Functions.RemoveMoney('cash', Config.CarWash.defaultPrice, 'car-washed') then + if player.Functions.RemoveMoney('cash', Config.CarWash.defaultPrice, 'car-washed') then TriggerClientEvent('qb-carwash:client:washCar', src) - elseif Player.Functions.RemoveMoney('bank', Config.CarWash.defaultPrice, 'car-washed') then + elseif player.Functions.RemoveMoney('bank', Config.CarWash.defaultPrice, 'car-washed') then TriggerClientEvent('qb-carwash:client:washCar', src) else TriggerClientEvent('QBCore:Notify', src, 'You dont have enough money..', 'error')