Jump to content

ADMINISTRATOR CHAT


Recommended Posts

Oi, estou com um pequeno problema no meu chat admin, ele manda mensagem , mas só os admins conseguem ver, codigo no lado server

 

function adminjonnas ( thePlayer, _, ... )
    local message = table.concat ( { ... }, " " )
    if ( isPlayerOnGroup ( thePlayer ) ) then
        for _, player in ipairs ( getElementsByType ( "player" ) ) do
            if ( isPlayerOnGroup ( player ) ) then
                outputChatBox ( "#FF0000[ADM] #FFFFFF".. getPlayerName ( thePlayer ) .." : #FF0000".. message, player, 255, 255, 255, true )
            end
        end
    else
        outputChatBox ( "#FF0000[ERRO] - #FFFFFFVocê não é um administrador !", thePlayer, 255, 255, 255, true )
    end
end
addCommandHandler("ChatADM", adminjonnas)
-- addCommandHandler ( "ac", adminchat ) -- PARA COLOCAR POR COMANDO DE NOVO COLOQUE adminchat no lugar de adminjonnas
 
function isPlayerOnGroup ( thePlayer )
    local account = getPlayerAccount ( thePlayer )
    local inGroup = false
    for _, group in ipairs ( { "Console", "Admin", "SuperModerator", "Moderator" } ) do  
        if isObjectInACLGroup ( "user.".. getAccountName ( account ), aclGetGroup ( group ) )   then
            inGroup = true
            break
        end
    end
 
    return inGroup
end

Codigo no lado client 

bindKey("i", "down", "chatbox", "ChatADM")

Queria uma ajuda para colocar para todos verem se alguém poder me ajudar obg !

Link to comment

Vlw funcionou !

2 hours ago, DNL291 said:

Remova a linha:


if ( isPlayerOnGroup ( player ) ) then

Essa função verifica se o jogador é um Staff.

Só mais uma coisinha eu tentei adicionar essa função em baixo do output

outputServerLog("ADMCHAT: " .. name .. " : " .. text)

Para mostrar no console do servidor e nas logs, só que deu erro, tem algo errado sera?

 

Link to comment
10 hours ago, DNL291 said:

Qual erro deu? Porque o código está correto. Pode ser que você tenha usado no lado client, nesse caso, você receberia um erro: Atempt to call global...

Lado server

 

function adminjonnas ( thePlayer, _, ... )
    local message = table.concat ( { ... }, " " )
    if ( isPlayerOnGroup ( thePlayer ) ) then
        for _, player in ipairs ( getElementsByType ( "player" ) ) do
            outputChatBox ( "#FF0000[ADM] #FFFFFF".. getPlayerName ( thePlayer ) .." : #FF0000".. message, player, 255, 255, 255, true )
			outputServerLog("ADMCHAT: " .. name .. " : " .. text)
        end
    else
        outputChatBox ( "#FF0000[ERRO] - #FFFFFFVocê não é um administrador !", thePlayer, 255, 255, 255, true )
    end
end
addCommandHandler("adminchat", adminjonnas)

ERRO: attempt to concatenate global text < a nill value >

Link to comment
2 minutes ago, Lord Henry said:

A variável text não existe.

Verdade, obrigado é message xD 

5 minutes ago, Lord Henry said:

A variável text não existe.

Use message em vez disso.

Mas eu não entendi por que da erro no name

outputServerLog("ADMCHAT: " .. name .. " : " .. message) 

Mesmo erro ! já tentei por player mas mesmo assim continua

Link to comment
17 hours ago, DNL291 said:

Qual erro deu? Porque o código está correto. Pode ser que você tenha usado no lado client, nesse caso, você receberia um erro: Atempt to call global...

Mas eu não entendi por que da erro no name

outputServerLog("ADMCHAT: " .. name .. " : " .. message) 

Mesmo erro ! já tentei por player mas mesmo assim continua

Link to comment
1 hour ago, DNL291 said:

Você não vai conseguir usar um elemento aonde deve ser string.


outputServerLog("ADMCHAT: " .. getPlayerName(thePlayer) .. " : " .. message)

 

Estava testando e esta dando um pequeno problema, 

 

[2018-05-28 19:19:02] ADMCHAT: wLoocKyzeraaa^OnE : pai joga mt
[2018-05-28 19:19:02] ADMCHAT: wLoocKyzeraaa^OnE : pai joga mt
[2018-05-28 19:19:02] ADMCHAT: wLoocKyzeraaa^OnE : pai joga mt
[2018-05-28 19:19:02] ADMCHAT: wLoocKyzeraaa^OnE : pai joga mt
[2018-05-28 19:19:02] ADMCHAT: wLoocKyzeraaa^OnE : pai joga mt

 Esta repetindo no console 

Como esta o código atualmente :

 

function chatadminbyjonas ( thePlayer, _, ... )
    local message = table.concat ( { ... }, " " )
    if ( isPlayerOnGroup ( thePlayer ) ) then
        for _, player in ipairs ( getElementsByType ( "player" ) ) do
            outputChatBox ( "#FF0000[ADM] #FFFFFF".. getPlayerName ( thePlayer ) .." : #FF0000".. message, player, 255, 255, 255, true )
			outputServerLog("ADMCHAT: " .. getPlayerName(thePlayer) .. " : " .. message) -- ENVIA LOG'S PARA O CONSOLE E NOS ARQUIVOS DE TEXTO !
        end
    else
        outputChatBox ( "#FF0000[ERRO] - #FFFFFFVocê não é um administrador !", thePlayer, 255, 255, 255, true )
    end
end
addCommandHandler("adminchat", chatadminbyjonas)

Tem algo errado, eu particularmente não achei !

Link to comment
  • Moderators

A função tá dentro do loop

function chatadminbyjonas ( thePlayer, _, ... )
    local message = table.concat ( { ... }, " " )
    if ( isPlayerOnGroup ( thePlayer ) ) then
        for _, player in ipairs ( getElementsByType ( "player" ) ) do
            outputChatBox ( "#FF0000[ADM] #FFFFFF".. getPlayerName ( thePlayer ) .." : #FF0000".. message, player, 255, 255, 255, true )
        end
        outputServerLog("ADMCHAT: " .. getPlayerName(thePlayer) .. " : " .. message) -- ENVIA LOG'S PARA O CONSOLE E NOS ARQUIVOS DE TEXTO !
    else
        outputChatBox ( "#FF0000[ERRO] - #FFFFFFVocê não é um administrador !", thePlayer, 255, 255, 255, true )
    end
end
addCommandHandler("adminchat", chatadminbyjonas)

 

  • Like 1
Link to comment
2 minutes ago, DNL291 said:

A função tá dentro do loop


function chatadminbyjonas ( thePlayer, _, ... )
    local message = table.concat ( { ... }, " " )
    if ( isPlayerOnGroup ( thePlayer ) ) then
        for _, player in ipairs ( getElementsByType ( "player" ) ) do
            outputChatBox ( "#FF0000[ADM] #FFFFFF".. getPlayerName ( thePlayer ) .." : #FF0000".. message, player, 255, 255, 255, true )
        end
        outputServerLog("ADMCHAT: " .. getPlayerName(thePlayer) .. " : " .. message) -- ENVIA LOG'S PARA O CONSOLE E NOS ARQUIVOS DE TEXTO !
    else
        outputChatBox ( "#FF0000[ERRO] - #FFFFFFVocê não é um administrador !", thePlayer, 255, 255, 255, true )
    end
end
addCommandHandler("adminchat", chatadminbyjonas)

 

Obrigado amigo !

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