#Spawn Selector
1 messages · Page 1 of 1 (latest)
i don´t need to see "last location"
Alright let me check the script
qb-spawn server.lua copy and paste this (assumingly you are using default qb core)
local QBCore = exports['qb-core']:GetCoreObject()
QBCore.Functions.CreateCallback('qb-spawn:server:getOwnedHouses', function(_, cb, cid)
if cid ~= nil then
local houses = MySQL.query.await('SELECT * FROM player_houses WHERE citizenid = ?', {cid})
if houses[1] ~= nil then
cb(houses)
else
cb({})
end
else
cb({})
end
end)
RegisterServerEvent('qb-spawn:server:loadPlayerData', function()
local src = source
local Player = QBCore.Functions.GetPlayer(src)
if not Player then return end
local pos = Player.PlayerData.position
if pos and pos.x ~= 0 and pos.y ~= 0 and pos.z ~= 0 then
TriggerClientEvent('qb-spawn:client:setSpawnPos', src, pos)
else
TriggerClientEvent('qb-spawn:client:setupSpawns', src, false, false)
end
end)
and in client.lua
Add this at the bottom :
RegisterNetEvent('qb-spawn:client:setSpawnPos', function(position)
local ped = PlayerPedId()
DoScreenFadeOut(500)
Wait(1000)
SetEntityCoords(ped, position.x, position.y, position.z)
SetEntityHeading(ped, position.a or 0.0)
ShutdownLoadingScreenNui()
ShutdownLoadingScreen()
Wait(500)
DoScreenFadeIn(1000)
TriggerServerEvent('QBCore:Server:OnPlayerLoaded')
TriggerEvent('QBCore:Client:OnPlayerLoaded')
end)
Let me know if this works
Insane have you tried this ?
What is the name of that spawn resource
I'm little confused, this is not the default spawn selector
is not is another one
qb-spawn server.lua
local QBCore = exports['qb-core']:GetCoreObject()
QBCore.Functions.CreateCallback('qb-spawn:server:getOwnedHouses', function(source, cb, cid)
if cid ~= nil then
local houses = exports.oxmysql:executeSync("SELECT * FROM player_houses WHERE identifier = ? OR JSON_CONTAINS(keyholders, JSON_ARRAY(?))", {cid, cid})
if houses[1] ~= nil then
cb(houses)
else
cb(nil)
end
else
cb(nil)
end
end)
RegisterNetEvent("orangutan:spawn:getHouseCoords", function(houseName)
local src = source
if houseName then
local house = exports.oxmysql:executeSync("SELECT * FROM houselocations WHERE name = ?", {houseName})
if house[1] then
local ped = GetPlayerPed(src)
local data = json.decode(house[1].coords)
local x, y, z = data.enter.x, data.enter.y, data.enter.z
-- print(x, y, z)
SetEntityCoords(ped, x, y, z, false, false, false, true)
end
end
end)
QBCore.Commands.Add("addloc", "Add location for spawn (God Only)", {}, false, function(source)
local src = source
TriggerClientEvent('qb-spawn:client:OpenUIForSelectCoord', src)
end, "god")
So I assume, for "returning" player, or the player which has already an account on your server, you don't want them to get this interface upon logging into server?
client.lua
i want they only have acess to this interface after server restart (RR)
i don´t want for exemple if the player dies in 1 place he can´t "quit" and login and change is location with spawn selector
so only works the interface in server restart
if don´t have server restart auto spawn in last location
Can you send me server.lua
Server.lua is this
@torn rose
Will contact you a little later. Busy atm
Checking out your support post now
SERVER.LUA
local QBCore = exports['qb-core']:GetCoreObject()
local serverSession = os.time()
QBCore.Functions.CreateCallback('qb-spawn:server:getOwnedHouses', function(source, cb, cid)
if cid ~= nil then
local houses = exports.oxmysql:executeSync("SELECT * FROM player_houses WHERE identifier = ? OR JSON_CONTAINS(keyholders, JSON_ARRAY(?))", {cid, cid})
if houses[1] ~= nil then
cb(houses)
else
cb(nil)
end
else
cb(nil)
end
end)
RegisterNetEvent("orangutan:spawn:getHouseCoords", function(houseName)
local src = source
if houseName then
local house = exports.oxmysql:executeSync("SELECT * FROM houselocations WHERE name = ?", {houseName})
if house[1] then
local ped = GetPlayerPed(src)
local data = json.decode(house[1].coords)
local x, y, z = data.enter.x, data.enter.y, data.enter.z
SetEntityCoords(ped, x, y, z, false, false, false, true)
end
end
end)
QBCore.Commands.Add("addloc", "Add location for spawn (God Only)", {}, false, function(source)
TriggerClientEvent('qb-spawn:client:OpenUIForSelectCoord', source)
end, "god")
RegisterNetEvent("qb-core:playerJoined", function()
local src = source
local player = QBCore.Functions.GetPlayer(src)
if player then
local lastSession = player.PlayerData.metadata["last_session"] or 0
if lastSession == serverSession then
TriggerClientEvent("spawn:lastlocation", src)
else
TriggerClientEvent("qb-spawn:client:openUI", src, true)
end
end
end)
AddEventHandler("playerDropped", function()
local src = source
local player = QBCore.Functions.GetPlayer(src)
if player then
player.Functions.SetMetaData("last_session", serverSession)
end
end)
CLIENT.LUA
Can you test this and let me know if it works ?
Did you clear your cache before testing ?
yes now i clear my cache and steel appearing the ui
Find out the exact resource name that you presented here and I might be able to help you. There is a NUI trigger somewhere which I can't figure out, if this was default qb-core it would already be solved.
i can send you the script if you want, this nui is like nopixel inspired
send me the resource
I want this too but for the basic spawn of qbcore
Woefrey there are already resolved topics about this for default spawn of qbcore , try searching around the support
Okey
Do you want to skip the selection at all , or leave "last location" to be chosen in these scenarios
client.lua
server.lua
local QBCore = exports['qb-core']:GetCoreObject()
local firstSpawnMenu = true
QBCore.Functions.CreateCallback('qb-spawn:server:getOwnedHouses', function(source, cb, cid)
if cid ~= nil then
local houses = exports.oxmysql:executeSync(
"SELECT * FROM player_houses WHERE identifier = ? OR JSON_CONTAINS(keyholders, JSON_ARRAY(?))",
{ cid, cid }
)
if houses[1] ~= nil then
cb(houses)
else
cb(nil)
end
else
cb(nil)
end
end)
RegisterNetEvent("orangutan:spawn:getHouseCoords", function(houseName)
local src = source
if houseName then
local house = exports.oxmysql:executeSync(
"SELECT * FROM houselocations WHERE name = ?",
{ houseName }
)
if house[1] then
local ped = GetPlayerPed(src)
local data = json.decode(house[1].coords)
local x, y, z = data.enter.x, data.enter.y, data.enter.z
SetEntityCoords(ped, x, y, z, false, false, false, true)
end
end
end)
QBCore.Commands.Add("addloc", "Add location for spawn (God Only)", {}, false, function(source)
TriggerClientEvent('qb-spawn:client:OpenUIForSelectCoord', source)
end, "god")
AddEventHandler('QBCore:Server:OnPlayerLoaded', function(src)
local isFresh = firstSpawnMenu
firstSpawnMenu = false
TriggerClientEvent('qb-spawn:client:openUI', src, isFresh)
local Player = QBCore.Functions.GetPlayer(src)
TriggerClientEvent('qb-spawn:client:setupSpawns', src, Player.PlayerData.citizenid, isFresh, {})
end)
After restart , everyone gets to choose where to spawn.
If disconnected player has an option to choose "last location"
skip the selection at all
server.lua
local QBCore = exports['qb-core']:GetCoreObject()
local firstSpawnMenu = true
QBCore.Functions.CreateCallback('qb-spawn:server:getOwnedHouses', function(source, cb, cid)
if cid then
local houses = exports.oxmysql:executeSync(
"SELECT * FROM player_houses WHERE identifier = ? OR JSON_CONTAINS(keyholders, JSON_ARRAY(?))",
{ cid, cid }
)
cb(houses[1] ~= nil and houses or nil)
else
cb(nil)
end
end)
RegisterNetEvent("orangutan:spawn:getHouseCoords", function(houseName)
local src = source
if houseName then
local house = exports.oxmysql:executeSync(
"SELECT * FROM houselocations WHERE name = ?",
{ houseName }
)
if house[1] then
local ped = GetPlayerPed(src)
local data = json.decode(house[1].coords)
SetEntityCoords(ped, data.enter.x, data.enter.y, data.enter.z, false, false, false, true)
end
end
end)
QBCore.Commands.Add("addloc", "Add location for spawn (God Only)", {}, false, function(source)
TriggerClientEvent('qb-spawn:client:OpenUIForSelectCoord', source)
end, "god")
AddEventHandler('QBCore:Server:OnPlayerLoaded', function(src)
local isFresh = firstSpawnMenu
firstSpawnMenu = false
if isFresh then
TriggerClientEvent('qb-spawn:client:openUI', src, isFresh)
local Player = QBCore.Functions.GetPlayer(src)
TriggerClientEvent('qb-spawn:client:setupSpawns', src, Player.PlayerData.citizenid, isFresh, {})
else
TriggerClientEvent('qb-spawn:client:autoSpawn', src)
end
end)
client is to add this or replace?
I thought you were understanding me but here's the full code
replace client lua with this 1
I'll be back later
We don't provide support for paid resources. You can contact the authors.
Please for the love of god tell me you didn’t buy a server from nchub
idk this script i get from github, is nc-spawn is nopixel inspired
Send link
i dont find more
Send the link of where you got it from