Wei Posted May 5, 2012 Posted May 5, 2012 whats wrong here ? 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) -- saves team on quit
Castillo Posted May 5, 2012 Posted May 5, 2012 You've set the script as server side on meta.xml, right?
Wei Posted May 5, 2012 Author Posted May 5, 2012 You've set the script as server side on meta.xml, right? ofc. And no debug errors. Onli some errors from login panel...
Jaysds1 Posted May 6, 2012 Posted May 6, 2012 try this: addEventHandler("onPlayerLogin",root,function() local team = getAccountData (getPlayerAccount(source), "team") -- gets players team if (team==getTeamName(getTeamFromName(team))) then setPlayerTeam(source, getTeamFromName(team)) -- sets players team end end) -- sets players team on login function save() local team = getPlayerTeam(source) -- Gets the players team local account = getPlayerAccount(source) if not isGuestAccount(account) then -- Checks to see if the player is a guest or not if(team)then setAccountData(account, "team", getTeamName(team)) --saves team end end end addEventHandler("onPlayerLogout", root, save) -- saves team on logout addEventHandler("onPlayerQuit", root, save) -- saves team on quit
X-SHADOW Posted May 6, 2012 Posted May 6, 2012 Here Use My Script you'r free to edit it addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), function() teamPolice = createTeam ( "Police", 0, 0, 255 ) teamFreeroamers = createTeam ( "Roberes", 255, 255, 0 ) for id, player in ipairs(getElementsByType("player")) do bindKey(player,"F3","down",teamP,"Police") bindKey(player,"F5","down",teamP,"Roberes") end end) function setTeam() local account = getPlayerAccount(source) local team = getAccountData (account, "team") if team and getTeamFromName(team) then setPlayerTeam(source, getTeamFromName(team)) end end addEventHandler("onPlayerLogin",getRootElement(),setTeam) function saveTeam() local team = getPlayerTeam(source) local account = getPlayerAccount(source) if (team) and not isGuestAccount(account) then setAccountData(account, "team", getTeamName(team)) end end addEventHandler("onPlayerQuit",getRootElement(),saveTeam) addEventHandler("onPlayerJoin",getRootElement(), function() bindKey(source,"F3","down",teamP,"Police") bindKey(source,"F5","down",teamP,"Roberes") end) function teamP(player,key,state,team) if team == "Police" then setPlayerTeam(player,teamPolice) elseif team == "Roberes" then setPlayerTeam(player,teamFreeroamers) end end
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