GetModuleInfo: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (Added getModuleInfo)
 
mNo edit summary
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
{{Server function}}  
{{Server function}}  
<!-- Describe in plain english what this function does. Don't go into details, just give an overview -->
This function returns information about the specified [[Modules|module]].
This function returns information about the specified module.


==Syntax==  
==Syntax==  
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd -->
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
table getModuleInfo (string moduleName, string informationToGet)
table getModuleInfo ( string moduleName )
</syntaxhighlight>  
</syntaxhighlight>  


===Required Arguments===  
===Required Arguments===  
*'''moduleName:''' A string containing the module you wish to get information of e.g. "hashing.dll"
*'''moduleName:''' A string containing the module you wish to get information of e.g. "hashing.dll"
*'''informationToGet:''' A string containing the information you wish to retrieve Currently supported information is Version, Name and Author.


===Returns===
===Returns===
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check -->
Returns a [[table]] containing information about module. These keys are present in the table:
Returns a string with the requested information about the module. If The modulename is invalid or the informationToGet parameter is invalid it will return ''false''.
*'''version''': Module version in format X.XX
*'''name''': Module name
*'''author''': Module author
If invalid name for module is passed, it will return ''false''.


==Example==  
==Example==
<!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized -->
This example adds a command ''checkmodules'' with which you can view information about currently loaded modules.
<syntaxhighlight lang="lua">
function printModuleInfo ( thePlayer )
    local modules = getLoadedModules()
    if #modules == 0 then
        return outputConsole ( "There are no modules loaded!", thePlayer ) -- Return as no module is loaded, the for has nothing todo
    end


    for k, v in ipairs ( modules ) do
        local moduleInfo = getModuleInfo ( v )
        outputConsole ( moduleInfo.name .. "(" .. v .. ") v" .. moduleInfo.version .. ", author: " .. moduleInfo.author, thePlayer )
    end
end
addCommandHandler ( "checkmodules", printModuleInfo )
</syntaxhighlight>


==See Also==
==See Also==
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc -->
{{Module_functions}}
{{Module_functions}}
[[ru:getModuleInfo]]

Latest revision as of 15:43, 16 September 2014

This function returns information about the specified module.

Syntax

table getModuleInfo ( string moduleName )

Required Arguments

  • moduleName: A string containing the module you wish to get information of e.g. "hashing.dll"

Returns

Returns a table containing information about module. These keys are present in the table:

  • version: Module version in format X.XX
  • name: Module name
  • author: Module author

If invalid name for module is passed, it will return false.

Example

This example adds a command checkmodules with which you can view information about currently loaded modules.

function printModuleInfo ( thePlayer )
    local modules = getLoadedModules()
    if #modules == 0 then
        return outputConsole ( "There are no modules loaded!", thePlayer ) -- Return as no module is loaded, the for has nothing todo
    end

    for k, v in ipairs ( modules ) do
        local moduleInfo = getModuleInfo ( v )
        outputConsole ( moduleInfo.name .. "(" .. v .. ") v" .. moduleInfo.version .. ", author: " .. moduleInfo.author, thePlayer )
    end
end
addCommandHandler ( "checkmodules", printModuleInfo )

See Also