Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# qb-spawn
qb-spawn design
qb-spawn design - updated for newest qbcore (Date of update: 25.05.2023)

Updated by Metalholt#1942

![](https://cdn.discordapp.com/attachments/797581154315927573/913605989880692827/unknown.png)

#qb-multicharacter
https://github.com/marcostom32/qb-multicharacter
https://github.com/marcostom32/qb-multicharacter
65 changes: 35 additions & 30 deletions client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,25 @@ local pointCamCoords2 = 0
local cam1Time = 500
local cam2Time = 1000
local choosingSpawn = false
local cam, cam2 = nil, nil
local Houses = {}
local cam = nil
local cam2 = nil

-- Functions

local function SetDisplay(bool)
local translations = {}
for k in pairs(Lang.fallback and Lang.fallback.phrases or Lang.phrases) do
if k:sub(0, #'ui.') then
translations[k:sub(#'ui.' + 1)] = Lang:t(k)
end
end
choosingSpawn = bool
SetNuiFocus(bool, bool)
SendNUIMessage({
type = "ui",
status = bool
action = "showUi",
status = bool,
translations = translations
})
end

Expand All @@ -36,7 +45,7 @@ RegisterNetEvent('qb-spawn:client:openUI', function(value)
end)

RegisterNetEvent('qb-houses:client:setHouseConfig', function(houseConfig)
Config.Houses = houseConfig
Houses = houseConfig
end)

RegisterNetEvent('qb-spawn:client:setupSpawns', function(cData, new, apps)
Expand All @@ -47,7 +56,7 @@ RegisterNetEvent('qb-spawn:client:setupSpawns', function(cData, new, apps)
for i = 1, (#houses), 1 do
myHouses[#myHouses+1] = {
house = houses[i].house,
label = Config.Houses[houses[i].house].adress,
label = Houses[houses[i].house].adress,
}
end
end
Expand All @@ -57,30 +66,30 @@ RegisterNetEvent('qb-spawn:client:setupSpawns', function(cData, new, apps)
action = "setupLocations",
locations = QB.Spawns,
houses = myHouses,
isNew = new
})
end, cData.citizenid)
elseif new then
SendNUIMessage({
action = "setupAppartements",
locations = apps,
isNew = new
})
end
end)

-- NUI Callbacks

RegisterNUICallback("exit", function(data)
RegisterNUICallback("exit", function(_, cb)
SetNuiFocus(false, false)
SendNUIMessage({
type = "ui",
action = "showUi",
status = false
})
choosingSpawn = false
cb("ok")
end)

local cam = nil
local cam2 = nil

local function SetCam(campos)
cam2 = CreateCamWithParams("DEFAULT_SCRIPTED_CAMERA", campos.x, campos.y, campos.z + camZPlus1, 300.00,0.00,0.00, 110.00, false, 0)
PointCamAtCoord(cam2, campos.x, campos.y, campos.z + pointCamCoords)
Expand All @@ -96,36 +105,30 @@ local function SetCam(campos)
SetEntityCoords(PlayerPedId(), campos.x, campos.y, campos.z)
end

RegisterNUICallback('setCam', function(data)
RegisterNUICallback('setCam', function(data, cb)
local location = tostring(data.posname)
local type = tostring(data.type)

DoScreenFadeOut(200)
Wait(500)
DoScreenFadeIn(200)

if DoesCamExist(cam) then
DestroyCam(cam, true)
end

if DoesCamExist(cam2) then
DestroyCam(cam2, true)
end

if DoesCamExist(cam) then DestroyCam(cam, true) end
if DoesCamExist(cam2) then DestroyCam(cam2, true) end
if type == "current" then
QBCore.Functions.GetPlayerData(function(PlayerData)
SetCam(PlayerData.position)
end)
elseif type == "house" then
SetCam(Config.Houses[location].coords.enter)
SetCam(Houses[location].coords.enter)
elseif type == "normal" then
SetCam(QB.Spawns[location].coords)
elseif type == "appartment" then
SetCam(Apartments.Locations[location].coords.enter)
end
cb('ok')
end)

RegisterNUICallback('chooseAppa', function(data)
RegisterNUICallback('chooseAppa', function(data, cb)
local ped = PlayerPedId()
local appaYeet = data.appType
SetDisplay(false)
DoScreenFadeOut(500)
Expand All @@ -139,7 +142,8 @@ RegisterNUICallback('chooseAppa', function(data)
DestroyCam(cam, true)
SetCamActive(cam2, false)
DestroyCam(cam2, true)
SetEntityVisible(PlayerPedId(), true)
SetEntityVisible(ped, true)
cb('ok')
end)

local function PreSpawnPlayer()
Expand All @@ -160,19 +164,19 @@ local function PostSpawnPlayer(ped)
DoScreenFadeIn(250)
end

RegisterNUICallback('spawnplayer', function(data)
RegisterNUICallback('spawnplayer', function(data, cb)
local location = tostring(data.spawnloc)
local type = tostring(data.typeLoc)
local ped = PlayerPedId()
local PlayerData = QBCore.Functions.GetPlayerData()
local insideMeta = PlayerData.metadata["inside"]

if type == "current" then
PreSpawnPlayer()
QBCore.Functions.GetPlayerData(function(PlayerData)
SetEntityCoords(PlayerPedId(), PlayerData.position.x, PlayerData.position.y, PlayerData.position.z)
SetEntityHeading(PlayerPedId(), PlayerData.position.a)
FreezeEntityPosition(PlayerPedId(), false)
QBCore.Functions.GetPlayerData(function(pd)
ped = PlayerPedId()
SetEntityCoords(ped, pd.position.x, pd.position.y, pd.position.z)
SetEntityHeading(ped, pd.position.a)
FreezeEntityPosition(ped, false)
end)

if insideMeta.house ~= nil then
Expand Down Expand Up @@ -207,6 +211,7 @@ RegisterNUICallback('spawnplayer', function(data)
SetEntityHeading(ped, pos.w)
PostSpawnPlayer()
end
cb('ok')
end)

-- Threads
Expand Down
29 changes: 18 additions & 11 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
fx_version 'cerulean'
game 'gta5'

description 'QB-Spawn'
version '1.0.0'
author "Designed by marcostom32"
description 'QB-Spawn Design - Updated by Metalholt#1942'
version '2.0.9'

shared_scripts {
'config.lua',
'@qb-houses/config.lua',
'@qb-apartments/config.lua'
'@qb-core/shared/locale.lua',
'locales/en.lua',
'locales/*.lua',
'config.lua',
'@qb-apartments/config.lua',
}

client_script 'client.lua'
server_script 'server.lua'

server_scripts {
'@oxmysql/lib/MySQL.lua',
'server.lua'
}

ui_page 'html/index.html'

files {
'html/index.html',
'html/style.css',
'html/script.js',
'html/reset.css'
'html/index.html',
'html/style.css',
'html/vue.js',
'html/reset.css'
}

lua54 'yes'
lua54 'yes'
12 changes: 12 additions & 0 deletions locales/en.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
local Translations = {
ui = {
last_location = "Last Location",
confirm = "Confirm",
where_would_you_like_to_start = "Where would you like to start?",
}
}

Lang = Lang or Locale:new({
phrases = Translations,
warnOnMissing = true
})
8 changes: 4 additions & 4 deletions server.lua
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
local QBCore = exports['qb-core']:GetCoreObject()

QBCore.Functions.CreateCallback('qb-spawn:server:getOwnedHouses', function(source, cb, cid)
QBCore.Functions.CreateCallback('qb-spawn:server:getOwnedHouses', function(_, cb, cid)
if cid ~= nil then
local houses = exports.oxmysql:executeSync('SELECT * FROM player_houses WHERE citizenid = ?', {cid})
local houses = MySQL.query.await('SELECT * FROM player_houses WHERE citizenid = ?', {cid})
if houses[1] ~= nil then
cb(houses)
else
cb(nil)
cb({})
end
else
cb(nil)
cb({})
end
end)