LUA Commands Handler

Share your gamemodes and snippets here
Post Reply
Armelin

LUA Commands Handler

Post by Armelin » August 15th, 2019, 1:49 pm

  • This release is included in the 11.2 server dist
  • Function parameters

    Code: Select all

    addCommand(cmdName, cmdFunction, cmdParams)
    
    String cmdName: ex: "/hello"
    Function cmdFunction: declared name or definition
    String cmdParams:  i (Int), f (Float), s (anything, returns String) or nil if not required 
  • Examples:

    Code: Select all

    function testFunc(playerid, params)
    	if(params == nil) then
    		print("Usage: /test [int] [float]")
    		do return end
    	end
    	print("First param + lastParam = " .. params[1] + params[2])
    end
    addCommand("/test", testFunc, "if")
    

    Code: Select all

    addCommand("/test2", 
    	function(playerid)
    		print("Not expecting any params")
    	end
    , nil)
    

    Code: Select all

    addCommand("/test3", 
    	function(playerid, params)
    		--Params will be passed BUT the handler won't parse them. Note the nil usage
    		print("Param count: " .. #params)
    	end
    , nil)
    

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests