Jump to content

some script for save-load the last team where you have been?


HITMANzz

Recommended Posts

You can save team names in player's account data and load it when he logs back in.

Here is a basic idea:

addEventHandler( "onPlayerQuit", getRootElement(),
function( )
local plrAcc = getPlayerAccount( source );
if not isGuestAccount( plrAcc ) then
setAccountData( plrAcc, "teamname", getTeamName( getPlayerTeam( source ) ) );
end
end
);
 
addEventHandler( "onPlayerLogin", getRootElement( ),
function( _, account )
local teamName = getAccountData( account, "teamname" );
if teamName then
setPlayerTeam( source, getTeamFromName( teamName ) );
end
end
);

Keep in mind that you should do more checks, like if player is in team, if so, get the team's name, if not, don't do anything.. or when loading the data, you should also check if team exists (getTeamFromName would return false or nil if team didn't exist)...

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