Jump to content

Simple ban command


Recommended Posts

Hello! I've try to make a /ban command but it doesnt work. Here's my command:

function banPlayerCommand ( theClient, commandName, bannedName, ... ) 
    if hasObjectPermissionTo ( theClient, "function.kickPlayer" ) then 
        if not ... then 
            return outputChatBox ("#bf2e2e* Error: /aban [name] [reason]",theClient,255,255,255,true) 
        end 
        local reason = table.concat({...}," ") 
        local bannerName = getPlayerName(theClient):gsub("#%x%x%x%x%x%x","") 
        local bannedPlayer = getPlayerFromName(bannedName) 
        if not isElement(bannedPlayer) then 
            outputChatBox ("#bf2e2e* Error: Invalid player name!",theClient,255,255,255,true) 
        end 
        outputChatBox ( "#ff6666* #ff1111" ..getPlayerName(bannedPlayer):gsub("#%x%x%x%x%x%x","").. " #ff6666has been banned by " .. bannerName .. " (" ..reason.. ")", getRootElement(), 255, 0, 0, true )  
        banPlayer ( bannedPlayer, theClient, reason ) 
    else 
        outputChatBox ("#bf2e2e* Error: You are not admin!",theClient,255,255,255,true) 
    end 
end 
addCommandHandler ( "aban", banPlayerCommand ) 

But it doesnt work, it displays "errors" in chat box like "You are not an admin" but when I do like "/aban inferno test" it always says "Invalid player name", and not my ban announce and the ban. Does someone know what did I make wrong please?

PS: I also want to rename the /aban command in /ban command but I don't know how to remove the original /ban command.

Thanks for helping :)

Link to comment
Hello! I've try to make a /ban command but it doesnt work. Here's my command:
function banPlayerCommand ( theClient, commandName, bannedName, ... ) 
    if hasObjectPermissionTo ( theClient, "function.kickPlayer" ) then 
        if not ... then 
            return outputChatBox ("#bf2e2e* Error: /aban [name] [reason]",theClient,255,255,255,true) 
        end 
        local reason = table.concat({...}," ") 
        local bannerName = getPlayerName(theClient):gsub("#%x%x%x%x%x%x","") 
        local bannedPlayer = getPlayerFromName(bannedName) 
        if not isElement(bannedPlayer) then 
            outputChatBox ("#bf2e2e* Error: Invalid player name!",theClient,255,255,255,true) 
        end 
        outputChatBox ( "#ff6666* #ff1111" ..getPlayerName(bannedPlayer):gsub("#%x%x%x%x%x%x","").. " #ff6666has been banned by " .. bannerName .. " (" ..reason.. ")", getRootElement(), 255, 0, 0, true )  
        banPlayer ( bannedPlayer, theClient, reason ) 
    else 
        outputChatBox ("#bf2e2e* Error: You are not admin!",theClient,255,255,255,true) 
    end 
end 
addCommandHandler ( "aban", banPlayerCommand ) 

But it doesnt work, it displays "errors" in chat box like "You are not an admin" but when I do like "/aban inferno test" it always says "Invalid player name", and not my ban announce and the ban. Does someone know what did I make wrong please?

PS: I also want to rename the /aban command in /ban command but I don't know how to remove the original /ban command.

Thanks for helping :)

Mate i think this is stole because you dont even know how to change the command from /aban to /ban

Link to comment

It's not stolen, it's server side, I just modified the command from here http://wiki.multitheftauto.com/wiki/BanPlayer and Callum helped me a little on the IRC chat but it's still not working.

And I know how to change the command, I just don't know how to remove the original /ban command from MTA. I thought I needed to set the command.ban in ACL to false but it doesnt work.

Please help I really tried, it's not like if i didn't do anything or steal the code.

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