Jump to content

commands


Recommended Posts

you cant just change that one letter, to be recognized as commands..

you have to use "onPlayerChat" event, then check if his/her msg starts with "!" and after theres command you want to handle, then handle it.. (and cancell onPlayerChat event)

you will have to rewrite all addCommandHandler from all scripts..

for my opinion -> this is stupid.

Link to comment

it is really stupid, i'm still wondering why people like old mIRC script commands :D

anyway, you need only something like this:

addEventHandler("onPlayerChat", getRootElement(), 
function (text)
if string.sub(text, 1, 1) == "!" then
cancelEvent()
local command = string.gsub(gettok(text, 1, 32), "!", "")
local args = string.gsub(text, "!"..command, "")
--outputChatBox(getPlayerName(source)..": "..text, getRootElement())
executeCommandHandler(command, source, args)
end
end
)

if you want to display the command typed, uncomment the outputChatBox line.

Link to comment

if you want to display the command typed, uncomment the outputChatBox line.

thats stupid, just don't cancel event then, besides your output is not fully functional

cancelling is done for a reason, you know.

if event is not cancelled, command will be executed BEFORE chat output, since it's called from chat event.

so if the command called prints something to the chat, IT will look stupid.

and exactly what do you mean "not fully functional"?

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