Jump to content

Set team on Join


Xeno

Recommended Posts

function onJoin(player) 
local team =getTeamFromName("Guests") 
setPlayerTeam(player, team) 
end 
addEventHandler("onPlayerJoin", getRootElement(), onJoin) 

It does not seem to work... And I get no errors.

EDIT: I actually get a bad argument at setPlayerTeam

Link to comment
    function onJoin() 
    local team =getTeamFromName("Guests") 
    setPlayerTeam(source, team) 
    end 
    addEventHandler("onPlayerJoin", getRootElement(), onJoin) 

That did it, thanks bro.

1 More thing, how would I create a script that changes the team to Admin when an Admin logs in? I just had a quick go but failed... :/

Link to comment
  
local teamadmin= createTeam("Admin's",255,255,255) ---you can change the color  
local teamg= createTeam("Guests",255,255,255) ---you can change the color  
function onJoin(player) 
 setPlayerTeam(player, teamg) 
    end 
     
  
function onlogin() 
local account=getPlayerAccount(source) 
if not   isObjectInACLGroup ( "user." ..getAccountName(account) , aclGetGroup ( "Admin" ) ) 
return end 
setPlayerTeam(source, teamadmin) 
end 
  
function timerl() 
setTimer(onlogin,1000,1,source) 
end 
  
addEventHandler("onPlayerLogin", getRootElement(), timerl) 
  
  
function timer() 
setTimer(onJoin,1000,1,source) 
end 
addEventHandler("onPlayerJoin", getRootElement(), onJoin) 

meta

you need to save the code whit name "team"

<meta> 
  
    <script src="team.lua" type="server" /> 
  
</meta> 

Link to comment
local teamadmin = createTeam("Admin's",255,255,255) ---you can change the color  
local teamg = createTeam("Guests",255,255,255) ---you can change the color  
  
function onJoin(player) 
 setPlayerTeam(player, teamg) 
end     
  
function onLogin() 
if isObjectInACLGroup ("user." ..getAccountName(getPlayerAccount(source)) , aclGetGroup ("Admin")) 
then 
      setPlayerTeam(source, teamadmin) 
      end 
end 
  
function timerl() 
setTimer(onLogin,1000,1,source) 
end 
addEventHandler("onPlayerLogin", getRootElement(), timerl) 
  
function timer() 
setTimer(onJoin,1000,1,source) 
end 
addEventHandler("onPlayerJoin", getRootElement(), timer) 

    

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