Jump to content

Rewriting Default Commands


sirboring

Recommended Posts

Posted (edited)

Hy guys ,

I'm trying to make some really basic chat system as a way to learn the basics of lua / mta scripting.

I have something like this:

function chatMain(pl, cmd, ...) 
--shared logic
-- ...

if(cmd == "c") 
...
elseif(cmd == "me")
...
end
end

-- ...
addCommandHandler("c", chatMain)
addCommandHandler("s", chatMain)
addCommandHandler("me", chatMain)
addCommandHandler("do", chatMain)
addCommandHandler("b", chatMain)

Everything seems to be working just fine except /me 

It uses mta's default code rather than mine.

How can i change that ?

 

I tried with this

addEventHandler("onPlayerCommand", root, 
function(cmd) 
	if (cmd == "me") then 
		chatMain(source ,"me" ,...) 
	end 
end) 

but it's obviously wrong...

 

Thanks.

Edited by sirboring
Posted (edited)

not so exp, but tried using cancelEvent()  before calling chatMain function?

Edited by Om.

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