38 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			Lua
		
	
	
	
	
	
			
		
		
	
	
			38 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			Lua
		
	
	
	
	
	
local QBCore = exports['qb-core']:GetCoreObject()
 | 
						|
local savedLocation = nil
 | 
						|
 | 
						|
RegisterCommand("relog", function()
 | 
						|
    local ped = PlayerPedId()
 | 
						|
    local coords = GetEntityCoords(ped)
 | 
						|
    local heading = GetEntityHeading(ped)
 | 
						|
    local cid = QBCore.Functions.GetPlayerData().citizenid
 | 
						|
 | 
						|
    -- Speicher Ort vor Relog
 | 
						|
    TriggerServerEvent("qb-relogsave:server:saveLocation", cid, {
 | 
						|
        x = coords.x,
 | 
						|
        y = coords.y,
 | 
						|
        z = coords.z
 | 
						|
    }, heading)
 | 
						|
 | 
						|
    TriggerEvent("qb-multicharacter:client:chooseChar")
 | 
						|
end, false)
 | 
						|
 | 
						|
RegisterNetEvent("qb-relogsave:client:restoreLocation", function(pos, heading)
 | 
						|
    savedLocation = {
 | 
						|
        pos = pos,
 | 
						|
        heading = heading
 | 
						|
    }
 | 
						|
end)
 | 
						|
 | 
						|
RegisterNetEvent("qb-spawn:client:spawned", function()
 | 
						|
    if savedLocation then
 | 
						|
        DoScreenFadeOut(500)
 | 
						|
        Wait(500)
 | 
						|
        SetEntityCoords(PlayerPedId(), savedLocation.pos.x, savedLocation.pos.y, savedLocation.pos.z)
 | 
						|
        SetEntityHeading(PlayerPedId(), savedLocation.heading)
 | 
						|
        Wait(500)
 | 
						|
        DoScreenFadeIn(500)
 | 
						|
 | 
						|
        savedLocation = nil
 | 
						|
    end
 | 
						|
end)
 |