Jump to content

ACL teamsaver


Sex*

Recommended Posts

Why doesnt it set my team? It creates the team though...

It has no errors...

function setTeam(_, account) 
local team = getAccountName ( account )  
    if isObjectInACLGroup ("user."..team, aclGetGroup ( "SuperModerator" ) ) then 
            if not getTeamFromName(team) then 
            MainTeam = createTeam(team, 255, 50, 0)   
        end 
        setPlayerTeam(source, MainTeam) 
    end 
end 
addEventHandler("onPlayerLogin", root, setTeam) 
  
function setTeam2(_, account) 
local team = getAccountName ( account )  
    if isObjectInACLGroup ("user."..team, aclGetGroup ( "Admin" ) ) then 
            if not getTeamFromName(team) then 
            MainTeam = createTeam(team, 255, 50, 0)   
        end 
        setPlayerTeam(source, MainTeam) 
    end 
end 
addEventHandler("onPlayerLogin", root, setTeam2) 

Edited by Guest
Link to comment

Well now it created a team that has my account name and moved me into there. Tried to modify it like this:

function setTeam2(_, account) 
local team = getAccountName ( account ) 
    if isObjectInACLGroup ("user."..team, aclGetGroup ( "Admin" ) ) then 
            if not getTeamFromName(team) then 
            MainTeam = createTeam( MainTeam, 255, 50, 0)   
        end 
        setPlayerTeam(source, MainTeam) 
    end 
end 
addEventHandler("onPlayerLogin", root, setTeam2) 

But didnt work...

Link to comment
Did it work or not? because you confused me, you just said that it created it, but at the same time you said it doesn't work.

It did but it created a team with my name on it so I found what I have done wrong so I tried to fix it but I got bad arguments:

function setTeam2(_, account) 
local acc = getAccountName ( account ) 
    if isObjectInACLGroup ("user."..acc, aclGetGroup ( "Admin" ) ) then 
            if not getTeamFromName(team) then 
            MainTeam = createTeam(team, 255, 50, 0)   
        end 
        setPlayerTeam(source, MainTeam) 
    end 
end 
addEventHandler("onPlayerLogin", root, setTeam2) 
  

I had bad arguments in these lines:

          if not getTeamFromName(team) then 
            MainTeam = createTeam(team, 255, 50, 0)   

Link to comment
You want to create a team with the name "Admin"? if so, then just replace "team" with "Admin".

No...Here is my full code:

function createTeamsOnStart() 
    MainTeam = createTeam("Fucking Awesome Players!", 255, 50, 0)   
end 
addEventHandler("onResourceStart", resourceRoot, createTeamsOnStart) 
  
function setTeam(_, account) 
local acc = getAccountName ( account ) 
    if isObjectInACLGroup ("user."..acc, aclGetGroup ( "SuperModerator" ) ) then 
            if not getTeamFromName(team) then 
            MainTeam = createTeam(team, 255, 50, 0)   
        end 
        setPlayerTeam(source, MainTeam) 
    end 
end 
addEventHandler("onPlayerLogin", root, setTeam) 
  
function setTeam2(_, account) 
local acc = getAccountName ( account ) 
    if isObjectInACLGroup ("user."..acc, aclGetGroup ( "Admin" ) ) then 
            if not getTeamFromName(team) then 
            MainTeam = createTeam(team, 255, 50, 0)   
        end 
        setPlayerTeam(source, MainTeam) 
    end 
end 
addEventHandler("onPlayerLogin", root, setTeam2) 
  
  
  
  
  
function unassignTeam() 
    local team = getPlayerTeam(source) 
    if (team and MainTeam and team == MainTeam) then 
        setPlayerTeam(source, nil) 
        remove(source) 
    end 
end 
addEventHandler("onPlayerLogout", root, unassignTeam) 
  
function remove(source) 
    if MainTeam and (countPlayersInTeam(MainTeam) == 0) then 
        destroyElement(MainTeam) 
    end 
end 

Link to comment

Try this:

function createTeamsOnStart() 
    MainTeam = createTeam(":O Awesome Players!", 255, 50, 0)   
end 
addEventHandler("onResourceStart", resourceRoot, createTeamsOnStart) 
  
function setTeam(_, account) 
local acc = getAccountName ( account ) 
    if isObjectInACLGroup("user."..acc, aclGetGroup( "SuperModerator" )) 
    or isObjectInACLGroup("user."..acc, aclGetGroup( "Admin" )) then 
        if MainTeam then 
            setPlayerTeam(source, MainTeam) 
        end 
    end 
end 
addEventHandler("onPlayerLogin", root, setTeam) 
  
function unassignTeam() 
    local team = getPlayerTeam(source) 
    if (team and MainTeam and team == MainTeam) then 
        setPlayerTeam(source, nil) 
        remove(source) 
    end 
end 
addEventHandler("onPlayerLogout", root, unassignTeam) 
  
function remove(source) 
    if MainTeam and (countPlayersInTeam(MainTeam) == 0) then 
        destroyElement(MainTeam) 
    end 
end 

Link to comment

