Jump to content

Save player team


Xedo

Recommended Posts

Posted

hi gyus. I try to save team to account but every time after reconnect i'm not in saved team o_O, can anyone help me please?

Posted

meta.xml:

<meta>
<script src="saveteam.lua" type="server" /> 
</meta>

saveteam.lua:

function playerLogin (thePreviousAccount, theCurrentAccount, autoLogin)
if  not (isGuestAccount (getPlayerAccount (source))) then
local playerTeam = getAccountData (theCurrentAccount, "team")
setPlayerTeam(source,playerTeam)
end
end
addEventHandler ("onPlayerLogin", getRootElement(), playerLogin)
 
function onQuit (quitType, reason, responsibleElement,thePreviousAccount)
if not (isGuestAccount (getPlayerAccount (source))) then
   account = getPlayerAccount (source)
if (account) then
local team = getPlayerTeam(source)
local teamName = getTeamName(team)
setAccountData (account, "team", teamName)
end
end
end
addEventHandler ("onPlayerQuit", getRootElement(), onQuit)

this should work.

Posted

tnx, but it doesn't works too :(

i made something like you yesterday

function playerLogin (thePreviousAccount, theCurrentAccount, autoLogin)
 if  not (isGuestAccount (getPlayerAccount (source))) then
   account = getPlayerAccount (source)
   if (accountData) then
local playerTeam = getAccountData (theCurrentAccount, "Team")
 
     spawnPlayer (source, playerteam)
   end
 end
end
addEventHandler ("onPlayerLogin", getRootElement(), playerLogin)
 
function onQuit (quitType, reason, responsibleElement)
 if not (isGuestAccount (getPlayerAccount (source))) then
   account = getPlayerAccount (source)
   if (account) then
     setAccountData (account, "Team", getPlayerTeam (source))
   end
 end
end
addEventHandler ("onPlayerQuit", getRootElement(), onQuit)

Posted

fixed function from solidsnake script

function playerLogin (thePreviousAccount, theCurrentAccount, autoLogin)
if  not (isGuestAccount (getPlayerAccount (source))) then
local playerTeam = getAccountData (theCurrentAccount, "team")
local teamElement = getTeamFromName(playerTeam)
if (teamElement) then
setPlayerTeam(source,playerTeam)
end
end
end
addEventHandler ("onPlayerLogin", getRootElement(), playerLogin)

not tested too, should work

Posted

Can someone answer me: What's the point of using getPlayerAccount in onPlayerLogin event?

People, think for a moment. Also, can you login to a guest account? I'm pretty sure the 2nd line is pointless.

"it doesn't work" is as helpful to us as saying "Jump!" to a depressed person standing on a cliff.

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