Jump to content

Ajuda script de kick


Recommended Posts

  function kikarplayer (theClient, commandName, kickedName, ...) 
        local account = getAccountName (getPlayerAccount (theClient))
     	if isObjectInACLGroup ("user."..account, aclGetGroup ("Admin")) then 
		   if not ... then
                return outputChatBox ("#bf2e2e* Erro: /kick [nick] [motivo]",theClient,255,255,255,true) 
            end 
            local reason = table.concat({...}," ") 
            local kickerName = getPlayerName(theClient):gsub("#%x%x%x%x%x%x","") 
            local kickedPlayer = getPlayerFromName(kickedName) 
            if not isElement(kickedPlayer) then 
                outputChatBox ("#bf2e2e* Erro: Player Invalido!",theClient,255,255,255,true) 
            end 
            outputChatBox ( "#c9c9c9[#1a6cefFW-INFORMA#c9c9c9]O #1a6cef" .. kickerName .. "  #c9c9c9Kickou o Player #1a6cef" ..getPlayerName(kickedPlayer):gsub("#%x%x%x%x%x%x","").. "#c9c9c9 | Motivo #1a6cef" ..reason.. "#c9c9c9", getRootElement(), 255, 0, 0, true )  
            banPlayer ( kickedPlayer, theClient, reason ) 
        else 
            outputChatBox ("#bf2e2e* Erro: Você Não tem Permissão!",theClient,255,255,255,true) 
        end 
    end 
    addCommandHandler ( "kick", kikarplayer )

Erro 

 ERROR: Loading script failed: [FW]Comandos/Server.Lua:4: unexpected symbol near '�'
Link to comment
  • Other Languages Moderators
 function kikarplayer (theClient, commandName, kickedName, ...) 
    local account = getAccountName (getPlayerAccount (theClient))
    if isObjectInACLGroup ("user."..account, aclGetGroup ("Admin")) then
        local r = {...}
		if not r or string.len(r) < 1 then
            return outputChatBox ("#bf2e2e* Erro: /kick [nick] [motivo]",theClient,255,255,255,true) 
        end 
        local reason = table.concat(r," ") 
        local kickerName = getPlayerName(theClient):gsub("#%x%x%x%x%x%x","") 
        local kickedPlayer = getPlayerFromName(kickedName) 
        if not isElement(kickedPlayer) then 
            outputChatBox ("#bf2e2e* Erro: Player Invalido!",theClient,255,255,255,true) 
        end 
        outputChatBox ( "#c9c9c9[#1a6cefFW-INFORMA#c9c9c9]O #1a6cef" .. kickerName .. "  #c9c9c9Kickou o Player #1a6cef" ..getPlayerName(kickedPlayer):gsub("#%x%x%x%x%x%x","").. "#c9c9c9 | Motivo #1a6cef" ..reason.. "#c9c9c9", getRootElement(), 255, 0, 0, true )  
        banPlayer ( kickedPlayer, theClient, reason ) 
    else 
        outputChatBox ("#bf2e2e* Erro: Você Não tem Permissão!",theClient,255,255,255,true) 
    end 
end 
addCommandHandler ( "kick", kikarplayer )

 

Link to comment
5 minutes ago, asrzkj said:

 function kikarplayer (theClient, commandName, kickedName, ...) 
    local account = getAccountName (getPlayerAccount (theClient))
    if isObjectInACLGroup ("user."..account, aclGetGroup ("Admin")) then
        local r = {...}
		if not r or string.len(r) < 1 then
            return outputChatBox ("#bf2e2e* Erro: /kick [nick] [motivo]",theClient,255,255,255,true) 
        end 
        local reason = table.concat(r," ") 
        local kickerName = getPlayerName(theClient):gsub("#%x%x%x%x%x%x","") 
        local kickedPlayer = getPlayerFromName(kickedName) 
        if not isElement(kickedPlayer) then 
            outputChatBox ("#bf2e2e* Erro: Player Invalido!",theClient,255,255,255,true) 
        end 
        outputChatBox ( "#c9c9c9[#1a6cefFW-INFORMA#c9c9c9]O #1a6cef" .. kickerName .. "  #c9c9c9Kickou o Player #1a6cef" ..getPlayerName(kickedPlayer):gsub("#%x%x%x%x%x%x","").. "#c9c9c9 | Motivo #1a6cef" ..reason.. "#c9c9c9", getRootElement(), 255, 0, 0, true )  
        banPlayer ( kickedPlayer, theClient, reason ) 
    else 
        outputChatBox ("#bf2e2e* Erro: Você Não tem Permissão!",theClient,255,255,255,true) 
    end 
