abu5lf Posted April 3, 2012 Posted April 3, 2012 (edited) This script is to save the police team but does not work I tried a lot but my attempts failed is function onLogin () local uAccount = getPlayerAccount ( source ) local sTeamName = getAccountData ( uAccount, 'POLICE' ) if uAccount and not isGuestAccount ( uAccount ) and sTeamName then setPlayerTeam ( source, getTeamFromName( sTeamName ) ) setElementModel (source, 280) spawnPlayer ( source, 2292.0925292969, 2451.7045898438, 10.8203125, 0, 280, 0, 0 ) else setPlayerTeam ( source, nil ) end end addEventHandler ("onPlayerLogin", root, onLogin) function saveData () local theAccount = getPlayerAccount(source) local team = getPlayerTeam(source) local uTeam = getTeamName ( team ) if theAccount and not isGuestAccount(theAccount) and team == getTeamFromName("Police") then if uTeam then setAccountData (theAccount, "POLICE", uTeam ) end end end addEventHandler ("onPlayerQuit", root, saveData) addEventHandler ("onPlayerLogout", root, saveData) Edited December 25, 2012 by Guest
Castillo Posted April 3, 2012 Posted April 3, 2012 Try this: function onLogin ( _, account ) local sTeamName = getAccountData ( account, 'POLICE' ) if ( account and not isGuestAccount ( account ) and sTeamName ) then setPlayerTeam ( source, getTeamFromName ( sTeamName ) ) setElementModel ( source, 280 ) spawnPlayer ( source, 2292.0925292969, 2451.7045898438, 10.8203125, 0, 280, 0, 0 ) else setPlayerTeam ( source, nil ) end end addEventHandler ( "onPlayerLogin", root, onLogin ) function saveData ( account ) local account = type ( account ) == "userdata" and account or getPlayerAccount ( source ) local team = getPlayerTeam ( source ) local teamName = team and getTeamName ( team ) or "" if ( account and not isGuestAccount ( account ) and teamName == "Police" ) then setAccountData ( account, "POLICE", teamName ) end end addEventHandler ( "onPlayerQuit", root, saveData ) addEventHandler ( "onPlayerLogout", root, saveData )
abu5lf Posted April 3, 2012 Author Posted April 3, 2012 Try this: function onLogin ( _, account ) local sTeamName = getAccountData ( account, 'POLICE' ) if ( account and not isGuestAccount ( account ) and sTeamName ) then setPlayerTeam ( source, getTeamFromName ( sTeamName ) ) setElementModel ( source, 280 ) spawnPlayer ( source, 2292.0925292969, 2451.7045898438, 10.8203125, 0, 280, 0, 0 ) else setPlayerTeam ( source, nil ) end end addEventHandler ( "onPlayerLogin", root, onLogin ) function saveData ( account ) local account = type ( account ) == "userdata" and account or getPlayerAccount ( source ) local team = getPlayerTeam ( source ) local teamName = team and getTeamName ( team ) or "" if ( account and not isGuestAccount ( account ) and teamName == "Police" ) then setAccountData ( account, "POLICE", teamName ) end end addEventHandler ( "onPlayerQuit", root, saveData ) addEventHandler ( "onPlayerLogout", root, saveData ) Thank you
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