Jump to content

Save player team


roy_ppp

Recommended Posts

first this is not a requesting forum and second you should check out the wiki but anyway i've made it for you this time, i hope it works i didn't had time to test it.

server.lua:

function playerLogin (thePreviousAccount, theCurrentAccount, autoLogin) 
  if  not (isGuestAccount (getPlayerAccount (source))) then 
    local accountData = getAccountData (theCurrentAccount, "team") 
    if (accountData) then 
    setPlayerTeam(source,accountData) 
    end    
  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) 
  
function onLogout(prevAccount) 
  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("onPlayerLogout", getRootElement(), onLogout) 

meta.xml:

<meta> 
    <info author="Castillo" version="1.0.0" type="script"  
    description="team saver when quit/logout" /> 
    <script src="server.lua" type="server"/> 
</meta> 

Link to comment
Solid, I'm wondering why are you so often giving full script instead of direct someone how to make/fix it.. I'm not saying if it's bad or not.. Just thinking..

Also, there was a lot of topics like this one. I think little searching can bring the answer.

I know about this, i was just too lazy to explain it etc so just made the script, next time i will not post whole code ;)

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