housing und dj
This commit is contained in:
parent
112c7b1761
commit
10a5d168d4
731 changed files with 506993 additions and 0 deletions
191
resources/[housing]/qs-housing/client/custom/framework/esx.lua
Normal file
191
resources/[housing]/qs-housing/client/custom/framework/esx.lua
Normal file
|
@ -0,0 +1,191 @@
|
|||
if Config.Framework ~= 'esx' then
|
||||
return
|
||||
end
|
||||
|
||||
ESX = exports['es_extended']:getSharedObject()
|
||||
|
||||
CreateThread(function()
|
||||
PlayerData = GetPlayerData()
|
||||
Debug('init playerData')
|
||||
end)
|
||||
|
||||
RegisterNetEvent('esx:setJob', function(jobData)
|
||||
PlayerData.job = jobData
|
||||
end)
|
||||
|
||||
RegisterNetEvent('esx:playerLoaded')
|
||||
AddEventHandler('esx:playerLoaded', function(playerData)
|
||||
PlayerData = playerData
|
||||
IsLoggedIn = true
|
||||
Wait(2500)
|
||||
TriggerServerCallback('qb-houses:GetInside', function(currentHouse)
|
||||
Debug('qb-houses:GetInside', currentHouse)
|
||||
if currentHouse and currentHouse ~= 'nil' and currentHouse ~= '' then
|
||||
Wait(100)
|
||||
TriggerEvent('qb-houses:client:LastLocationHouse', currentHouse)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('esx:playerLogout')
|
||||
AddEventHandler('esx:playerLogout', function()
|
||||
IsLoggedIn = false
|
||||
CurrentHouseData = {}
|
||||
DeleteBlips()
|
||||
end)
|
||||
|
||||
function TriggerServerCallback(name, cb, ...)
|
||||
ESX.TriggerServerCallback(name, cb, ...)
|
||||
end
|
||||
|
||||
function GetPlayerData()
|
||||
return ESX.GetPlayerData()
|
||||
end
|
||||
|
||||
function GetIdentifier()
|
||||
return GetPlayerData().identifier
|
||||
end
|
||||
|
||||
function GetJobName()
|
||||
return PlayerData?.job?.name or 'unemployed'
|
||||
end
|
||||
|
||||
function GetPlayers()
|
||||
return ESX.Game.GetPlayers()
|
||||
end
|
||||
|
||||
function GetVehicleProperties(vehicle)
|
||||
return ESX.Game.GetVehicleProperties(vehicle)
|
||||
end
|
||||
|
||||
function ShowHelpNotification(msg)
|
||||
BeginTextCommandDisplayHelp('STRING')
|
||||
AddTextComponentSubstringPlayerName(msg)
|
||||
EndTextCommandDisplayHelp(0, false, true, -1)
|
||||
end
|
||||
|
||||
local texts = {}
|
||||
if GetResourceState('qs-textui') == 'started' then
|
||||
function DrawText3D(x, y, z, text, id, key)
|
||||
local _id = id
|
||||
if not texts[_id] then
|
||||
CreateThread(function()
|
||||
texts[_id] = 5
|
||||
while texts[_id] > 0 do
|
||||
texts[_id] = texts[_id] - 1
|
||||
Wait(0)
|
||||
end
|
||||
texts[_id] = nil
|
||||
exports['qs-textui']:DeleteDrawText3D(id)
|
||||
Debug('Deleted text', id)
|
||||
end)
|
||||
TriggerEvent('textui:DrawText3D', x, y, z, text, id, key)
|
||||
end
|
||||
texts[_id] = 5
|
||||
end
|
||||
else
|
||||
function DrawText3D(x, y, z, text)
|
||||
SetTextScale(0.35, 0.35)
|
||||
SetTextFont(4)
|
||||
SetTextProportional(1)
|
||||
SetTextColour(255, 255, 255, 215)
|
||||
SetTextEntry('STRING')
|
||||
SetTextCentre(true)
|
||||
AddTextComponentString(text)
|
||||
SetDrawOrigin(x, y, z, 0)
|
||||
DrawText(0.0, 0.0)
|
||||
local factor = text:len() / 370
|
||||
DrawRect(0.0, 0.0 + 0.0125, 0.017 + factor, 0.03, 0, 0, 0, 75)
|
||||
ClearDrawOrigin()
|
||||
end
|
||||
end
|
||||
|
||||
function DrawText3Ds(x, y, z, text)
|
||||
SetTextScale(0.35, 0.35)
|
||||
SetTextFont(4)
|
||||
SetTextProportional(1)
|
||||
SetTextColour(255, 255, 255, 215)
|
||||
SetTextEntry('STRING')
|
||||
SetTextCentre(true)
|
||||
AddTextComponentString(text)
|
||||
SetDrawOrigin(x, y, z, 0)
|
||||
DrawText(0.0, 0.0)
|
||||
local factor = text:len() / 370
|
||||
DrawRect(0.0, 0.0 + 0.0125, 0.017 + factor, 0.03, 0, 0, 0, 75)
|
||||
ClearDrawOrigin()
|
||||
end
|
||||
|
||||
function DrawTextBoard(x, y, z, text)
|
||||
SetTextScale(0.45, 0.45)
|
||||
SetTextFont(1)
|
||||
SetTextProportional(1)
|
||||
SetTextColour(0, 0, 0, 215)
|
||||
SetTextEntry('STRING')
|
||||
SetTextCentre(true)
|
||||
AddTextComponentString(text)
|
||||
SetDrawOrigin(x, y, z, 0)
|
||||
DrawText(0.0, 0.0)
|
||||
ClearDrawOrigin()
|
||||
end
|
||||
|
||||
function DrawGenericText(text)
|
||||
SetTextColour(186, 186, 186, 255)
|
||||
SetTextFont(4)
|
||||
SetTextScale(0.5, 0.5)
|
||||
SetTextWrap(0.0, 1.0)
|
||||
SetTextCentre(false)
|
||||
SetTextDropshadow(0, 0, 0, 0, 255)
|
||||
SetTextEdge(1, 0, 0, 0, 205)
|
||||
SetTextEntry('STRING')
|
||||
AddTextComponentString(text)
|
||||
DrawText(0.40, 0.00)
|
||||
end
|
||||
|
||||
function Notification(msg, type)
|
||||
if GetResourceState('qs-interface') == 'started' then
|
||||
if type == 'inform' then
|
||||
exports['qs-interface']:AddNotify(msg, 'Inform', 2500, 'fas fa-file')
|
||||
elseif type == 'error' then
|
||||
exports['qs-interface']:AddNotify(msg, 'Error', 2500, 'fas fa-bug')
|
||||
elseif type == 'success' then
|
||||
exports['qs-interface']:AddNotify(msg, 'Success', 2500, 'fas fa-thumbs-up')
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if type == 'inform' then
|
||||
lib.notify({
|
||||
title = 'Housing',
|
||||
description = msg,
|
||||
type = 'inform'
|
||||
})
|
||||
elseif type == 'error' then
|
||||
lib.notify({
|
||||
title = 'Housing',
|
||||
description = msg,
|
||||
type = 'error'
|
||||
})
|
||||
elseif type == 'success' then
|
||||
lib.notify({
|
||||
title = 'Housing',
|
||||
description = msg,
|
||||
type = 'success'
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
function ToggleHud(bool)
|
||||
if bool then
|
||||
Debug('Event to show the hud [client/custom/framework/esx.lua line 177]')
|
||||
-- DisplayRadar(false) -- You can enable or disable mini-map here
|
||||
if GetResourceState('qs-interface') == 'started' then
|
||||
exports['qs-interface']:ToggleHud(false)
|
||||
end
|
||||
else
|
||||
Debug('Event to hide the hud [client/custom/framework/esx.lua line 177]')
|
||||
-- DisplayRadar(true) -- You can enable or disable mini-map here
|
||||
if GetResourceState('qs-interface') == 'started' then
|
||||
exports['qs-interface']:ToggleHud(true)
|
||||
end
|
||||
end
|
||||
end
|
188
resources/[housing]/qs-housing/client/custom/framework/qb.lua
Normal file
188
resources/[housing]/qs-housing/client/custom/framework/qb.lua
Normal file
|
@ -0,0 +1,188 @@
|
|||
if Config.Framework ~= 'qb' then
|
||||
return
|
||||
end
|
||||
|
||||
QBCore = exports['qb-core']:GetCoreObject()
|
||||
|
||||
CreateThread(function()
|
||||
PlayerData = GetPlayerData()
|
||||
end)
|
||||
|
||||
RegisterNetEvent('QBCore:Client:OnPlayerLoaded')
|
||||
AddEventHandler('QBCore:Client:OnPlayerLoaded', function(playerData)
|
||||
PlayerData = GetPlayerData()
|
||||
IsLoggedIn = true
|
||||
Wait(1000)
|
||||
local currentHouseId = QBCore.Functions.GetPlayerData().metadata['currentHouseId']
|
||||
Debug('inside meta', currentHouseId)
|
||||
if currentHouseId then
|
||||
TriggerEvent('qb-houses:client:LastLocationHouse', currentHouseId)
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNetEvent('QBCore:Client:OnJobUpdate', function(jobData)
|
||||
PlayerData.job = jobData
|
||||
end)
|
||||
|
||||
RegisterNetEvent('QBCore:Client:OnPlayerUnload')
|
||||
AddEventHandler('QBCore:Client:OnPlayerUnload', function()
|
||||
IsLoggedIn = false
|
||||
CurrentHouseData = {}
|
||||
DeleteBlips()
|
||||
end)
|
||||
|
||||
function TriggerServerCallback(name, cb, ...)
|
||||
QBCore.Functions.TriggerCallback(name, cb, ...)
|
||||
end
|
||||
|
||||
function GetPlayerData()
|
||||
return QBCore.Functions.GetPlayerData()
|
||||
end
|
||||
|
||||
function GetIdentifier()
|
||||
return GetPlayerData().citizenid
|
||||
end
|
||||
|
||||
function GetJobName()
|
||||
return PlayerData?.job?.name or 'unemployed'
|
||||
end
|
||||
|
||||
function GetPlayers()
|
||||
return QBCore.Functions.GetPlayers()
|
||||
end
|
||||
|
||||
function GetVehicleProperties(vehicle)
|
||||
return QBCore.Functions.GetVehicleProperties(vehicle)
|
||||
end
|
||||
|
||||
function ShowHelpNotification(msg)
|
||||
BeginTextCommandDisplayHelp('STRING')
|
||||
AddTextComponentSubstringPlayerName(msg)
|
||||
EndTextCommandDisplayHelp(0, false, true, -1)
|
||||
end
|
||||
|
||||
local texts = {}
|
||||
if GetResourceState('qs-textui') == 'started' then
|
||||
function DrawText3D(x, y, z, text, id, key)
|
||||
local _id = id
|
||||
if not texts[_id] then
|
||||
CreateThread(function()
|
||||
texts[_id] = 5
|
||||
while texts[_id] > 0 do
|
||||
texts[_id] = texts[_id] - 1
|
||||
Wait(0)
|
||||
end
|
||||
texts[_id] = nil
|
||||
exports['qs-textui']:DeleteDrawText3D(id)
|
||||
Debug('Deleted text', id)
|
||||
end)
|
||||
TriggerEvent('textui:DrawText3D', x, y, z, text, id, key)
|
||||
end
|
||||
texts[_id] = 5
|
||||
end
|
||||
else
|
||||
function DrawText3D(x, y, z, text)
|
||||
SetTextScale(0.35, 0.35)
|
||||
SetTextFont(4)
|
||||
SetTextProportional(1)
|
||||
SetTextColour(255, 255, 255, 215)
|
||||
SetTextEntry('STRING')
|
||||
SetTextCentre(true)
|
||||
AddTextComponentString(text)
|
||||
SetDrawOrigin(x, y, z, 0)
|
||||
DrawText(0.0, 0.0)
|
||||
local factor = text:len() / 370
|
||||
DrawRect(0.0, 0.0 + 0.0125, 0.017 + factor, 0.03, 0, 0, 0, 75)
|
||||
ClearDrawOrigin()
|
||||
end
|
||||
end
|
||||
|
||||
function DrawText3Ds(x, y, z, text)
|
||||
SetTextScale(0.35, 0.35)
|
||||
SetTextFont(4)
|
||||
SetTextProportional(1)
|
||||
SetTextColour(255, 255, 255, 215)
|
||||
SetTextEntry('STRING')
|
||||
SetTextCentre(true)
|
||||
AddTextComponentString(text)
|
||||
SetDrawOrigin(x, y, z, 0)
|
||||
DrawText(0.0, 0.0)
|
||||
local factor = text:len() / 370
|
||||
DrawRect(0.0, 0.0 + 0.0125, 0.017 + factor, 0.03, 0, 0, 0, 75)
|
||||
ClearDrawOrigin()
|
||||
end
|
||||
|
||||
function DrawTextBoard(x, y, z, text)
|
||||
SetTextScale(0.45, 0.45)
|
||||
SetTextFont(1)
|
||||
SetTextProportional(1)
|
||||
SetTextColour(0, 0, 0, 215)
|
||||
SetTextEntry('STRING')
|
||||
SetTextCentre(true)
|
||||
AddTextComponentString(text)
|
||||
SetDrawOrigin(x, y, z, 0)
|
||||
DrawText(0.0, 0.0)
|
||||
ClearDrawOrigin()
|
||||
end
|
||||
|
||||
function DrawGenericText(text)
|
||||
SetTextColour(186, 186, 186, 255)
|
||||
SetTextFont(4)
|
||||
SetTextScale(0.5, 0.5)
|
||||
SetTextWrap(0.0, 1.0)
|
||||
SetTextCentre(false)
|
||||
SetTextDropshadow(0, 0, 0, 0, 255)
|
||||
SetTextEdge(1, 0, 0, 0, 205)
|
||||
SetTextEntry('STRING')
|
||||
AddTextComponentString(text)
|
||||
DrawText(0.40, 0.00)
|
||||
end
|
||||
|
||||
function Notification(msg, type)
|
||||
if GetResourceState('qs-interface') == 'started' then
|
||||
if type == 'inform' then
|
||||
exports['qs-interface']:AddNotify(msg, 'Inform', 2500, 'fas fa-file')
|
||||
elseif type == 'error' then
|
||||
exports['qs-interface']:AddNotify(msg, 'Error', 2500, 'fas fa-bug')
|
||||
elseif type == 'success' then
|
||||
exports['qs-interface']:AddNotify(msg, 'Success', 2500, 'fas fa-thumbs-up')
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if type == 'inform' then
|
||||
lib.notify({
|
||||
title = 'Housing',
|
||||
description = msg,
|
||||
type = 'inform'
|
||||
})
|
||||
elseif type == 'error' then
|
||||
lib.notify({
|
||||
title = 'Housing',
|
||||
description = msg,
|
||||
type = 'error'
|
||||
})
|
||||
elseif type == 'success' then
|
||||
lib.notify({
|
||||
title = 'Housing',
|
||||
description = msg,
|
||||
type = 'success'
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
function ToggleHud(bool)
|
||||
if bool then
|
||||
Debug('Event to show the hud [client/custom/framework/esx.lua line 174]')
|
||||
-- DisplayRadar(false) -- You can enable or disable mini-map here
|
||||
if GetResourceState('qs-interface') == 'started' then
|
||||
exports['qs-interface']:ToggleHud(false)
|
||||
end
|
||||
else
|
||||
Debug('Event to hide the hud [client/custom/framework/esx.lua line 174]')
|
||||
-- DisplayRadar(true) -- You can enable or disable mini-map here
|
||||
if GetResourceState('qs-interface') == 'started' then
|
||||
exports['qs-interface']:ToggleHud(true)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,203 @@
|
|||
if Config.Framework ~= 'standalone' then return end
|
||||
|
||||
local RequestId = 0
|
||||
local serverRequests = {}
|
||||
|
||||
local clientCallbacks = {}
|
||||
|
||||
---@param eventName string
|
||||
---@param callback function
|
||||
---@param ... any
|
||||
TriggerServerCallback = function(eventName, callback, ...)
|
||||
serverRequests[RequestId] = callback
|
||||
|
||||
TriggerServerEvent('houses:triggerServerCallback', eventName, RequestId, GetInvokingResource() or 'unknown', ...)
|
||||
|
||||
RequestId = RequestId + 1
|
||||
end
|
||||
|
||||
exports('TriggerServerCallback', TriggerServerCallback)
|
||||
|
||||
RegisterNetEvent('houses:serverCallback', function(requestId, invoker, ...)
|
||||
if not serverRequests[requestId] then
|
||||
return print(('[^1ERROR^7] Server Callback with requestId ^5%s^7 Was Called by ^5%s^7 but does not exist.'):format(requestId, invoker))
|
||||
end
|
||||
|
||||
serverRequests[requestId](...)
|
||||
serverRequests[requestId] = nil
|
||||
end)
|
||||
|
||||
---@param eventName string
|
||||
---@param callback function
|
||||
_RegisterClientCallback = function(eventName, callback)
|
||||
clientCallbacks[eventName] = callback
|
||||
end
|
||||
|
||||
RegisterNetEvent('houses:triggerClientCallback', function(eventName, requestId, invoker, ...)
|
||||
if not clientCallbacks[eventName] then
|
||||
return print(('[^1ERROR^7] Client Callback not registered, name: ^5%s^7, invoker resource: ^5%s^7'):format(eventName, invoker))
|
||||
end
|
||||
|
||||
clientCallbacks[eventName](function(...)
|
||||
TriggerServerEvent('houses:clientCallback', requestId, invoker, ...)
|
||||
end, ...)
|
||||
end)
|
||||
|
||||
function GetPlayerData()
|
||||
Error('GetPlayerData is not implemented in standalone framework')
|
||||
return {}
|
||||
end
|
||||
|
||||
local playerIdentifier = nil
|
||||
|
||||
function GetIdentifier()
|
||||
if playerIdentifier then
|
||||
return playerIdentifier
|
||||
end
|
||||
local identifier = TriggerServerCallbackSync('houses:GetIdentifier')
|
||||
if identifier then
|
||||
playerIdentifier = identifier
|
||||
end
|
||||
return identifier
|
||||
end
|
||||
|
||||
function GetJobName()
|
||||
Error('GetJobName is used with standalone')
|
||||
return 'police'
|
||||
end
|
||||
|
||||
function GetPlayers()
|
||||
return TriggerServerCallbackSync('houses:GetPlayers')
|
||||
end
|
||||
|
||||
function ShowHelpNotification(msg)
|
||||
BeginTextCommandDisplayHelp('STRING')
|
||||
AddTextComponentSubstringPlayerName(msg)
|
||||
EndTextCommandDisplayHelp(0, false, true, -1)
|
||||
end
|
||||
|
||||
local texts = {}
|
||||
if GetResourceState('qs-textui') == 'started' then
|
||||
function DrawText3D(x, y, z, text, id, key)
|
||||
local _id = id
|
||||
if not texts[_id] then
|
||||
CreateThread(function()
|
||||
texts[_id] = 5
|
||||
while texts[_id] > 0 do
|
||||
texts[_id] = texts[_id] - 1
|
||||
Wait(0)
|
||||
end
|
||||
texts[_id] = nil
|
||||
exports['qs-textui']:DeleteDrawText3D(id)
|
||||
Debug('Deleted text', id)
|
||||
end)
|
||||
TriggerEvent('textui:DrawText3D', x, y, z, text, id, key)
|
||||
end
|
||||
texts[_id] = 5
|
||||
end
|
||||
else
|
||||
function DrawText3D(x, y, z, text)
|
||||
SetTextScale(0.35, 0.35)
|
||||
SetTextFont(4)
|
||||
SetTextProportional(1)
|
||||
SetTextColour(255, 255, 255, 215)
|
||||
SetTextEntry('STRING')
|
||||
SetTextCentre(true)
|
||||
AddTextComponentString(text)
|
||||
SetDrawOrigin(x, y, z, 0)
|
||||
DrawText(0.0, 0.0)
|
||||
local factor = text:len() / 370
|
||||
DrawRect(0.0, 0.0 + 0.0125, 0.017 + factor, 0.03, 0, 0, 0, 75)
|
||||
ClearDrawOrigin()
|
||||
end
|
||||
end
|
||||
|
||||
function DrawText3Ds(x, y, z, text)
|
||||
SetTextScale(0.35, 0.35)
|
||||
SetTextFont(4)
|
||||
SetTextProportional(1)
|
||||
SetTextColour(255, 255, 255, 215)
|
||||
SetTextEntry('STRING')
|
||||
SetTextCentre(true)
|
||||
AddTextComponentString(text)
|
||||
SetDrawOrigin(x, y, z, 0)
|
||||
DrawText(0.0, 0.0)
|
||||
local factor = text:len() / 370
|
||||
DrawRect(0.0, 0.0 + 0.0125, 0.017 + factor, 0.03, 0, 0, 0, 75)
|
||||
ClearDrawOrigin()
|
||||
end
|
||||
|
||||
function DrawTextBoard(x, y, z, text)
|
||||
SetTextScale(0.45, 0.45)
|
||||
SetTextFont(1)
|
||||
SetTextProportional(1)
|
||||
SetTextColour(0, 0, 0, 215)
|
||||
SetTextEntry('STRING')
|
||||
SetTextCentre(true)
|
||||
AddTextComponentString(text)
|
||||
SetDrawOrigin(x, y, z, 0)
|
||||
DrawText(0.0, 0.0)
|
||||
ClearDrawOrigin()
|
||||
end
|
||||
|
||||
function DrawGenericText(text)
|
||||
SetTextColour(186, 186, 186, 255)
|
||||
SetTextFont(4)
|
||||
SetTextScale(0.5, 0.5)
|
||||
SetTextWrap(0.0, 1.0)
|
||||
SetTextCentre(false)
|
||||
SetTextDropshadow(0, 0, 0, 0, 255)
|
||||
SetTextEdge(1, 0, 0, 0, 205)
|
||||
SetTextEntry('STRING')
|
||||
AddTextComponentString(text)
|
||||
DrawText(0.40, 0.00)
|
||||
end
|
||||
|
||||
function Notification(msg, type)
|
||||
if GetResourceState('qs-interface') == 'started' then
|
||||
if type == 'inform' then
|
||||
exports['qs-interface']:AddNotify(msg, 'Inform', 2500, 'fas fa-file')
|
||||
elseif type == 'error' then
|
||||
exports['qs-interface']:AddNotify(msg, 'Error', 2500, 'fas fa-bug')
|
||||
elseif type == 'success' then
|
||||
exports['qs-interface']:AddNotify(msg, 'Success', 2500, 'fas fa-thumbs-up')
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if type == 'inform' then
|
||||
lib.notify({
|
||||
title = 'Housing',
|
||||
description = msg,
|
||||
type = 'inform'
|
||||
})
|
||||
elseif type == 'error' then
|
||||
lib.notify({
|
||||
title = 'Housing',
|
||||
description = msg,
|
||||
type = 'error'
|
||||
})
|
||||
elseif type == 'success' then
|
||||
lib.notify({
|
||||
title = 'Housing',
|
||||
description = msg,
|
||||
type = 'success'
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
function ToggleHud(bool)
|
||||
if bool then
|
||||
Debug('Event to show the hud [client/custom/framework/esx.lua line 189]')
|
||||
-- DisplayRadar(false) -- You can enable or disable mini-map here
|
||||
if GetResourceState('qs-interface') == 'started' then
|
||||
exports['qs-interface']:ToggleHud(false)
|
||||
end
|
||||
else
|
||||
Debug('Event to hide the hud [client/custom/framework/esx.lua line 189]')
|
||||
-- DisplayRadar(true) -- You can enable or disable mini-map here
|
||||
if GetResourceState('qs-interface') == 'started' then
|
||||
exports['qs-interface']:ToggleHud(true)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue