Jump to content

On playerquit


aintaro

Recommended Posts

Hello guys,

I want a player to be teleported back to he's original spot when he disconnects from the server but it doesn't work, here is my code:

server side :

function loggedOut() 
    triggerClientEvent("closeTuneInterface", root, closeTuneInterface) 
end 
  
addEventHandler("onPlayerLogout",getRootElement(),loggedOut) 

client side part:

function closeTuneInterface() 
    if (isPedInVehicle(getLocalPlayer())) then 
        local vehicle = getPedOccupiedVehicle ( getLocalPlayer()) 
        setElementPosition(vehicle, 1910, -1758 , 14 ) 
        setElementFrozen ( vehicle, false ) 
        setCameraTarget(getLocalPlayer()) 
        setCameraTarget ( getLocalPlayer() ) 
        setHideWorldInterface(false) 
        if (GUIEditor.window[1]) then 
            givePlayerInput(false) 
            destroyElement ( GUIEditor.window[1] ) 
            GUIEditor.window[1] = nil 
        end 
        if (GUIEditor.window[2]) then 
            destroyElement ( GUIEditor.window[2] ) 
            GUIEditor.window[2] = nil 
        end 
    else 
        setElementPosition(getLocalPlayer(), 1910, -1758 , 14 ) 
        setCameraTarget(getLocalPlayer()) 
        setCameraTarget ( getLocalPlayer() ) 
    end 
end 
  
addEvent("closeTuneInterface", true) 
addEventHandler("closeTuneInterface", root, closeTuneInterface) 

Link to comment

Server :

  
function closeTuneInterface() 
    if (isPedInVehicle(getLocalPlayer())) then 
        local vehicle = getPedOccupiedVehicle ( getLocalPlayer()) 
        setElementPosition(vehicle, 1910, -1758 , 14 ) 
        setElementFrozen ( vehicle, false ) 
        setCameraTarget(getLocalPlayer()) 
        setCameraTarget ( getLocalPlayer() ) 
        setHideWorldInterface(false) 
        if (GUIEditor.window[1]) then 
            givePlayerInput(false) 
            destroyElement ( GUIEditor.window[1] ) 
            GUIEditor.window[1] = nil 
        end 
        if (GUIEditor.window[2]) then 
            destroyElement ( GUIEditor.window[2] ) 
            GUIEditor.window[2] = nil 
        end 
    else 
        setElementPosition(getLocalPlayer(), 1910, -1758 , 14 ) 
        setCameraTarget(getLocalPlayer()) 
        setCameraTarget ( getLocalPlayer() ) 
    end 
end 
  
addEvent("closeTuneInterface", true) 
addEventHandler("closeTuneInterface", source, closeTuneInterface) 
  

Client::

  
function loggedOut() 
    local logout = addEventHandler("onPlayerLogout",getRootElement(),closeTuneInterface) 
    triggerClientEvent("closeTuneInterface", source, logout) 
end 
  
  
  

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...