You forgot that my teamsaver detroys the team if it gets empty. Your script moved me into team but as soon it gets empty and destroyed it will not be recreacted. I tried something to recreate the team but no sucess:

function setTeam(_, account) 
local acc = getAccountName ( account ) 
    if isObjectInACLGroup("user."..acc, aclGetGroup( "SuperModerator" )) 
    or isObjectInACLGroup("user."..acc, aclGetGroup( "Admin" )) then 
   if MainTeam then 
            setPlayerTeam(source, MainTeam) 
        if not MainTeam then 
            MainTeam = createTeam(team, 255, 50, 0) 
        end 
            setPlayerTeam(source, MainTeam) 
        end 
    end 
end 
addEventHandler("onPlayerLogin", root, setTeam) 

Link to comment
function createTeamsOnStart() 
    MainTeam = createTeam(":O Awesome Players!", 255, 50, 0)   
end 
addEventHandler("onResourceStart", resourceRoot, createTeamsOnStart) 
  
function setTeam(_, account) 
local acc = getAccountName ( account ) 
    if isObjectInACLGroup ("user."..acc, aclGetGroup ( "SuperModerator" ) ) then 
            if not getTeamFromName(team) then 
            MainTeam = createTeam(team, 255, 50, 0)   
        end 
        setPlayerTeam(source, MainTeam) 
    end 
end 
addEventHandler("onPlayerLogin", root, setTeam) 
  
function setTeam2(_, account) 
local acc = getAccountName ( account ) 
    if isObjectInACLGroup ("user."..acc, aclGetGroup ( "Admin" ) ) then 
            if not getTeamFromName(team) then 
            MainTeam = createTeam(team, 255, 50, 0)   
        end 
        setPlayerTeam(source, MainTeam) 
    end 
end 
addEventHandler("onPlayerLogin", root, setTeam2) 
  
function unassignTeam ( ) 
    local team = getPlayerTeam ( source ) 
    if ( team ) then 
        setPlayerTeam ( source, nil ) 
        local players = countPlayersInTeam ( team ) 
        if ( players == 0 ) then 
            destroyElement ( team ) 
        end 
    end 
end 
addEventHandler ( "onPlayerLogout", root, unassignTeam ) 

Link to comment
function createTeamsOnStart() 
    MainTeam = createTeam(":O Awesome Players!", 255, 50, 0)   
end 
addEventHandler("onResourceStart", resourceRoot, createTeamsOnStart) 
  
function setTeam(_, account) 
local acc = getAccountName ( account ) 
    if isObjectInACLGroup ("user."..acc, aclGetGroup ( "SuperModerator" ) ) then 
            if not getTeamFromName(team) then 
            MainTeam = createTeam(team, 255, 50, 0)   
        end 
        setPlayerTeam(source, MainTeam) 
    end 
end 
addEventHandler("onPlayerLogin", root, setTeam) 
  
function setTeam2(_, account) 
local acc = getAccountName ( account ) 
    if isObjectInACLGroup ("user."..acc, aclGetGroup ( "Admin" ) ) then 
            if not getTeamFromName(team) then 
            MainTeam = createTeam(team, 255, 50, 0)   
        end 
        setPlayerTeam(source, MainTeam) 
    end 
end 
addEventHandler("onPlayerLogin", root, setTeam2) 
  
function unassignTeam ( ) 
    local team = getPlayerTeam ( source ) 
    if ( team and MainTeam and team == MainTeam ) then 
        setPlayerTeam ( source, nil ) 
        local players = countPlayersInTeam ( team ) 
        if ( players == 0 ) then 
            destroyElement ( team ) 
        end 
    end 
end 
addEventHandler ( "onPlayerLogout", root, unassignTeam ) 

Doesnt work.

Link to comment
local teams = { } 
  
function createTeamsOnStart ( ) 
    local team = createTeam ( ":O Awesome Players!", 255, 50, 0 ) 
    teams [ team ] = true 
end 
addEventHandler ( "onResourceStart", resourceRoot, createTeamsOnStart ) 
  
function setTeam ( _, account ) 
    local acc = getAccountName ( account ) 
    local team = "" 
    if isObjectInACLGroup ( "user.".. acc, aclGetGroup ( "SuperModerator" ) ) then 
        team = "Moderators" 
    elseif isObjectInACLGroup ( "user.".. acc, aclGetGroup ( "Admin" ) ) then 
        team = "Admins" 
    end 
    if ( team ~= "" ) then 
        if ( not getTeamFromName ( team ) ) then 
            local team = createTeam ( team, 255, 50, 0 ) 
            teams [ team ] = true 
            setPlayerTeam ( source, team ) 
        end 
    end 
end 
addEventHandler ( "onPlayerLogin", root, setTeam ) 
  
function unassignTeam ( ) 
    local team = getPlayerTeam ( source ) 
    if ( team and teams [ team ] ) then 
        setPlayerTeam ( source, nil ) 
        local players = countPlayersInTeam ( team ) 
        if ( players == 0 ) then 
            destroyElement ( team ) 
        end 
    end 
end 
addEventHandler ( "onPlayerLogout", root, unassignTeam ) 

Link to comment
local teams = { } 
  