end 
addCommandHandler ( "kick", kikarplayer )

 

ERROR: [FW]Comandos/Server.Lua:5: bad argument #1 to 'len' (string expected, got table)
Link to comment

como consigo colocar mais de uma aclgroup no comando ?

9 minutes ago, Eficiencia said:

 function kikarplayer (theClient, commandName, kickedName, ...) 
    local account = getAccountName (getPlayerAccount (theClient))
    if isObjectInACLGroup ("user."..account, aclGetGroup ("Admin")) then
        local r = {...}
		if not r or not kickedName then
            return outputChatBox ("#bf2e2e* Erro: /kick [nick] [motivo]",theClient,255,255,255,true) 
        end 
        local reason = table.concat(r," ") 
        local kickerName = getPlayerName(theClient):gsub("#%x%x%x%x%x%x","") 
        local kickedPlayer = getPlayerFromName(kickedName) 
        outputChatBox ( "#c9c9c9[#1a6cefFW-INFORMA#c9c9c9]O #1a6cef" .. kickerName .. "  #c9c9c9Kickou o Player #1a6cef" ..getPlayerName(kickedPlayer):gsub("#%x%x%x%x%x%x","").. "#c9c9c9 | Motivo #1a6cef" ..reason.. "#c9c9c9", getRootElement(), 255, 0, 0, true )  
        banPlayer ( kickedPlayer, theClient, reason ) 
    else 
        outputChatBox ("#bf2e2e* Erro: Você Não tem Permissão!",theClient,255,255,255,true) 
    end 
end 
addCommandHandler ( "kick", kikarplayer )

tente assim

 

Link to comment

esquece essa parte viajei legal

7 minutes ago, giovanymito said:

como consigo colocar mais de uma aclgroup no comando ?

 

 

adicione isso:

function getPlayerFromPartialName(name)
    local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil
    if name then
        for _, player in ipairs(getElementsByType("player")) do
            local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower()
            if name_:find(name, 1, true) then
                return player
            end
        end
    end
end

 

 function kikarplayer (theClient, commandName, kickedName, ...) 
    local account = getAccountName (getPlayerAccount (theClient))
    if isObjectInACLGroup ("user."..account, aclGetGroup ("Admin")) then
        local r = {...}
		if not r or string.len(r) < 1 then
            return outputChatBox ("#bf2e2e* Erro: /kick [nick] [motivo]",theClient,255,255,255,true) 
        end 
        local reason = table.concat(r," ") 
        local kickerName = getPlayerName(theClient):gsub("#%x%x%x%x%x%x","") 
        local kickedPlayer = getPlayerFromPartialName(kickedName) 
        if not isElement(kickedPlayer) then 
            outputChatBox ("#bf2e2e* Erro: Player Invalido!",theClient,255,255,255,true) 
        end 
        outputChatBox ( "#c9c9c9[#1a6cefFW-INFORMA#c9c9c9]O #1a6cef" .. kickerName .. "  #c9c9c9Kickou o Player #1a6cef" ..getPlayerName(kickedPlayer):gsub("#%x%x%x%x%x%x","").. "#c9c9c9 | Motivo #1a6cef" ..reason.. "#c9c9c9", getRootElement(), 255, 0, 0, true )  
        banPlayer ( kickedPlayer, theClient, reason ) 
    else 
        outputChatBox ("#bf2e2e* Erro: Você Não tem Permissão!",theClient,255,255,255,true) 
    end 
