BorderLine Posted March 21, 2012 Share Posted March 21, 2012 i was searching on forum but i didnt find . Is about save team Anyone know why this dont work? debug dont show errors server function onPlayerQuit ( ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) and not isGuestAccount ( playeraccount ) then local playerteam = getPlayerTeam ( source ) setAccountData ( playeraccount, "team", playerteam ) end end function onPlayerLogin (_, playeraccount ) if ( playeraccount ) then local playerteam = getAccountData ( playeraccount, "team" ) if ( playerteam ) then setPlayerTeam ( source, playerteam ) end end end addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin) Link to comment
Kenix Posted March 21, 2012 Share Posted March 21, 2012 (edited) You save userdata but should save team name. On quit. getTeamName On login. getTeamFromName Because you save team name string ( in event onPlayerQuit ) and you need get team from string ( in event onPlayerLogin ). function fSaveManager ( ) local uAccount = getPlayerAccount ( source ) if uAccount and not isGuestAccount ( uAccount ) then if eventName == 'onPlayerLogin' then local sTeamName = getAccountData ( uAccount, 'team' ) if sTeamName then setPlayerTeam ( source, getTeamFromName( sTeamName ) ) end elseif eventName == 'onPlayerQuit' then local uTeam = getPlayerTeam( source ) if uTeam then uTeam = getTeamName( uTeam ) end setAccountData ( uAccount, 'team', uTeam ) end end end addEventHandler ( 'onPlayerQuit', root, fSaveManager ) addEventHandler ( 'onPlayerLogin', root, fSaveManager ) Ask questions if you not understand something. Edited March 21, 2012 by Guest Link to comment
BorderLine Posted March 21, 2012 Author Share Posted March 21, 2012 Perfect can delete script, or thieves will steal thanks a loot bro Link to comment
Kenix Posted March 21, 2012 Share Posted March 21, 2012 No problem. I do not care whether if stolen. Link to comment
TwiX! Posted March 21, 2012 Share Posted March 21, 2012 Perfect can delete script, or thieves will steal thanks a loot bro u can edit your post 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