Custom console commands
invTempest
Join Date: 2003-03-02 Member: 14223Members, Constellation, Squad Five Blue
in Modding
Comments
and this one i found in getWebApi
.. ' <input type="submit" name="addbot" value="Add Bot" /> '
another example: Event.Hook("Console_create", OnCommandCreate)
so, you can simply add your own command to you NS2ConsoleCommands_Server.lua, but use the prefix "Console_", since I think it will be attached automatically somewhere.
hope that helped a little bit
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->Event.Hook("Console_my_console_command", MyCustomCommand)<!--c2--></div><!--ec2-->
Whenever that console-command is run, the engine calls the lua-function 'MyCustomCommand'.
To this function a ServerClient-object is passed as the first parameter. This is the client that used the console-command. It is also possible that said console-command is run from the server-console or the web-admin, in which case there isn't a client to speak of, and the first parameter will be NIL. All parameters following the first one are arguments given to the console-command (they are seperated by spaces). So say "my_console_command" requires 2 parameters (let's run "my_console_command test1 test2"), the function will look like this:
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->function MyCustomCommand( Client, Parameter1, Parameter2 )
-- Do something here
end<!--c2--></div><!--ec2-->
Parameter1 will be a string with the value "test1", and likewise Parameter2 "test2".