forked from Simnation/Main
clear script
This commit is contained in:
parent
bce674034a
commit
da481ae71b
3 changed files with 0 additions and 180 deletions
|
@ -1,101 +0,0 @@
|
|||
local QBCore = exports['qb-core']:GetCoreObject()
|
||||
local savedLocation = nil
|
||||
|
||||
-- Relog-Befehl
|
||||
RegisterCommand("relog", function()
|
||||
local ped = PlayerPedId()
|
||||
local coords = GetEntityCoords(ped)
|
||||
local heading = GetEntityHeading(ped)
|
||||
local playerData = QBCore.Functions.GetPlayerData()
|
||||
|
||||
if not playerData or not playerData.citizenid then
|
||||
QBCore.Functions.Notify("Fehler beim Abrufen der Spielerdaten", "error")
|
||||
return
|
||||
end
|
||||
|
||||
-- Prüft, ob der Spieler in einem Fahrzeug ist
|
||||
if IsPedInAnyVehicle(ped, false) then
|
||||
QBCore.Functions.Notify("Du kannst nicht im Fahrzeug relogen", "error")
|
||||
return
|
||||
end
|
||||
|
||||
-- Speichert die Position vor dem Relog
|
||||
TriggerServerEvent("qb-relogsave:server:saveLocation", playerData.citizenid, {
|
||||
x = coords.x,
|
||||
y = coords.y,
|
||||
z = coords.z
|
||||
}, heading)
|
||||
|
||||
QBCore.Functions.Notify("Position gespeichert. Leite zum Charaktermenü weiter...", "primary")
|
||||
|
||||
-- Kurze Verzögerung für die Benachrichtigung
|
||||
Wait(1000)
|
||||
|
||||
-- DIREKTE WEITERLEITUNG ZUM MULTICHARACTER-MENÜ
|
||||
-- Wir verwenden mehrere Methoden, um sicherzustellen, dass eine funktioniert
|
||||
|
||||
-- Methode 1: Standard um-multicharacter Event
|
||||
TriggerEvent("um-multicharacter:client:chooseChar")
|
||||
|
||||
-- Methode 2: Alternative Events für um-multicharacter
|
||||
Wait(100)
|
||||
TriggerEvent("um-multicharacter:client:openUI")
|
||||
|
||||
-- Methode 3: Spieler vom Server trennen (ohne Kick)
|
||||
Wait(100)
|
||||
TriggerServerEvent("QBCore:Server:OnPlayerUnload")
|
||||
|
||||
-- Methode 4: Direkte Weiterleitung zum Multicharacter-Menü über Server
|
||||
Wait(100)
|
||||
TriggerServerEvent("qb-relogsave:server:redirectToMultichar")
|
||||
end, false)
|
||||
|
||||
-- Empfängt die gespeicherte Position vom Server
|
||||
RegisterNetEvent("qb-relogsave:client:restoreLocation", function(pos, heading)
|
||||
if not pos or not pos.x or not pos.y or not pos.z then return end
|
||||
|
||||
savedLocation = {
|
||||
pos = pos,
|
||||
heading = heading
|
||||
}
|
||||
end)
|
||||
|
||||
-- Setzt die Position nach dem Spawn (QBCore Standard)
|
||||
RegisterNetEvent("QBCore:Client:OnPlayerLoaded", function()
|
||||
Wait(1000) -- Warte kurz, bis alles geladen ist
|
||||
RestorePosition()
|
||||
end)
|
||||
|
||||
-- Fallback für um-multicharacter
|
||||
RegisterNetEvent("um-multicharacter:client:spawned", function()
|
||||
Wait(1000)
|
||||
RestorePosition()
|
||||
end)
|
||||
|
||||
-- Alternative Events für um-multicharacter
|
||||
RegisterNetEvent("um-multicharacter:client:playerSpawned", function()
|
||||
Wait(1000)
|
||||
RestorePosition()
|
||||
end)
|
||||
|
||||
-- Funktion zum Wiederherstellen der Position
|
||||
function RestorePosition()
|
||||
if savedLocation then
|
||||
-- Verzögerung für sicheres Teleportieren
|
||||
Wait(500)
|
||||
DoScreenFadeOut(500)
|
||||
Wait(600)
|
||||
|
||||
-- Teleportiere den Spieler
|
||||
SetEntityCoords(PlayerPedId(), savedLocation.pos.x, savedLocation.pos.y, savedLocation.pos.z)
|
||||
SetEntityHeading(PlayerPedId(), savedLocation.heading)
|
||||
|
||||
Wait(500)
|
||||
DoScreenFadeIn(500)
|
||||
|
||||
-- Löscht die gespeicherte Position
|
||||
savedLocation = nil
|
||||
|
||||
QBCore.Functions.Notify("Position wiederhergestellt", "success")
|
||||
end
|
||||
end
|
|
@ -1,13 +0,0 @@
|
|||
fx_version 'cerulean'
|
||||
game 'gta5'
|
||||
|
||||
description 'Easy Relog // um-multi. ist erforderlich'
|
||||
author 'Duck'
|
||||
version '1.0.0'
|
||||
|
||||
client_script 'client.lua'
|
||||
server_script 'server.lua'
|
||||
|
||||
shared_script '@qb-core/shared/locale.lua'
|
||||
dependency 'qb-core'
|
||||
dependency 'um-multicharacter'
|
|
@ -1,66 +0,0 @@
|
|||
local savedLocations = {}
|
||||
local QBCore = exports['qb-core']:GetCoreObject()
|
||||
|
||||
-- Speichert die Position des Spielers beim Relog
|
||||
RegisterNetEvent("qb-relogsave:server:saveLocation", function(cid, coords, heading)
|
||||
if not cid or not coords then return end
|
||||
|
||||
savedLocations[cid] = {
|
||||
pos = coords,
|
||||
heading = heading
|
||||
}
|
||||
|
||||
print("[Relog] Position für " .. cid .. " gespeichert")
|
||||
end)
|
||||
|
||||
-- Lädt die Position beim Login
|
||||
RegisterNetEvent('QBCore:Server:OnPlayerLoaded', function()
|
||||
local src = source
|
||||
local Player = QBCore.Functions.GetPlayer(src)
|
||||
|
||||
if not Player then return end
|
||||
|
||||
local cid = Player.PlayerData.citizenid
|
||||
|
||||
if savedLocations[cid] then
|
||||
local pos = savedLocations[cid].pos
|
||||
local heading = savedLocations[cid].heading
|
||||
|
||||
TriggerClientEvent("qb-relogsave:client:restoreLocation", src, pos, heading)
|
||||
print("[Relog] Position für " .. cid .. " wiederhergestellt")
|
||||
|
||||
savedLocations[cid] = nil
|
||||
end
|
||||
end)
|
||||
|
||||
-- Alternative Event für um-multicharacter
|
||||
RegisterNetEvent('um-multicharacter:server:CharacterLoaded', function()
|
||||
local src = source
|
||||
local Player = QBCore.Functions.GetPlayer(src)
|
||||
|
||||
if not Player then return end
|
||||
|
||||
local cid = Player.PlayerData.citizenid
|
||||
|
||||
if savedLocations[cid] then
|
||||
TriggerClientEvent("qb-relogsave:client:restoreLocation", src, savedLocations[cid].pos, savedLocations[cid].heading)
|
||||
savedLocations[cid] = nil
|
||||
end
|
||||
end)
|
||||
|
||||
-- Server-seitige Weiterleitung zum Multicharacter
|
||||
RegisterNetEvent("qb-relogsave:server:redirectToMultichar", function()
|
||||
local src = source
|
||||
|
||||
-- Versuche verschiedene Server-Events für um-multicharacter
|
||||
TriggerClientEvent("um-multicharacter:client:chooseChar", src)
|
||||
|
||||
-- Fallback: Spieler trennen, aber sanft
|
||||
Citizen.SetTimeout(500, function()
|
||||
if GetPlayerPing(src) > 0 then
|
||||
-- Spieler ist noch verbunden, versuche sanften Disconnect
|
||||
TriggerEvent("um-multicharacter:server:disconnect", src)
|
||||
TriggerEvent("um-multicharacter:server:loadUserData", src)
|
||||
end
|
||||
end)
|
||||
end)
|
Loading…
Add table
Add a link
Reference in a new issue