Jump to content

Set a team for a new player?


Xeno

Recommended Posts

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

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