joedajoester Posted January 16, 2012 Share Posted January 16, 2012 Is there a function in scripting that can perform a command from another script? Like in one script, if someone types, can i get a infernus. I got the scripting part to get what someone says. Then the script would output a code like /cv infernus for that player. Would aexec work in a script? Link to comment
mjau Posted January 16, 2012 Share Posted January 16, 2012 https://wiki.multitheftauto.com/wiki/Exe ... andHandler Link to comment
joedajoester Posted January 16, 2012 Author Share Posted January 16, 2012 For this i get error, bad argument @ excuteCommandHandler expected argument at element 2. function sendMessage2( messageclean, messageType) if (string.find(messageclean, "i") and string.find(messageclean, "love") and string.find(messageclean, "bot")) then outputChatBox("i love you too!", source, 191, 62, 255) end end addEventHandler("onPlayerChat",root,sendMessage2) function sendMessage2( messageclean, messageType) if (string.find(messageclean, "i") and string.find(messageclean, "hate") and string.find(messageclean, "bot")) then outputChatBox("Ill note that", source, 191, 62, 255) end end addEventHandler("onPlayerChat",root,sendMessage2) function sendMessage2( messageclean, messageType) if (string.find(messageclean, "hi") and string.find(messageclean, "bot")) then outputChatBox("Hello", source, 191, 62, 255) end end addEventHandler("onPlayerChat",root,sendMessage2) function sendMessage2( messageclean, messageType) if (string.find(messageclean, "how") and string.find(messageclean, "are") and string.find(messageclean, "bot")) then outputChatBox("I'm doing great", source, 191, 62, 255) end end addEventHandler("onPlayerChat",root,sendMessage2) function sendMessage2( messageclean, messageType) if (string.find(messageclean, "i") and string.find(messageclean, "a") and string.find(messageclean, "infernus")) then executeCommandHandler ( "sv infernus", playerSource ) end end addEventHandler("onPlayerChat",root,sendMessage2) Link to comment
mjau Posted January 16, 2012 Share Posted January 16, 2012 function sendMessage2( messageclean, messageType) if (string.find(messageclean, "i") and string.find(messageclean, "love") and string.find(messageclean, "bot")) then outputChatBox("i love you too!", source, 191, 62, 255) end end addEventHandler("onPlayerChat",root,sendMessage2) function sendMessage2( messageclean, messageType) if (string.find(messageclean, "i") and string.find(messageclean, "hate") and string.find(messageclean, "bot")) then outputChatBox("Ill note that", source, 191, 62, 255) end end addEventHandler("onPlayerChat",root,sendMessage2) function sendMessage2( messageclean, messageType) if (string.find(messageclean, "hi") and string.find(messageclean, "bot")) then outputChatBox("Hello", source, 191, 62, 255) end end addEventHandler("onPlayerChat",root,sendMessage2) function sendMessage2( messageclean, messageType) if (string.find(messageclean, "how") and string.find(messageclean, "are") and string.find(messageclean, "bot")) then outputChatBox("I'm doing great", source, 191, 62, 255) end end addEventHandler("onPlayerChat",root,sendMessage2) function sendMessage2( messageclean, messageType) if (string.find(messageclean, "i") and string.find(messageclean, "a") and string.find(messageclean, "infernus")) then executeCommandHandler ( "sv infernus", source ) end end addEventHandler("onPlayerChat",root,sendMessage2) Link to comment
joedajoester Posted January 16, 2012 Author Share Posted January 16, 2012 Still doesn't work and no error code. The sv script is also running along with thi script. Do you know what's going wrong?? Link to comment
TAPL Posted January 16, 2012 Share Posted January 16, 2012 function sendMessage2( messageclean, messageType) if (string.find(messageclean, "i") and string.find(messageclean, "love") and string.find(messageclean, "bot")) then outputChatBox("i love you too!", source, 191, 62, 255) end end addEventHandler("onPlayerChat",root,sendMessage2) function sendMessage2( messageclean, messageType) if (string.find(messageclean, "i") and string.find(messageclean, "hate") and string.find(messageclean, "bot")) then outputChatBox("Ill note that", source, 191, 62, 255) end end addEventHandler("onPlayerChat",root,sendMessage2) function sendMessage2( messageclean, messageType) if (string.find(messageclean, "hi") and string.find(messageclean, "bot")) then outputChatBox("Hello", source, 191, 62, 255) end end addEventHandler("onPlayerChat",root,sendMessage2) function sendMessage2( messageclean, messageType) if (string.find(messageclean, "how") and string.find(messageclean, "are") and string.find(messageclean, "bot")) then outputChatBox("I'm doing great", source, 191, 62, 255) end end addEventHandler("onPlayerChat",root,sendMessage2) function sendMessage2( messageclean, messageType) if (string.find(messageclean, "i") and string.find(messageclean, "a") and string.find(messageclean, "infernus")) then executeCommandHandler("sv", source, "infernus") end end addEventHandler("onPlayerChat",root,sendMessage2) Link to comment
joedajoester Posted January 16, 2012 Author Share Posted January 16, 2012 ok i will test this tomorrow. thank you and what was going wrong? Link to comment
BriGhtx3 Posted January 16, 2012 Share Posted January 16, 2012 As far as I know this was the error (The space between "sv" and "infernus"). like TAPL said it has to be like this : executeCommandHandler("sv", source, "infernus") Link to comment
joedajoester Posted January 16, 2012 Author Share Posted January 16, 2012 It still doesnt work and i get no error. Everything works fine, just the car spawning part. Link to comment
GanJaRuleZ Posted January 16, 2012 Share Posted January 16, 2012 Well , you can name the function spawnInfernus and there you can write executeCommandHandler("spawnInfernus" , source) Link to comment
Castillo Posted January 16, 2012 Share Posted January 16, 2012 function sendMessage2( messageclean, messageType) if (string.find(messageclean, "i") and string.find(messageclean, "love") and string.find(messageclean, "bot")) then outputChatBox("i love you too!", source, 191, 62, 255) elseif (string.find(messageclean, "i") and string.find(messageclean, "hate") and string.find(messageclean, "bot")) then outputChatBox("Ill note that", source, 191, 62, 255) elseif (string.find(messageclean, "hi") and string.find(messageclean, "bot")) then outputChatBox("Hello", source, 191, 62, 255) elseif (string.find(messageclean, "how") and string.find(messageclean, "are") and string.find(messageclean, "bot")) then outputChatBox("I'm doing great", source, 191, 62, 255) elseif (string.find(messageclean, "i") and string.find(messageclean, "a") and string.find(messageclean, "infernus")) then executeCommandHandler("sv", source, "infernus") end end addEventHandler("onPlayerChat",root,sendMessage2) Link to comment
TAPL Posted January 17, 2012 Share Posted January 17, 2012 if you are using freeroam resource the command isn't sv it's cv Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now