end 
addCommandHandler ( "kick", kikarplayer )

dai deixe o codigo assim e teste.

pois com getPlayerFromName vc deve escrever o nome do player inteiro e de forma correta (se n me engano)

e ja com getPlayerFromPartialName vc pode abreviar o nome.

Edited by Eficiencia
Link to comment

ok

é que primeiro fui tentar ajudar a resolver o problema no script vou botar aqi no server local e testar

 

script arrumado (obs: parte da ACL tive ajuda do DNL)

function isPlayerInACL(player, acl)
   local accountName = getAccountName( getPlayerAccount(player) )
   if accountName ~= "guest" and type( aclGetGroup(acl) ) == "userdata" then
      return isObjectInACLGroup( "user."..accountName, aclGetGroup(acl) )
   end
   return false
end

function kikarplayer ( source, commandName, kickedName, ... ) 
    if isPlayerInACL(source, "Admin") or isPlayerInACL(source, "SuperModerator") or isPlayerInACL(source, "Console") then
        local r = {...}
		if not r or not commandName or not kickedName then
            return outputChatBox ("#bf2e2e* Erro: /kick [nick] [motivo]", source, 255, 255, 255, true) 
        end 
        local reason = table.concat(r," ") 
        local kickerName = getPlayerName(source):gsub("#%x%x%x%x%x%x","") 
        local kickedPlayer = getPlayerFromPartialName(kickedName) 
        if not isElement(kickedPlayer) then 
            outputChatBox ("#bf2e2e* Erro: Player Invalido!", source, 255, 255, 255, true) 
        end 
        outputChatBox ( "#c9c9c9[#1a6cefFW-INFORMA#c9c9c9]O #1a6cef"..kickerName.."  #c9c9c9Kickou o Player #1a6cef" ..getPlayerName(kickedPlayer):gsub("#%x%x%x%x%x%x","").. "#c9c9c9 | Motivo #1a6cef" ..reason.. "#c9c9c9", getRootElement(), 255, 0, 0, true )  
        banPlayer ( kickedPlayer, source, reason ) 
    else 
        outputChatBox ("#bf2e2e* Erro: Você Não tem Permissão!", source, 255, 255, 255, true) 
    end
end
addCommandHandler("kick", kikarplayer)

 

Link to comment

Eu faria sem obrigar o staff de colocar o motivo. De qualquer forma, Tente:


function kikarplayer ( source, commandName, kickedName, ... ) 
    if isPlayerInACL(source, "Admin") or isPlayerInACL(source, "SuperModerator") or isPlayerInACL(source, "Console") then
        local r = {...}
		if not kickedName or not r or #r == 0 then
            return outputChatBox ("#bf2e2e* Erro: /kick [nick] [motivo]", source, 255, 255, 255, true) 
        end 
        local reason = table.concat(r," ") 
        local kickerName = getPlayerName(source):gsub("#%x%x%x%x%x%x","") 
        local kickedPlayer = getPlayerFromPartialName(kickedName) 
        if not isElement(kickedPlayer) then 
            outputChatBox ("#bf2e2e* Erro: Player Invalido!", source, 255, 255, 255, true) 
        end 
        outputChatBox ( "#c9c9c9[#1a6cefFW-INFORMA#c9c9c9]O #1a6cef"..kickerName.."  #c9c9c9Kickou o Player #1a6cef" ..getPlayerName(kickedPlayer):gsub("#%x%x%x%x%x%x","").. "#c9c9c9 | Motivo #1a6cef" ..reason.. "#c9c9c9", getRootElement(), 255, 0, 0, true )  
        banPlayer ( kickedPlayer, source, reason ) 
    else 
        outputChatBox ("#bf2e2e* Erro: Você Não tem Permissão!", source, 255, 255, 255, true) 
    end
end
addCommandHandler("kick", kikarplayer)

