Recommended Posts

Só vc criar as Teams no script e adicionar uma função que coloca os players no Team correto quando eles logam no servidor dependendo da ACL Group que eles estiverem.

Para evitar o bug, vc pode fazer uma verificação ao iniciar o resource, para que ele coloque os players que já estão logados nos times corretos. Dai vc precisa obter todos os players online, verificar quais deles estão logados e verificar se eles estão na ACL Group correta.

  • onResourceStart (executa o evento quando um resource é iniciado)
  • getElementsByType (obtém todos os elementos do servidor daquele tipo, neste caso use o tipo "player" e ele vai obter todos os jogadores online)
  • isGuestAccount (verifica se uma conta é Guest ou não, usa-se isso para verificar se um player está logado ou não.)

Outra coisa que vc deve fazer, é tirar os jogadores do Team se eles deslogarem (sem sair do servidor). Dai basta setar Team nulo neles quando eles fizerem logout.

  • onPlayerLogout (executa o evento quando alguém faz logout)
  • setPlayerTeam (coloca alguém em determinado Team, neste caso coloque nil, no parâmetro do Team para remover o jogador de um Team.)
Edited by Lord Henry
  • Thanks 1

Share this post


Link to post

function createAdminTeamOnStart ()
    AdminTeam = createTeam ( "[BOPE]Batalhão De Operações Especiais", 0, 0, 0 )-- create a new team and name it 'Admin'
end
addEventHandler("onResourceStart", resourceRoot, createAdminTeamOnStart) -- add an event handler

function setAdminTeam()
if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("BOPE")) then -- if he is admin
   setPlayerTeam(source, AdminTeam) -- set him to admin team
   end
end
addEventHandler("onPlayerLogin",getRootElement(),setAdminTeam) -- add an event handler
addEventHandler("onResourceStart", getRootElement(), setAdminTeam) -- add an event handler

---2
function createAdminTeamOnStart ()
    AdminTeam = createTeam ( "[ROTA]Ronda Ostensiva Tobias De Aguiar", 169, 169, 169 )-- create a new team and name it 'Admin'
end
addEventHandler("onResourceStart", resourceRoot, createAdminTeamOnStart) -- add an event handler

function setAdminTeam()
if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("ROTA")) then -- if he is admin
   setPlayerTeam(source, AdminTeam) -- set him to admin team
   end
end
addEventHandler("onPlayerLogin",getRootElement(),setAdminTeam) -- add an event handler
addEventHandler("onResourceStart", getRootElement(), setAdminTeam) -- add an event handler

--- 3
function createAdminTeamOnStart ()
    AdminTeam = createTeam ( "[PMERJ]Policia Militar Rio de Janeiro", 0, 187, 255 )-- create a new team and name it 'Admin'
end
addEventHandler("onResourceStart", resourceRoot, createAdminTeamOnStart) -- add an event handler

function setAdminTeam()
if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("PMERJ")) then -- if he is admin
   setPlayerTeam(source, AdminTeam) -- set him to admin team
   end
end
addEventHandler("onPlayerLogin",getRootElement(),setAdminTeam) -- add an event handler
addEventHandler("onResourceStart", getRootElement(), setAdminTeam) -- add an event handler

---4
function createAdminTeamOnStart ()
    AdminTeam = createTeam ( "[FT]Força Tatica", 255, 0, 0 )-- create a new team and name it 'Admin'
end
addEventHandler("onResourceStart", resourceRoot, createAdminTeamOnStart) -- add an event handler

function setAdminTeam()
if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("FT")) then -- if he is admin
   setPlayerTeam(source, AdminTeam) -- set him to admin team
   end
end
addEventHandler("onPlayerLogin",getRootElement(),setAdminTeam) -- add an event handler
addEventHandler("onResourceStart", getRootElement(), setAdminTeam) -- add an event handler
 

 

ai, eu fiz assim ne add a função

addEventHandler("onResourceStart", getRootElement(), setAdminTeam) -- add an event handler

Mais ta bugando, todos dessa mesma team só cai na time ft

Edited by danilin

Share this post


Link to post

Já lhe avisamos mais de 3 vezes que vc precisa usar o botão <> quando for postar código. Se colar direto como texto, não consigo interpretar o código.

Não posso lhe ajudar enquanto não postar da maneira legível o código.

https://prntscr.com/itiqv9

Edited by Lord Henry
  • Thanks 1

Share this post


Link to post
function createAdminTeamOnStart ()
    AdminTeam = createTeam ( "[BOPE]Batalhão De Operações Especiais", 0, 0, 0 )-- create a new team and name it 'Admin'
