diff --git a/client/events.lua b/client/events.lua index 955c14f..0e7ae4b 100644 --- a/client/events.lua +++ b/client/events.lua @@ -4,10 +4,9 @@ RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function() ShutdownLoadingScreenNui() LocalPlayer.state:set('isLoggedIn', true, false) - if QBConfig.Server.pvp then - SetCanAttackFriendly(PlayerPedId(), true, false) - NetworkSetFriendlyFireOption(true) - end + if not QBConfig.Server.pvp then return end + SetCanAttackFriendly(PlayerPedId(), true, false) + NetworkSetFriendlyFireOption(true) end) RegisterNetEvent('QBCore:Client:OnPlayerUnload', function() @@ -33,17 +32,16 @@ end) RegisterNetEvent('QBCore:Command:GoToMarker', function() local ped = PlayerPedId() local blip = GetFirstBlipInfoId(8) - if DoesBlipExist(blip) then - local blipCoords = GetBlipCoords(blip) - for height = 1, 1000 do + if not DoesBlipExist(blip) then return end + local blipCoords = GetBlipCoords(blip) + for height = 1, 1000 do + SetPedCoordsKeepVehicle(ped, blipCoords.x, blipCoords.y, height + 0.0) + local foundGround, zPos = GetGroundZFor_3dCoord(blipCoords.x, blipCoords.y, height + 0.0) + if foundGround then SetPedCoordsKeepVehicle(ped, blipCoords.x, blipCoords.y, height + 0.0) - local foundGround, zPos = GetGroundZFor_3dCoord(blipCoords.x, blipCoords.y, height + 0.0) - if foundGround then - SetPedCoordsKeepVehicle(ped, blipCoords.x, blipCoords.y, height + 0.0) - break - end - Wait(0) + break end + Wait(0) end end) @@ -52,12 +50,10 @@ end) RegisterNetEvent('QBCore:Command:SpawnVehicle', function(vehName) local ped = PlayerPedId() local hash = GetHashKey(vehName) - if not IsModelInCdimage(hash) then - return - end + if not IsModelInCdimage(hash) then return end RequestModel(hash) while not HasModelLoaded(hash) do - Wait(10) + Wait(0) end local vehicle = CreateVehicle(hash, GetEntityCoords(ped), GetEntityHeading(ped), true, false) TaskWarpPedIntoVehicle(ped, vehicle, -1) @@ -152,4 +148,4 @@ RegisterNetEvent('QBCore:Client:OnSharedUpdateMultiple', function(tableName, val QBCore.Shared[tableName][key] = value end TriggerEvent('QBCore:Client:UpdateObject') -end) \ No newline at end of file +end)