function isPlayerInACL(player, acl)
   local accountName = getAccountName( getPlayerAccount(player) )
   if accountName ~= "guest" and type( aclGetGroup(acl) ) == "userdata" then
      return isObjectInACLGroup( "user."..accountName, aclGetGroup(acl) )
   end
   return false
end

function getPlayerFromPartialName(name)
    local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil
    if name then
        for _, player in ipairs(getElementsByType("player")) do
            local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower()
            if name_:find(name, 1, true) then
                return player
            end
        end
    end
end

EDIT: deve ser a função kickPlayer; banPlayer vai banir o jogador.

Link to comment
On 18/07/2019 at 18:10, DNL291 said:

Eu faria sem obrigar o staff de colocar o motivo. De qualquer forma, Tente:


function kikarplayer ( source, commandName, kickedName, ... ) 
    if isPlayerInACL(source, "Admin") or isPlayerInACL(source, "SuperModerator") or isPlayerInACL(source, "Console") then
        local r = {...}
		if not kickedName or not r or #r == 0 then
            return outputChatBox ("#bf2e2e* Erro: /kick [nick] [motivo]", source, 255, 255, 255, true) 
        end 
        local reason = table.concat(r," ") 
        local kickerName = getPlayerName(source):gsub("#%x%x%x%x%x%x","") 
        local kickedPlayer = getPlayerFromPartialName(kickedName) 
        if not isElement(kickedPlayer) then 
            outputChatBox ("#bf2e2e* Erro: Player Invalido!", source, 255, 255, 255, true) 
        end 
        outputChatBox ( "#c9c9c9[#1a6cefFW-INFORMA#c9c9c9]O #1a6cef"..kickerName.."  #c9c9c9Kickou o Player #1a6cef" ..getPlayerName(kickedPlayer):gsub("#%x%x%x%x%x%x","").. "#c9c9c9 | Motivo #1a6cef" ..reason.. "#c9c9c9", getRootElement(), 255, 0, 0, true )  
        banPlayer ( kickedPlayer, source, reason ) 
    else 
        outputChatBox ("#bf2e2e* Erro: Você Não tem Permissão!", source, 255, 255, 255, true) 
    end
end
addCommandHandler("kick", kikarplayer)

function isPlayerInACL(player, acl)
   local accountName = getAccountName( getPlayerAccount(player) )
   if accountName ~= "guest" and type( aclGetGroup(acl) ) == "userdata" then
      return isObjectInACLGroup( "user."..accountName, aclGetGroup(acl) )
   end
   return false
end

function getPlayerFromPartialName(name)
    local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil
    if name then
        for _, player in ipairs(getElementsByType("player")) do
            local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower()
            if name_:find(name, 1, true) then
                return player
            end
        end
    end
end

EDIT: deve ser a função kickPlayer; banPlayer vai banir o jogador.

Não esta aparecendo a mensagem no chat falando que foi kickado, e ta kikando sem precisar de motivo

EDIT : Aparece a Mensagem   Erro: /kick [nick] [motivo], MAIS o player é kickado mesmo assim

Edited by giovanymito
Link to comment

kick é um comando do resource admin, vai executar ele quando usar o comando.

Mude para outro nome ou remova o kick do admin. Tente isto:

function kikarplayer ( source, commandName, kickedName, ... ) 
    if isPlayerInACL(source, "Admin") or isPlayerInACL(source, "SuperModerator") or isPlayerInACL(source, "Console") then
        local r = {...}
        
        if not kickedName or #r == 0 then
            return outputChatBox ("#bf2e2e* Erro: /kick [nick] [motivo]", source, 255, 255, 255, true) 
        end
        local kickerName = getPlayerName(source):gsub("#%x%x%x%x%x%x","") 
        local kickedPlayer = getPlayerFromPartialName(kickedName)
        if not isElement(kickedPlayer) then 
            return outputChatBox ("#bf2e2e* Erro: Player Invalido!", source, 255, 255, 255, true) 
        end
        local reason = table.concat(r," ") 

        outputChatBox ( "#c9c9c9[#1a6cefFW-INFORMA#c9c9c9]O #1a6cef"..kickerName.."  #c9c9c9Kickou o Player #1a6cef" ..getPlayerName(kickedPlayer):gsub("#%x%x%x%x%x%x","").. "#c9c9c9 | Motivo #1a6cef" ..reason.. "#c9c9c9", getRootElement(), 255, 0, 0, true )  
        kickPlayer ( kickedPlayer, source, reason ) 
    else 
        outputChatBox ("#bf2e2e* Erro: Você Não tem Permissão!", source, 255, 255, 255, true) 
    end
