Memory Posted November 1, 2012 Share Posted November 1, 2012 Hi, I have this code function setTeam() local account = getPlayerAccount(source) -- gets players account local team = getAccountData (account, "team") -- gets players team if (team) and getTeamFromName(team) then setPlayerTeam(source, getTeamFromName(team)) -- sets players team end end addEventHandler("onPlayerLogin",root,setTeam) -- sets players team on login function save() local team = getPlayerTeam(source) -- Gets the players team local account = getPlayerAccount(source) if (team) and not isGuestAccount(account) then -- Checks to see if the player is a guest or not setAccountData(account, "team", getTeamName(team)) --saves team end end addEventHandler("onPlayerQuit", getRootElement(), save) But if remove player, he after reconnect again in team, problem with the save. Function for to removed players. function unassignTeam ( source, commandName ) local account = getPlayerAccount(source) local team = getAccountData (account, "team") -- Check if the player is on a team if team then -- this player is on a team, so we can remove them from it setPlayerTeam ( source, nil ) -- remove the player from the current team end end addCommandHandler ( "takeawaymyteam", unassignTeam ) I try use this, but doesn't work. function delete( source, commandName ) local team = getPlayerTeam(source) local account = getPlayerAccount(source) if (team) and not isGuestAccount(account) then setAccountData(account, "team", nil) end end addCommandHandler ( "remove", delete ) Link to comment
Castillo Posted November 1, 2012 Share Posted November 1, 2012 You get removed from the team after using the "/remove" command? if so, what happens after you reconnect and login again? Link to comment
Renkon Posted November 1, 2012 Share Posted November 1, 2012 In remove, you forgot to use setPlayerTeam to nil. In takeawaymyteam you forgot to setAccountData to nil. Link to comment
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