jumalley / Quasar-Housing-ox_lib

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

qs-housing X ox_lib

Qs-Housing using ox_lib

-- * config_minigames.lua
-- ox_lib link : https://github.com/overextended/ox_lib
-- Enjoy !

--██╗░░░░░░█████╗░░█████╗░██╗░░██╗██████╗░██╗░█████╗░██╗░░██╗
--██║░░░░░██╔══██╗██╔══██╗██║░██╔╝██╔══██╗██║██╔══██╗██║░██╔╝
--██║░░░░░██║░░██║██║░░╚═╝█████═╝░██████╔╝██║██║░░╚═╝█████═╝░
--██║░░░░░██║░░██║██║░░██╗██╔═██╗░██╔═══╝░██║██║░░██╗██╔═██╗░
--███████╗╚█████╔╝╚█████╔╝██║░╚██╗██║░░░░░██║╚█████╔╝██║░╚██╗
--╚══════╝░╚════╝░░╚════╝░╚═╝░░╚═╝╚═╝░░░░░╚═╝░╚════╝░╚═╝░░╚═╝

RegisterNetEvent('qs-housing:client:Lockpicking')
AddEventHandler('qs-housing:client:Lockpicking', function()
    local ped = PlayerPedId()
    local pos = GetEntityCoords(ped)

    if closesthouse ~= nil then
        QSHousing.TriggerServerCallback('qs-housing:server:PoliceOnDuty', function(police)
            PoliceCount = police
            if PoliceCount >= Config.RequiredCops then
                local dist = GetDistanceBetweenCoords(pos, Config.Houses[closesthouse].coords.enter.x, Config.Houses[closesthouse].coords.enter.y, Config.Houses[closesthouse].coords.enter.z, true)
                if Config.Houses[closesthouse].IsRaming == nil then
                    Config.Houses[closesthouse].IsRaming = false
                end

                if dist < 1 then
                    if Config.Houses[closesthouse].locked then
                        if not Config.Houses[closesthouse].IsRaming then
                            local lockpickTime = 7500
                            LockpickDoorAnim(lockpickTime)
                            local lockpickFinish = lib.skillCheck({'easy', 'easy', 'easy'})
                            if lockpickFinish then
                            lib.progressCircle({
                            FreezeEntityPosition(Ped, true),
                            duration = 5000,
                            position = 'bottom',
                            useWhileDead = false,
                            canCancel = true,
                            disable = {
                              car = true,
                              combat = true,
                              move = true,
                            },
                            anim = {},
                            prop = {},
                            })
                            Robbing = true
                            if Config.Houses[closesthouse].mlo == false then
                            TriggerEvent('qs-housing:client:EnterHouse')
                            end
                            TriggerServerEvent('qs-housing:server:HomeInvasionOpenDoor', closesthouse)
                            SendTextMessage(Lang("OPEN_THE_DOOR"), 'success')
                            ClearPedSecondaryTask(PlayerPedId())
                            else
                            ClearPedSecondaryTask(PlayerPedId())
                            exports['okokNotify']:Alert("Burglary", "You have failed !", 5000, 'error')
                            DoRamAnimation(false)
                            end
                            if math.random(1, 100) < 50 then -- 50% change to call cops.
                                TriggerServerEvent('qs-housing:server:notifyCops', pos)
                            end
                        else
                            SendTextMessage(Lang("INVASION_ALERT"), 'inform')
                        end
                    else
                        SendTextMessage(Lang("HOUSE_IS_OPEN"), 'inform')
                    end
                else
                    SendTextMessage(Lang("NO_HOUSES_NEARBY"), 'error')
                end
            else
                SendTextMessage(Lang("NO_POLICES"), 'error')
            end
        end)
    else
        SendTextMessage(Lang("NO_HOUSES_NEARBY"), 'error')
    end
end)


--░██████╗████████╗░█████╗░██████╗░███╗░░░███╗██████╗░░█████╗░███╗░░░███╗
--██╔════╝╚══██╔══╝██╔══██╗██╔══██╗████╗░████║██╔══██╗██╔══██╗████╗░████║
--╚█████╗░░░░██║░░░██║░░██║██████╔╝██╔████╔██║██████╔╝███████║██╔████╔██║
--░╚═══██╗░░░██║░░░██║░░██║██╔══██╗██║╚██╔╝██║██╔══██╗██╔══██║██║╚██╔╝██║
--██████╔╝░░░██║░░░╚█████╔╝██║░░██║██║░╚═╝░██║██║░░██║██║░░██║██║░╚═╝░██║
--╚═════╝░░░░╚═╝░░░░╚════╝░╚═╝░░╚═╝╚═╝░░░░░╚═╝╚═╝░░╚═╝╚═╝░░╚═╝╚═╝░░░░░╚═╝

RegisterNetEvent('qs-housing:client:HomeInvasion')
AddEventHandler('qs-housing:client:HomeInvasion', function()
    local ped = PlayerPedId()
    local pos = GetEntityCoords(ped)
    local Skillbar = exports['skillbar']:GetSkillbarObject()

    if closesthouse ~= nil then
        local dist = GetDistanceBetweenCoords(pos, Config.Houses[closesthouse].coords.enter.x, Config.Houses[closesthouse].coords.enter.y, Config.Houses[closesthouse].coords.enter.z, true)
        if Config.Houses[closesthouse].IsRaming == nil then
            Config.Houses[closesthouse].IsRaming = false
        end

        if dist < 1 then
            if Config.Houses[closesthouse].locked then
                if not Config.Houses[closesthouse].IsRaming then
                DoRamAnimation(true)
                local success = lib.skillCheck({'easy', 'easy', 'easy'})
                if success then
                lib.progressCircle({
              FreezeEntityPosition(Ped, true),
              duration = 5000,
              position = 'bottom',
              useWhileDead = false,
              canCancel = true,
              disable = {
                  car = true,
                  combat = true,
                  move = true,
              },
              anim = {},
              prop = {},
          })
          Robbing = true
          if Config.Houses[closesthouse].mlo == false then
              TriggerEvent('qs-housing:client:EnterHouse')
          end
          TriggerServerEvent('qs-housing:server:HomeInvasionOpenDoor', closesthouse)
          SendTextMessage(Lang("OPEN_THE_DOOR"), 'success')
          DoRamAnimation(false)
      else
      exports['okokNotify']:Alert("Stormram", "You have failed !", 5000, 'error')
      DoRamAnimation(false)
      end

                else
                    SendTextMessage(Lang("INVASION_ALERT"), 'inform')
                end
            else
                SendTextMessage(Lang("HOUSE_IS_OPEN"), 'inform')
            end
        else
            SendTextMessage(Lang("NO_HOUSES_NEARBY"), 'error')
        end
    else
        SendTextMessage(Lang("NO_HOUSES_NEARBY"), 'error')
    end
end)

Don't forget to add ox_lib in the fxmanifest.lua of qs-housing.

--fxmanifest.lua

shared_scripts {
	'utils/callback.lua',
	'utils/rpc.lua',
	'utils/utils.lua',
	'@ox_lib/init.lua',
}

About