-- # Server Side
addEventHandler("onPlayerQuit",root,
function ( )
local account = getPlayerAccount(source)
if not isGuestAccount (account ) then
local Skin = getElementModel(source)
setAccountData (account,"CMG2.skin",Skin )
local x,y,z = getElementPosition(source)
setAccountData ( account, "CMG2.Xpos", x )
setAccountData ( account, "CMG2.Ypos", y )
setAccountData ( account, "CMG2.Zpos", z )
end
end
)
addEventHandler("onPlayerLogout",root,
function ( account )
if not isGuestAccount (account ) then
local Skin = getElementModel(source)
setAccountData (account,"CMG2.skin",Skin )
local x,y,z = getElementPosition(source)
setAccountData ( account, "CMG2.Xpos", x )
setAccountData ( account, "CMG2.Ypos", y )
setAccountData ( account, "CMG2.Zpos", z )
end
end
)
addEventHandler("onPlayerLogin",root,
function ( _,account )
local skin = getAccountData (account,"CMG2.skin" )
local x,y,z = getAccountData ( account, "CMG2.Xpos" ),getAccountData ( account, "CMG2.Ypos" ),getAccountData ( account, "CMG2.Zpos" )
if x and y and z then
spawnPlayer(source,x,y,z + 0.5,0,tonumber(skin),0)
setCameraTarget(source)
fadeCamera(source,true,2.5)
else
-- spawnPlayer(source,0,0,999999)
--setCameraTarget(source)
--fadeCamera(source,true,2.5)
end
end)