Xeno Posted November 13, 2011 Share Posted November 13, 2011 Hey guys, Its hard to explain, but ill try... Team 1 Team 5 Im trying to get it so when a new player joins, he is sent to Team 1. (wtf that wasnt hard to explain..........................) Anyway, thanks, and this is what I got so far : function onFirstJoin(player) local redteam = getTeamFromName ( "Team 1" ) setPlayerTeam ( source, redteam ) end addEventHandler("onPlayerLogin",root,onFirstJoin) But I have it so it SAVES the team your in when you leave, and this script changes that so every time you join your automattically sent to team 1. Please help, thanks. Link to comment
Castillo Posted November 13, 2011 Share Posted November 13, 2011 Post your saving team part. Link to comment
Xeno Posted November 13, 2011 Author Share Posted November 13, 2011 Post your saving team part. 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",root,setTeam) function save(player) local team = getPlayerTeam(player) local account = getPlayerAccount(player) if (team) and not isGuestAccount(account) then setAccountData(account, "team", getTeamName(team)) end end addEventHandler ( "onPlayerLogout", root, save ) Link to comment
Castillo Posted November 13, 2011 Share Posted November 13, 2011 function setTeam() local account = getPlayerAccount(source) local team = getAccountData (account, "team") if (team) then setPlayerTeam(source, getTeamFromName(team)) else setPlayerTeam(source, getTeamFromName("Team 1")) end end addEventHandler("onPlayerLogin",root,setTeam) function save() local team = getPlayerTeam(source) local account = getPlayerAccount(source) if (team) and not isGuestAccount(account) then setAccountData(account, "team", getTeamName(team)) end end addEventHandler ( "onPlayerLogout", root, save ) Link to comment
Xeno Posted November 13, 2011 Author Share Posted November 13, 2011 function setTeam() local account = getPlayerAccount(source) local team = getAccountData (account, "team") if (team) then setPlayerTeam(source, getTeamFromName(team)) else setPlayerTeam(source, getTeamFromName("Team 1")) end end addEventHandler("onPlayerLogin",root,setTeam) function save() local team = getPlayerTeam(source) local account = getPlayerAccount(source) if (team) and not isGuestAccount(account) then setAccountData(account, "team", getTeamName(team)) end end addEventHandler ( "onPlayerLogout", root, save ) Thank you, and thanks for the quick reply! Ill test it now man Link to comment
Castillo Posted November 13, 2011 Share Posted November 13, 2011 You're welcome. P.S: It should work. Link to comment
Xeno Posted November 13, 2011 Author Share Posted November 13, 2011 function setTeam() local account = getPlayerAccount(source) local team = getAccountData (account, "team") if (team) then setPlayerTeam(source, getTeamFromName(team)) else setPlayerTeam(source, getTeamFromName("Team 1")) end end addEventHandler("onPlayerLogin",root,setTeam) function save() local team = getPlayerTeam(source) local account = getPlayerAccount(source) if (team) and not isGuestAccount(account) then setAccountData(account, "team", getTeamName(team)) end end addEventHandler ( "onPlayerLogout", root, save ) I THINK theres something wrong... It sends me to the police force team before i've logged in? and I made a new account and stuff and its the same.. EDIT: I got it working, but it doesnt send me to a team? Im just not in a team now? Link to comment
Castillo Posted November 13, 2011 Share Posted November 13, 2011 The script should check if you have "team" account data and if so, it set's your team to that, else it sets to "Team 1". Link to comment
Xeno Posted November 13, 2011 Author Share Posted November 13, 2011 The script should check if you have "team" account data and if so, it set's your team to that, else it sets to "Team 1". So this IS correct? teamUnemp = createTeam("Unemployed",204,204,153) if (team) then setPlayerTeam(source, getTeamFromName(team)) else setPlayerTeam(source, getTeamFromName("Unemployed")) Link to comment
Xeno Posted November 13, 2011 Author Share Posted November 13, 2011 Yes. Perhaps I have tested it wrong, ill use my better PC tomorrow to test it, as I am on my netbook at the moment. 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