Jump to content

Rebinded "t" and can't use command


dugasz1

Recommended Posts

Posted (edited)

Hello!

I found a new local chat script. It's working just when a write a command (example.: /reconnect) It's writing out in the cahtbox /reconenct. I searching on the internet and now the script know what is command what it's simple message,but i don't know what can i do whit the command how i can use.

chat_range=5 
  
function bindOnJoin() 
    bindKey(source,"t","down","chatbox","Mondod") 
end 
addEventHandler("onPlayerJoin",getRootElement(),bindOnJoin) 
  
function bindRStart() 
    for index, player in pairs(getElementsByType("player")) do 
        bindKey(player,"t","down","chatbox","Mondod") 
    end 
end 
addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), bindRStart) 
  
function isPlayerInRangeOfPoint(player,x,y,z,range) 
    local px,py,pz=getElementPosition(player) 
    return ((x-px)^2+(y-py)^2+(z-pz)^2)^0.5<=range 
end 
  
function onChat(player,_,...) 
    local px,py,pz=getElementPosition(player) 
    local msg = table.concat({...}, " ") 
    local nick=getPlayerName(player) 
        if string.sub(msg, 1, 1) == "/" then 
            --What should here write? 
        else 
            for _,v in ipairs(getElementsByType("player")) do 
                if isPlayerInRangeOfPoint(v,px,py,pz,chat_range) then 
                outputChatBox(nick.." mondja: "..msg,v,255,255,255,true) 
                end 
            end 
        end 
end 
addCommandHandler("Mondod",onChat) 
  
  
  
  

Edited by Guest
Posted

Sorry. So, here's this local chat script only the nerby players see the message. I binded it "t" key it's overwrite the original chat. Now when i want to use a command (example /login or /reconnect or my commands) there's aren't work just send the command in the chatbox the commands don't work. At line 24 the script check it's a command or just a message but if it's a command i don't know what can i do whit it to i can use it.

Note: In the script "mondod" / "mondja" are hungarian words means "say"

Guest Guest4401
Posted
return executeCommandHandler(split(msg,' ')[1]:gsub("/",""),player,msg:gsub(split(msg,' ')[1],'')) 

Posted
        if string.sub(msg, 1, 1) == "/" then 
            executeCommandHandler(split(msg,' ')[1]:gsub("/",""),player,msg:gsub(split(msg,' ')[1],'')) 
        else 
            for _,v in ipairs(getElementsByType("player")) do 
                if isPlayerInRangeOfPoint(v,px,py,pz,chat_range) then 
                outputChatBox(nick.." mondja: "..msg,v,255,255,255,true) 
                end 
            end 
        end 
  

I copyed it. Now the if is look like this. But it's still don't work. No error message.

EDIT: No sorry, it's working just i tryed hardcoded (reconnect,quit) commands. Whit harcoded don't work but it isn't problem. Thank you very much :D

Posted

If you really want to replace 'T' then you might as well use onPlayerChat and cancelEvent. Then just make it display everything locally.

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