cyklopas Posted October 21, 2010 Posted October 21, 2010 (edited) Well, whoever is familiar to Roleplay, must know what "/do" is used for. So yeah. It's my first normal script. And whoever doesn't know what /my command does, I'll explain you... For example your nickname is Doctor. You type /my balls are big. And here comes the screen: *Doctor's balls are big. Thanks for downloading and helping the project. Version 1.0 DOWNLOAD: Here. Version 2.0 DOWNLOAD: Here. Changelog: Version 2.0- Added the /my command. Thanks to: Me- the main idea. ThaCoinz- Bug Fixing Edited October 21, 2010 by Guest The /do and /my Commands
dzek (varez) Posted October 21, 2010 Posted October 21, 2010 why on console command not with addCommandHandler ? 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)!
cyklopas Posted October 21, 2010 Author Posted October 21, 2010 Because it works this way too. The /do and /my Commands
dzek (varez) Posted October 21, 2010 Posted October 21, 2010 addCommandHandler seems to be much simplier and using "/do" in chatbox instead of "do" in console will work? im not sure about this so im asking 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)!
cyklopas Posted October 21, 2010 Author Posted October 21, 2010 addCommandHandler seems to be much simplierand using "/do" in chatbox instead of "do" in console will work? im not sure about this so im asking It will The /do and /my Commands
eAi Posted October 21, 2010 Posted October 21, 2010 We've always recommended _not_ using onConsole for this. addCommandHandler is both easier and more secure as you can easily secure console commands from being used through the ACL, plus write much less code. This is a very silly way to do it. Your code: function input_Console ( text ) local command = gettok (text, 1, 32 ) if ( command == "my" ) then local playerName = getPlayerName ( source ) local actionText = string.sub ( text, 3 ) outputChatBox ( " *" .. playerName .. "'s" .. actionText .. " ", root, 255, 40, 80, true ) end end addEventHandler ( "onConsole", getRootElement(), input_Console ) How it should be done: function myCommand( playerSource, commandName, ...) local actionText = table.concat( arg, " " ) local playerName = getPlayerName ( playerSource ) outputChatBox ( " *" .. playerName .. "'s" .. actionText .. " ", root, 255, 40, 80, true ) end addCommandHandler("my", myCommand)
cyklopas Posted October 21, 2010 Author Posted October 21, 2010 We've always recommended _not_ using onConsole for this. addCommandHandler is both easier and more secure as you can easily secure console commands from being used through the ACL, plus write much less code.This is a very silly way to do it. Your code: function input_Console ( text ) local command = gettok (text, 1, 32 ) if ( command == "my" ) then local playerName = getPlayerName ( source ) local actionText = string.sub ( text, 3 ) outputChatBox ( " *" .. playerName .. "'s" .. actionText .. " ", root, 255, 40, 80, true ) end end addEventHandler ( "onConsole", getRootElement(), input_Console ) How it should be done: function myCommand( playerSource, commandName, ...) local actionText = table.concat( arg, " " ) local playerName = getPlayerName ( playerSource ) outputChatBox ( " *" .. playerName .. "'s" .. actionText .. " ", root, 255, 40, 80, true ) end addCommandHandler("my", myCommand) Many thanks, mate The /do and /my Commands
eAi Posted October 21, 2010 Posted October 21, 2010 Read the addCommandHandler wiki page for many more examples.
cyklopas Posted October 21, 2010 Author Posted October 21, 2010 Read the addCommandHandler wiki page for many more examples. Yeah, I can see that. Thanks for the info. I'll use more of these in future. The /do and /my Commands
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