Jump to content

clearChatBox()


blas95

Recommended Posts

Firstly, I want to say hello, I'm new here. (actually, the first post, but I'm interested in MTA for a while)

Secondly, my English isn't perfect, I'm from Poland, so, sorry.

I think this will be very useful too have an ability to clear whole chatbox (and maybe console?) via scripting.

Possibilities with this are huge. Eg. chatbox tabs (outputs stored in a table. When user change tab, the chat is cleared and outputChatBox is called with every item in a table) or cleaning the chatbox when user change account.

Link to comment

Welcome - we've got lots of users from Poland here and your English seems pretty good!

The chat box is, I think, on the boundary between what the user should have complete control over and what servers would like control over. It's a hard line to tread - you don't want servers to be able to annoy users by overriding the chatbox behaviour substantially. There's no real reason that I can think of that a server couldn't have a chatbox resource that replaces the standard one - I can't see why that wouldn't work. That seems a more practical route to go down, though providing script access to the user's chatbox settings might be desirable (or providing a generic way for scripts to give users options?)

Link to comment

Frankly, making a custom chatbox isn't practical at all at the moment.

Making one in GUI simply sucks. It looks bad, and you have to click on the chatbox input before you can type in it.

A DX chatbox on the other hand needs functions like bindKey to work. However, bindKey seems to return the wrong key sometimes. (if I recall correctly / was being seen as # for example) Also, you need to do toggleAllControls to disable player's controls, which probably overrides all other control toggling already done. Besides that, you'd need a way to block keybinds as those would still work. (admin panel popping up when pressing the P in chat? no thanks)

Perhaps guiSetInputEnabled + getKeyState would work, but there's another problem that makes this whole thing impractical; Chatbox customisation. A lot of people have a modified chatbox. However, the server doesn't know what the client's chatbox looks like. In fact, the client doesn't even know what the client's chatbox looks like. You could of course just make it have a whole different look, but why would you edit your chatbox if the server changes it anyway? You could also make a possibility to edit the chatbox in the server, but that would be double work. First customizing in the settings menu, then on the server.

I think clearChatBox would actually be quite useful. Saves a lot of hassle, and I doubt players will get much trouble from it. It can't be misused that much. Alternatively, I'd like to see a good way of making your own chatbox. Preferably one identical to the client's. (therefore I would like to see a function like getChatboxLayout)

Link to comment

Chatbox is really possible, i have a scripted dx chatbox, which works exactly like the mta's one and has the same options aswell + has tabs on the side you can switch.

I agree, making the input was a bit hacky but possible, commands get executed with executeCommandHandler and binds are blocked with guiSetInputEnabled functions.

Link to comment
Chatbox is really possible, i have a scripted dx chatbox, which works exactly like the mta's one and has the same options aswell + has tabs on the side you can switch.

I agree, making the input was a bit hacky but possible, commands get executed with executeCommandHandler and binds are blocked with guiSetInputEnabled functions.

so its posible to execute for example /quit or /dissconetc, or /nick, or /time, etc commands with that function?

and u can clear chatbox with many times outputchatbox "", and save all chat to otput again by:

--client!
--chat saver
chattab = {}
line = 1
addEventHandler("onClientChatMessage",getRootElement(), function (text,r,g,b)
if text~="" then
   chattab[line] = string.gsub(tocolor(tonumber(r),tonumber(g),tonumber(b)),"0x%x%x","#")..text
   line = line+1
end
end)
 
--chat clear
function clearChat()
 done=0
while done<=200 do
outputChatBox("",0,0,0,false)
   done = done+1
end
end
 
--put chat back
function reAddChat()
if #chattab>200 then 
   addcount = #chattab
   currentcount = #chattab-200 
else 
   addcount =  #chattab 
   currentcount = 0 
end
while currentcount<=addcount do
outputChatBox(chattab[currentcount],0,0,0,true)
   currentcount = currentcount+1
end
end

EDIT: updated with new code

Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...