GetServerConfigSetting: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
(Updated info)
 
(5 intermediate revisions by 4 users not shown)
Line 9: Line 9:
==Syntax==
==Syntax==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
string getServerConfigSetting ( string name )
mixed getServerConfigSetting ( string name )
</syntaxhighlight>
</syntaxhighlight>


===Required Arguments===  
===Required Arguments===  
*'''name :''' The name of the setting
*'''name :''' The name of the setting (setting names can be found [[Server_mtaserver.conf|here]])


===Returns===
===Returns===
Returns a string containing the current value for the named setting, or ''false'' if the setting does not exist.
Returns a string containing the current value for the named setting, ''table'' if '''name''' is '''module''' or ''false'' if the setting does not exist.<br>
If the setting name is ''serverip'', may return the string ''"auto"'' on local servers.


==Example==
==Example==
Line 22: Line 23:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
outputChatBox( getServerConfigSetting ("minclientversion") )
outputChatBox( getServerConfigSetting ("minclientversion") )
</syntaxhighlight>
This example creates a <code>getServerIP</code> helper function:
<syntaxhighlight lang="lua">
function getServerIP()
    return getServerConfigSetting("serverip")
end
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{Utility functions}}
{{Utility functions}}

Latest revision as of 16:16, 10 October 2023

This function retrieves server settings which are usually stored in the mtaserver.conf file.

Available in 1.1 and onwards

Syntax

mixed getServerConfigSetting ( string name )

Required Arguments

  • name : The name of the setting (setting names can be found here)

Returns

Returns a string containing the current value for the named setting, table if name is module or false if the setting does not exist.
If the setting name is serverip, may return the string "auto" on local servers.

Example

This example prints the server minimum allowed client version to the chatbox

outputChatBox( getServerConfigSetting ("minclientversion") )

This example creates a getServerIP helper function:

function getServerIP()
    return getServerConfigSetting("serverip")
end

See Also