Jump to content

Save player team


Xedo

Recommended Posts

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.

Link to comment

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)

Link to comment

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

Link to comment

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.

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