Jump to content

Re-bind "say" command?


GTX

Recommended Posts

Hello, I'd like to rebind the 't' key (/say), but I am having some problems. Here's how far I came:

  
  
roomName = "Room" 
  
addEventHandler("onPlayerJoin", root, 
    function() 
        bindKey(source,"t","down","chatbox",roomName) 
    end 
) 
  
addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), 
    function() 
        for index, player in pairs(getElementsByType"player") do 
            bindKey(player,"t","down","chatbox",roomName) 
        end 
    end 
) 
  
function onRoomChat(player,_,...) 
    local msg = table.concat({...}, " ") 
    local nick=getPlayerName(player) 
    local r,g,b = 255, 255, 255 
    local team = getPlayerTeam(player) 
    if team then 
        r,g,b = getTeamColor(team) 
    end 
    if string.sub(msg, 1, 1) == "/" then 
        executeCommandHandler(string.sub(msg, 2, string.len(msg)), player, msg) 
        return 
    end 
    for _,v in ipairs(getElementsByType("player")) do 
        if getElementData(v, "roomID") == getElementData(player, "roomID") then 
            outputChatBox("#ffffff"..RGBToHex(r, g, b)..nick..": #ffffff"..msg,v,r,g,b,true) 
        end 
    end 
end 
addCommandHandler(roomName,onRoomChat) 

Okay. My problem is: When I'm trying to execute a command (like saying /logout in chatbox) it just doesn't. But it works perfectly on non-hardcored commands.

Any idea? Thanks in advance.

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