function createTeamsOnStart ( ) 
    local team = createTeam ( ":O Awesome Players!", 255, 50, 0 ) 
    teams [ team ] = true 
end 
addEventHandler ( "onResourceStart", resourceRoot, createTeamsOnStart ) 
  
function setTeam ( _, account ) 
    local acc = getAccountName ( account ) 
    local team = "" 
    if isObjectInACLGroup ( "user.".. acc, aclGetGroup ( "SuperModerator" ) ) then 
        team = "Moderators" 
    elseif isObjectInACLGroup ( "user.".. acc, aclGetGroup ( "Admin" ) ) then 
        team = "Admins" 
    end 
    if ( team ~= "" ) then 
        if ( not getTeamFromName ( team ) ) then 
            local team = createTeam ( team, 255, 50, 0 ) 
            teams [ team ] = true 
            setPlayerTeam ( source, team ) 
        end 
    end 
end 
addEventHandler ( "onPlayerLogin", root, setTeam ) 
  
function unassignTeam ( ) 
    local team = getPlayerTeam ( source ) 
    if ( team and teams [ team ] ) then 
        setPlayerTeam ( source, nil ) 
        local players = countPlayersInTeam ( team ) 
        if ( players == 0 ) then 
            destroyElement ( team ) 
        end 
    end 
end 
addEventHandler ( "onPlayerLogout", root, unassignTeam ) 

Now it creates the team ":O Awesome Players" but that stays empty and dont get destroyed also. And if I login it creates team "Admins" and move me to there and if i logout it destroys the team so it works but I want it to be in the other team (Fucking awesome players)

EDIT: I saw what you did solidsnake, I think you dont understand what Im trying to do. DNL291 code works good but it doesnt recreate the team.

Edited by Guest
Link to comment
local teamName = ":O Awesome Players!" 
  
function setTeam ( _, account ) 
    local acc = getAccountName ( account ) 
    if ( isObjectInACLGroup ( "user.".. acc, aclGetGroup ( "SuperModerator" ) ) or isObjectInACLGroup ( "user.".. acc, aclGetGroup ( "Admin" ) ) ) then 
        if ( not getTeamFromName ( teamName ) ) then 
            mainTeam = createTeam ( teamName, 255, 50, 0 ) 
            setPlayerTeam ( source, mainTeam ) 
        end 
    end 
end 
addEventHandler ( "onPlayerLogin", root, setTeam ) 
  
function unassignTeam ( ) 
    local team = getPlayerTeam ( source ) 
    if ( team == mainTeam ) then 
        setPlayerTeam ( source, nil ) 
        local players = countPlayersInTeam ( team ) 
        if ( players == 0 ) then 
            destroyElement ( team ) 
        end 
    end 
end 
addEventHandler ( "onPlayerLogout", root, unassignTeam ) 

Link to comment
local teamName = ":O Awesome Players!" 
  
function setTeam ( _, account ) 
    local acc = getAccountName ( account ) 
    if ( isObjectInACLGroup ( "user.".. acc, aclGetGroup ( "SuperModerator" ) ) or isObjectInACLGroup ( "user.".. acc, aclGetGroup ( "Admin" ) ) ) then 
        if ( not getTeamFromName ( teamName ) ) then 
            mainTeam = createTeam ( teamName, 255, 50, 0 ) 
            setPlayerTeam ( source, mainTeam ) 
        end 
    end 
end 
addEventHandler ( "onPlayerLogin", root, setTeam ) 
  
function unassignTeam ( ) 
    local team = getPlayerTeam ( source ) 
    if ( team == mainTeam ) then 
        setPlayerTeam ( source, nil ) 
        local players = countPlayersInTeam ( team ) 
        if ( players == 0 ) then 
            destroyElement ( team ) 
        end 
    end 
end 
addEventHandler ( "onPlayerLogout", root, unassignTeam ) 

Thanks works. But do you know how to make it like blink. Like its orange and then it like goes blue for a second?

Link to comment
local teamName = ":O Awesome Players!" 
  
function setTeam ( _, account ) 
    local acc = getAccountName ( account ) 
    if ( isObjectInACLGroup ( "user.".. acc, aclGetGroup ( "SuperModerator" ) ) or isObjectInACLGroup ( "user.".. acc, aclGetGroup ( "Admin" ) ) ) then 
        if ( not getTeamFromName ( teamName ) ) then 
            mainTeam = createTeam ( teamName, 255, 50, 0 ) 
            setPlayerTeam ( source, mainTeam ) 
        end 
    end 
end 
addEventHandler ( "onPlayerLogin", root, setTeam ) 
  
function unassignTeam ( ) 
    local team = getPlayerTeam ( source ) 
    if ( team == mainTeam ) then 
        setPlayerTeam ( source, nil ) 
        local players = countPlayersInTeam ( team ) 
        if ( players == 0 ) then 
            destroyElement ( team ) 
        end 
    end 
end 
addEventHandler ( "onPlayerLogout", root, unassignTeam ) 

Thanks works. But do you know how to make it like blink. Like its orange and then it like goes blue for a second?

What do you mean?

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