Jump to content

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


HITMANzz

Recommended Posts

Posted

Hi friends

I want know if there is some script for save and load the last team where the player has been.

If there is a script, please tell me where i must write it

thanks :)

Posted

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

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