Tox Posted August 7, 2015 Posted August 7, 2015 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)
iMr.SFA7 Posted August 7, 2015 Posted August 7, 2015 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)
Tox Posted August 7, 2015 Author Posted August 7, 2015 Any error in debugscript 3 ? Nope, it is clean
SpecT Posted August 7, 2015 Posted August 7, 2015 Are you sure you are in a team before you quit the server ?
Tox Posted August 7, 2015 Author Posted August 7, 2015 Are you sure you are in a team before you quit the server ? Duh, but I created the team on admin panel and set my team by admin panel also. Not sure it is wrong
SpecT Posted August 7, 2015 Posted August 7, 2015 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)
SpecT Posted August 7, 2015 Posted August 7, 2015 (edited) 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 August 7, 2015 by Guest
Tox Posted August 7, 2015 Author Posted August 7, 2015 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
SpecT Posted August 7, 2015 Posted August 7, 2015 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!
Tox Posted August 7, 2015 Author Posted August 7, 2015 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now