Jump to content

[HELP] Setting player into a team when logged in


..:D&G:..

Recommended Posts

Posted

Hello guys, I wanted to make a script that sets admins into the "Staff" team when they login, here is the code:

addEventHandler("onPlayerLogin", resourceRoot, function ( ) 
    local Admins = getOnlineAdmins() 
        if #Admins ~= 0 then 
            for k,v in ipairs ( Admins ) do  
            setPlayerTeam ( getPlayerName(v), "Staff") 
        end 
    end 
end ) 
  
function getOnlineAdmins() 
    local t = {} 
    for k,v in ipairs ( getElementsByType("player") ) do 
        while true do 
            local acc = getPlayerAccount(v) 
            if not acc or isGuestAccount(acc) then break end 
            local accName = getAccountName(acc) 
            local isAdmin = isObjectInACLGroup("user."..accName,aclGetGroup("Admin")) 
            if isAdmin == true then 
                table.insert(t,v) 
            end 
            break 
        end 
    end 
    return t 
end 

There are no errors and it doesn't set the player in the team, anyone know what's wrong?

Posted

your code has absolutly no sense at all.

  
addEventHandler("onPlayerLogin",root, function ( ) 
if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)),aclGetGroup("Admin")) then 
setPlayerTeam(source, getTeamFromName("Staff")) 
end 
end ) 
  

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