end
addCommandHandler("kickar", kikarplayer)

function isPlayerInACL(player, acl)
   local accountName = getAccountName( getPlayerAccount(player) )
   if accountName ~= "guest" and type( aclGetGroup(acl) ) == "userdata" then
      return isObjectInACLGroup( "user."..accountName, aclGetGroup(acl) )
   end
   return false
end

function getPlayerFromPartialName(name)
    local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil
    if name then
        for _, player in ipairs(getElementsByType("player")) do
            local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower()
            if name_:find(name, 1, true) then
                return player
            end
        end
    end
end

 

  • Thanks 1
Link to comment
2 hours ago, DNL291 said:

kick é um comando do resource admin, vai executar ele quando usar o comando.

Mude para outro nome ou remova o kick do admin. Tente isto:


function kikarplayer ( source, commandName, kickedName, ... ) 
    if isPlayerInACL(source, "Admin") or isPlayerInACL(source, "SuperModerator") or isPlayerInACL(source, "Console") then
        local r = {...}
        
        if not kickedName or #r == 0 then
            return outputChatBox ("#bf2e2e* Erro: /kick [nick] [motivo]", source, 255, 255, 255, true) 
        end
        local kickerName = getPlayerName(source):gsub("#%x%x%x%x%x%x","") 
        local kickedPlayer = getPlayerFromPartialName(kickedName)
        if not isElement(kickedPlayer) then 
            return outputChatBox ("#bf2e2e* Erro: Player Invalido!", source, 255, 255, 255, true) 
        end
        local reason = table.concat(r," ") 

        outputChatBox ( "#c9c9c9[#1a6cefFW-INFORMA#c9c9c9]O #1a6cef"..kickerName.."  #c9c9c9Kickou o Player #1a6cef" ..getPlayerName(kickedPlayer):gsub("#%x%x%x%x%x%x","").. "#c9c9c9 | Motivo #1a6cef" ..reason.. "#c9c9c9", getRootElement(), 255, 0, 0, true )  
        kickPlayer ( kickedPlayer, source, reason ) 
    else 
        outputChatBox ("#bf2e2e* Erro: Você Não tem Permissão!", source, 255, 255, 255, true) 
    end
end
addCommandHandler("kickar", kikarplayer)

function isPlayerInACL(player, acl)
   local accountName = getAccountName( getPlayerAccount(player) )
   if accountName ~= "guest" and type( aclGetGroup(acl) ) == "userdata" then
      return isObjectInACLGroup( "user."..accountName, aclGetGroup(acl) )
   end
   return false
end

function getPlayerFromPartialName(name)
    local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil
    if name then
        for _, player in ipairs(getElementsByType("player")) do
            local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower()
            if name_:find(name, 1, true) then
                return player
            end
        end
    end
end

 

Ainda esta mesma coisa.

Quando eu usava o banplayer, ele kickava e não bania, e o Erro: /kick [nick] [motivo]  aparecia sem kickar o player, é um misterio  kkkkkkk

Link to comment
On 27/07/2019 at 10:50, DNL291 said:

Você só pode estar usando o comando kick como eu falei, por isso tá sempre kickando mesmo com a função banPlayer.

Teste o meu código e use /kickar que vai funcionar.

Agora que fui perceber oque você disse, desculpa, então eu tirando o kick do admin, funcionaria correta mente o meu comando igual vc me Passou :D Obrigado 

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