Jump to content

Not saving dimension


Recommended Posts

Posted

Why not saving dimension?

function onPlayerQuit ( )
      local playeraccount = getPlayerAccount ( source )
      if ( playeraccount ) and not isGuestAccount ( playeraccount ) then -- if the player is logged in
            local dim = getElementDimension ( source ) -- get the player dim
            setAccountData ( playeraccount, "dimension", dim ) -- save it in his account
      end
end
 
function onPlayerLogin (_, playeraccount )
      if ( playeraccount ) then
            local dim = getAccountData ( playeraccount, "dimension" )

            if ( dim ) then
                  setElementDimension ( source, dim )
            end
      end
end
 
addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit )
addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin )

 

Posted (edited)

Look at this topic next time to save yourself some time..

Put an outputChatBox / outputDebugString with the value of variable "dim" inside the if statement and come back with the result.

Edited by pa3ck
Posted (edited)

i tried :) nothing in debug.

Tried with :outputServerLog("login "..getElementDimension(source).."")

always 0

Edited by TheMOG
Posted
addCommandHandler("changemydim", function(p)
    setElementDimension(p, 15)
    outputServerLog("You are in dim: " .. tostring(getElementDimension(p)))
end)

Add this function to your server side script, use "/changemydim" and quit and see what it returns.

Posted

Maybe you set the dimension client side and it's not synced with the server? Not too sure.. How do you set the player's dimension, client or server?

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...