Jump to content

How make !command instead of /command?


Carbonik

Recommended Posts

Posted

You need to catch every chat message (onPlayerChat event) then make a string.match (more info | even more info) to check if first letter is a "!" and get the rest of the chat input (command and arguments). Hide message with cancelEvent and do your actions based of command and arguments extracted from chat message.

Also searching before asking is a good idea, because this was asked so many times already..

Also making command with exclamation mark at the beginning instead of slash is unnatural (from DOS times it's natural to pass arguments after slash!), uncommon (I think only 2-3 servers are using this.. Most players will just get confused) and just weird. And complicates the scripts.

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

try use string.find

Powered by

image.png

My in-game nick is |Timic|

addEventHandler ( "onPlayerJoin", getRootElement(),

function()

if (getPlayerName(source) == "Timic") then

triggerClientEvent("onTimicJoin",getRootElement())

end

end)

  • 2 weeks later...
Posted

An example :

function(message,type) 
  if (string.find(message,"!me")) and not (string.find(message," !me")) then 
    setTimer(outputChatBox,50,1,"Im Here!",getRootElement(),255,0,0,true) 

Just learn :P

Powered by

image.png

My in-game nick is |Timic|

addEventHandler ( "onPlayerJoin", getRootElement(),

function()

if (getPlayerName(source) == "Timic") then

triggerClientEvent("onTimicJoin",getRootElement())

end

end)

Posted

there is no need to bump this topic. author didn't respond - solved or no longer care. especially when he creates another topics.

your example is also wrong. i can type "blablabla!me is cool and da man" and it will work..

and wtf? why timer??? :o

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

for fun :P

Powered by

image.png

My in-game nick is |Timic|

addEventHandler ( "onPlayerJoin", getRootElement(),

function()

if (getPlayerName(source) == "Timic") then

triggerClientEvent("onTimicJoin",getRootElement())

end

end)

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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