Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/22/14 in all areas

  1. I finally decided to add a section for creating custom commands. The information has been scattered around and I thought it will make it easier if all of it is in one place. http://mygamingtalk.com/wiki/index.php/Silent_Creating_Custom_Commands Please comment improvements and if you can provide clean short examples for the last two methods, that would be appreciated.
    2 points
  2. This is a great idea. I can provide a simple example of a shrubbot command working with LUA - we have a bunch of working scripts that use this method. You can use this if you want. For the purposes of this example, the command is mycommand. It will be executed when the uses enters !mycommand in the console, assuming that player has been assigned level 2 or higher shrubbot level. 1. Create your command in the shrubbot file. Open your shrubbot.cfg file (in silent\database directory) and add the following block: [command] command = mycommand exec = mycommand [i] desc = Does something cool for people over level 2 syntax = levels = 2 3 4 5 2. Create a LUA file in your silent directory on the server. Call it mycommand.lua (or whatever name you want to give it). Begin with the following stub: function et_ConsoleCommand(command) -- if the user types !mycommand in the console if et.trap_Argv(0) == "mycommand" then -- Do your custom processing here return 1 -- Tells silEnT that this method handled this command end return 0 -- Tells silEnT that this file did not handle this command end 3. Update your server config to load the LUA file. Add or modify the following server var (lua_modules): set lua_modules "mycommand.lua" 4. Restart your server. Assuming you are shrubbot level 2 or higher, !mycommand will execute and do cool stuff.
    2 points
  3. You could add the admin level to the passed arguments to the function: function CheckCommand(clientNum, level, arguments) if( arguments[0] == "!mycommand" ) then et.trap_SendServerCommand(clientNum, "chat \"Your command "..arguments[0].." has been received\"") return 1 end return 0 end function et_ClientCommand(clientNum, command) local level = et.G_shrubbot_level(clientNum) local flood = et.ClientIsFlooding(clientNum) -- we're not interested if the level is too low or if the client is flooding if (level < 1) or (flood == 1) then return 0 end local arg0 = string.lower(et.trap_Argv(0)) local arguments -- check to see if the command was given through any of the chat methods or as sparse text from the console if arg0 == "say" or arg0 == "say_team" or arg0 == "say_buddy" or arg0 == "say_teamnl" then arguments = SplitToArguments(et.trap_Argv(1)) else arguments = SplitToArguments(et.ConcatArgs(0)) end -- actual command handling return CheckCommand(clientNum, level, arguments) end Or you can declare the variable as close to its intended use as possible. This style is generally preferred when programming: function CheckCommand(clientNum, arguments) local level = et.G_shrubbot_level(clientNum) if( (arguments[0] == "!mycommand") and (level >= 1) ) then et.trap_SendServerCommand(clientNum, "chat \"Your command "..arguments[0].." has been received\"") return 1 end return 0 end function et_ClientCommand(clientNum, command) local flood = et.ClientIsFlooding(clientNum) -- we're not interested if the client is flooding if flood == 1 then return 0 end local arg0 = string.lower(et.trap_Argv(0)) local arguments -- check to see if the command was given through any of the chat methods or as sparse text from the console if arg0 == "say" or arg0 == "say_team" or arg0 == "say_buddy" or arg0 == "say_teamnl" then arguments = SplitToArguments(et.trap_Argv(1)) else arguments = SplitToArguments(et.ConcatArgs(0)) end -- actual command handling return CheckCommand(clientNum, arguments) end
    1 point
  4. Dragonji

    balance.lua + sound

    Use this instead: http://mygamingtalk.com/wiki/index.php/Silent_Lua#G_globalSound et.G_globalSound("playermove.wav")
    1 point
  5. I added an example to http://mygamingtalk.com/wiki/index.php/Silent_Creating_Custom_Commands You can use that to check issues. Btw, thanks for giving some code to start adding to it.
    1 point
×
×
  • Create New...