Jump to content

Chatbox


WhoAmI

Recommended Posts

Hi guys.

        for _,player in ipairs ( getElementsByType ( "player" ) ) do 
            unbindKey ( player, "T", "down", "chatbox", "say" ) 
            bindKey ( player, "T", "down", "chatbox", "IC" ) 
        end 

Is it possible to do such a thing? Couse i found topic in thsi forum, and someone said that it is not, but I saw this in some RP server. How can I do, that in "T" key I would have another chat than "Say"?

Link to comment

Actually I don't think it is possible. I remembered wrong; you can't unbind MTA internal commands.

However, you can do the following, like Anubhav mentioned above:

Server-side

addEventHandler( "onPlayerChat", root, 
    function( message, messageType ) 
        if ( messageType == 1 ) then 
            cancelEvent( ) 
            -- Do your own stuff 
        end 
    end 
) 

Link to comment
  • Moderators
On 03/03/2014 at 11:58, myonlake said:

Actually I don't think it is possible. I remembered wrong; you can't unbind MTA internal commands.

However, you can do the following, like Anubhav mentioned above:

Server-side


addEventHandler( "onPlayerChat", root, 
    function( message, messageType ) 
        if ( messageType == 1 ) then 
            cancelEvent( ) 
            -- Do your own stuff 
        end 
    end 
) 
 

 

We can ! But not with unBindKey actually. You need to use

toggleControl 
and the control name for the chatbox is "chatbox":

https://wiki.multitheftauto.com/wiki/Co ... d_commands

So just toggle that control to false and the player won't be able to show the chat input field.

Link to comment
Yea but how I would do another chat?
bindKey ( player, "T", "down", -- [[and here what?]] ) 

bindKey ( player, "T", "down", "chatbox", "IC" ) 
  
--You will need to have an addCommandHandler 
  
addCommandHandler("ic", function() 
... 
end) 

Link to comment
  • Moderators
Yea but how I would do another chat?
bindKey ( player, "T", "down", -- [[and here what?]] ) 

put a function that will show a new edit field for example. and when the guy press enter, get the text of this edit, output the text in the chat and hide the edit.

I'm guessing it's what you wanted to do ?

If not, then explain us exactly what you really want to do

Btw, you will have to rewrite the command feature. When you find a / as a first character, then send everyting in

executeCommandHandler 

Link to comment
  • Moderators

Oh ok, so you don't want to create a whole new chatbox, thought you wanted to do that.

You actually just want to add some stuff/fucntion between the chatbox input field and the display in the chatbox.

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