Jump to content

Saving Team


Tox

Recommended Posts

Hey uh, I am a little stuck here in my team saving script.The code is below there. I am having a trouble seeing what's wrong-not sure if it's because the "play" resource tho- so I would be so glad if you would give me a hand.

function saveTeam () 
local account = getPlayerAccount (source) 
    if not isGuestAccount (account) then 
    local team = getPlayerTeam (source) 
    setAccountData (account, "savingTeam", team) 
    end  
end 
  
addEventHandler ("onPlayerWasted", root, saveTeam) 
addEventHandler ("onPlayerQuit", root, saveTeam) 
  
function getTeam () 
local account = getPlayerAccount (source) 
    if account then 
        if not isGuestAccount (account) then 
            team = getAccountData (account, "savingTeam") 
            if team then 
            setPlayerTeam (source, team) 
            end 
        end  
    end      
end 
  
addEventHandler ("onPlayerSpawn", root, getTeam) 
addEventHandler ("onPlayerLogin", root, getTeam) 
  

Link to comment

function saveTeam () 
local account = getPlayerAccount (source) 
     if not account or isGuestAccount(account) then return end 
    local team = getPlayerTeam (source) 
    setAccountData (account, "savingTeam", team) 
    end  
end 
addEventHandler ("onPlayerQuit", root, saveTeam) 
  
function getTeam (_,acc) 
        local team = getAccountData (acc, "savingTeam") 
            if team then 
            setPlayerTeam (source, team) 
    end     
end 
addEventHandler ("onPlayerLogin", root, getTeam) 
  
Link to comment

Ha .. you said no error, huh ?

What about the useless end in the first function?

Try this:

function saveTeam () 
    local account = getPlayerAccount (source) 
    if not account or isGuestAccount(account) then return end 
    local team = getPlayerTeam (source) 
    setAccountData (account, "savingTeam", team) 
end 
addEventHandler ("onPlayerQuit", root, saveTeam) 
  
function getTeam (_,acc) 
    local team = getAccountData (acc, "savingTeam") 
    if team then 
        setPlayerTeam (source, team) 
    end     
end 
addEventHandler ("onPlayerLogin", root, getTeam) 

Link to comment

Oh ... wait you can't save the team in your account data. It has to be a string...

function saveTeam () 
    local account = getPlayerAccount (source) 
    if not account or isGuestAccount(account) then return end 
    local team = getTeamName(getPlayerTeam(source)) 
    setAccountData (account, "savingTeam", team) 
end 
addEventHandler ("onPlayerQuit", root, saveTeam) 
  
function getTeam (_,acc) 
    local team = getTeamFromName(getAccountData(acc, "savingTeam")) 
    if team then 
        setPlayerTeam (source, team) 
    end     
end 
addEventHandler ("onPlayerLogin", root, getTeam) 

Now it should work!

Edited by Guest
Link to comment
Ha .. you said no error, huh ?

What about the useless end in the first function?

Try this:

function saveTeam () 
    local account = getPlayerAccount (source) 
    if not account or isGuestAccount(account) then return end 
    local team = getPlayerTeam (source) 
    setAccountData (account, "savingTeam", team) 
end 
addEventHandler ("onPlayerQuit", root, saveTeam) 
  
function getTeam (_,acc) 
    local team = getAccountData (acc, "savingTeam") 
    if team then 
        setPlayerTeam (source, team) 
    end     
end 
addEventHandler ("onPlayerLogin", root, getTeam) 

Well it just doesn't work... Sorry

Link to comment
Oh ... wait you can't save the team in your account data. It has to be a string...
function saveTeam () 
    local account = getPlayerAccount (source) 
    if not account or isGuestAccount(account) then return end 
    local team = getTeamName(getPlayerTeam(source)) 
    setAccountData (account, "savingTeam", team) 
end 
addEventHandler ("onPlayerQuit", root, saveTeam) 
  
function getTeam (_,acc) 
    local team = getTeamFromName(getAccountData(acc, "savingTeam")) 
    if team then 
        setPlayerTeam (source, team) 
    end     
end 
addEventHandler ("onPlayerLogin", root, getTeam) 

Now it should work!

Link to comment
Oh ... wait you can't save the team in your account data. It has to be a string...
function saveTeam () 
    local account = getPlayerAccount (source) 
    if not account or isGuestAccount(account) then return end 
    local team = getTeamName(getPlayerTeam(source)) 
    setAccountData (account, "savingTeam", team) 
end 
addEventHandler ("onPlayerQuit", root, saveTeam) 
  
function getTeam (_,acc) 
    local team = getTeamFromName(getAccountData(acc, "savingTeam")) 
    if team then 
        setPlayerTeam (source, team) 
    end     
end 
addEventHandler ("onPlayerLogin", root, getTeam) 

Now it should work!

Oh, thank you man.

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