Jump to content

SOLVED!


Sex*

Recommended Posts

function createTeamsOnStart() 
    MainTeam = createTeam("The Professionals", 250, 50, 0)   
end 
addEventHandler("onResourceStart", resourceRoot, createTeamsOnStart) 
  
function setTeam(_, account) 
    local team = getAccountData(account, "team") 
    if (team) then 
        if not getTeamFromName(team) then 
            MainTeam = createTeam(team, 250, 50, 0)   
        end 
        setPlayerTeam(source, MainTeam) 
    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)) 
        remove(source) 
    end 
end 
addEventHandler("onPlayerQuit", root, save) 
  
function unassignTeam() 
    if getPlayerTeam(source) then 
        setPlayerTeam(source, nil) 
        remove(source) 
    end 
end 
addEventHandler("onPlayerLogout", root, unassignTeam) 
  
function remove(source) 
    if (getPlayerTeam(source) == MainTeam) then 
        if (countPlayersInTeam(MainTeam) == 0) then 
            destroyElement(MainTeam) 
        end 
    end 
end 

Link to comment
Doesnt work...

What is not work?

try this

function createTeamsOnStart() 
    MainTeam = createTeam("The Professionals", 250, 50, 0)   
end 
addEventHandler("onResourceStart", resourceRoot, createTeamsOnStart) 
  
function setTeam(_, account) 
    local team = getAccountData(account, "team") 
    if (team) then 
        if not getTeamFromName(team) then 
            MainTeam = createTeam(team, 250, 50, 0)   
        end 
        setPlayerTeam(source, MainTeam) 
    end 
end 
addEventHandler("onPlayerLogin", root, setTeam) 
  
function save() 
    local team = getPlayerTeam(source) 
    local account = getPlayerAccount(source) 
    if (team and MainTeam and team == MainTeam) and not isGuestAccount(account) then 
        setAccountData(account, "team", getTeamName(team)) 
        setPlayerTeam(source, nil) 
        remove(source) 
    end 
end 
addEventHandler("onPlayerQuit", root, save) 
  
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

What is not work?

try this

function createTeamsOnStart() 
    MainTeam = createTeam("The Professionals", 250, 50, 0)   
end 
addEventHandler("onResourceStart", resourceRoot, createTeamsOnStart) 
  
function setTeam(_, account) 
    local team = getAccountData(account, "team") 
    if (team) then 
        if not getTeamFromName(team) then 
            MainTeam = createTeam(team, 250, 50, 0)   
        end 
        setPlayerTeam(source, MainTeam) 
    end 
end 
addEventHandler("onPlayerLogin", root, setTeam) 
  
function save() 
    local team = getPlayerTeam(source) 
    local account = getPlayerAccount(source) 
    if (team and MainTeam and team == MainTeam) and not isGuestAccount(account) then 
        setAccountData(account, "team", getTeamName(team)) 
        setPlayerTeam(source, nil) 
        remove(source) 
    end 
end 
addEventHandler("onPlayerQuit", root, save) 
  
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 

function createTeamsOnStart() 
    MainTeam = createTeam("The Professionals", 250, 50, 0)   
end 
addEventHandler("onResourceStart", resourceRoot, createTeamsOnStart) 
  
function setTeam(_, account) 
    local team = getAccountData(account, "team") 
    if (team) then 
        if not getTeamFromName(team) then 
            MainTeam = createTeam(team, 250, 50, 0)   
        end 
        setPlayerTeam(source, MainTeam) 
    end 
end 
addEventHandler("onPlayerLogin", root, setTeam) 
  
function save() 
    local team = getPlayerTeam(source) 
    local account = getPlayerAccount(source) 
    if (team and MainTeam and team == MainTeam) and not isGuestAccount(account) then 
        setAccountData(account, "team", getTeamName(team)) 
        setPlayerTeam(source, nil) 
        remove() 
    end 
end 
addEventHandler("onPlayerQuit", root, save) 
  
function unassignTeam() 
    local team = getPlayerTeam(source) 
    if (team and MainTeam and team == MainTeam) then 
        setPlayerTeam(source, nil) 
        remove() 
    end 
end 
addEventHandler("onPlayerLogout", root, unassignTeam) 
  
function remove() 
    if MainTeam and (countPlayersInTeam(MainTeam) == 0) then 
        destroyElement(MainTeam) 
    end 
end 

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