end
addEventHandler("onResourceStart", resourceRoot, createAdminTeamOnStart) -- add an event handler

function setAdminTeam()
if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("BOPE")) then -- if he is admin
   setPlayerTeam(source, AdminTeam) -- set him to admin team
   end
end
addEventHandler("onPlayerLogin",getRootElement(),setAdminTeam) -- add an event handler
addEventHandler("onResourceStart", getRootElement(), setAdminTeam) -- add an event handler

---2
function createAdminTeamOnStart ()
    AdminTeam = createTeam ( "[ROTA]Ronda Ostensiva Tobias De Aguiar", 169, 169, 169 )-- create a new team and name it 'Admin'
end
addEventHandler("onResourceStart", resourceRoot, createAdminTeamOnStart) -- add an event handler

function setAdminTeam()
if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("ROTA")) then -- if he is admin
   setPlayerTeam(source, AdminTeam) -- set him to admin team
   end
end
addEventHandler("onPlayerLogin",getRootElement(),setAdminTeam) -- add an event handler
addEventHandler("onResourceStart", getRootElement(), setAdminTeam) -- add an event handler

--- 3
function createAdminTeamOnStart ()
    AdminTeam = createTeam ( "[PMERJ]Policia Militar Rio de Janeiro", 0, 187, 255 )-- create a new team and name it 'Admin'
end
addEventHandler("onResourceStart", resourceRoot, createAdminTeamOnStart) -- add an event handler

function setAdminTeam()
if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("PMERJ")) then -- if he is admin
   setPlayerTeam(source, AdminTeam) -- set him to admin team
   end
end
addEventHandler("onPlayerLogin",getRootElement(),setAdminTeam) -- add an event handler
addEventHandler("onResourceStart", getRootElement(), setAdminTeam) -- add an event handler

---4
function createAdminTeamOnStart ()
    AdminTeam = createTeam ( "[FT]Força Tatica", 255, 0, 0 )-- create a new team and name it 'Admin'
end
addEventHandler("onResourceStart", resourceRoot, createAdminTeamOnStart) -- add an event handler

function setAdminTeam()
if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("FT")) then -- if he is admin
   setPlayerTeam(source, AdminTeam) -- set him to admin team
   end
end
addEventHandler("onPlayerLogin",getRootElement(),setAdminTeam) -- add an event handler
addEventHandler("onResourceStart", getRootElement(), setAdminTeam) -- add an event handler

 

Share this post


Link to post

Vc criou várias funções com o mesmo nome, isso não pode.

No evento onResourceStart, vc não deve usar getRootElement() como elemento ativador, pois irá executar quando qualquer resource for iniciado, não só este.

Na Wiki ele diz qual o elemento ativador usar para que só ative ao iniciar este resource. Só saber ler o início da página.

  • Thanks 1

Share this post


Link to post
---BOPE 

local  bope = createTeam ("[BOPE]Batalhão De Operações Especiais", 0, 0, 0 )
setTeamFriendlyFire ( bope, false )



function conecta ()
    local conta = getAccountName(getPlayerAccount(source))
    if isObjectInACLGroup("user." .. conta, aclGetGroup("BOPE")) then

                                setPlayerTeam ( source, bope )
    end
end
addEventHandler( 'onPlayerLogin', root, conecta ) 



---- ROTA
local  rota = createTeam("[ROTA]Ronda Ostensiva Tobias De Aguiar", 169, 169, 169 ) 
setTeamFriendlyFire ( rota, false )


function conecta ()
    local conta = getAccountName(getPlayerAccount(source))
    if isObjectInACLGroup("user." .. conta, aclGetGroup("ROTA")) then

                                setPlayerTeam ( source, rota )
    end
end
addEventHandler( 'onPlayerLogin', root, conecta ) 




---- mais uma vez obrigado.

 

Share this post


Link to post

Em vez de usar duas funções com o mesmo nome, vc deveria colocar as duas condições na mesma função.

function conecta ()
    local conta = getAccountName(getPlayerAccount(source))
    if isObjectInACLGroup ("user." .. conta, aclGetGroup("BOPE")) then
        setPlayerTeam (source, bope)
    elseif isObjectInACLGroup ("user." .. conta, aclGetGroup("ROTA")) then
        setPlayerTeam (source, rota)
    end
end
addEventHandler ("onPlayerLogin", root, conecta)

E também faltou a função que tira o jogador do team quando ele desloga.

function conecta ()
    setPlayerTeam (source, nil)
end
addEventHandler ("onPlayerLogout", root, desconecta)

 

Share this post


Link to post

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.