OnSettingChange: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
m (Improved clarity of example code) |
||
Line 17: | Line 17: | ||
==Example== | ==Example== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function makeSettingsChangesVisible ( setting, oldValue, newValue ) | function makeSettingsChangesVisible(setting, oldValue, newValue) | ||
whatItWas = fromJSON ( oldValue ) | local whatItWas = fromJSON(oldValue) | ||
whatItsNow = fromJSON ( newValue ) | local whatItsNow = fromJSON(newValue) | ||
outputDebugString ( "The setting "..setting.." was "..whatItWas.." and has been changed to "..whatItsNow.."." ) --Making the setting change visible in debug (use /debugscript [number] to see it) | outputDebugString("The setting "..setting.." was "..whatItWas.." and has been changed to "..whatItsNow..".") -- Making the setting change visible in debug (use /debugscript [number] to see it) | ||
end | end | ||
addEventHandler("onSettingChange", root, makeSettingsChangesVisible) | |||
addEventHandler( "onSettingChange", | |||
</syntaxhighlight> | </syntaxhighlight> | ||
{{See also/Server event|Server events}} | {{See also/Server event|Server events}} |
Latest revision as of 07:36, 2 November 2021
This event is triggered when resource setting has been changed. For instance, this event would trigger if you would edit the settings of the Race resource through the Admin panel.
Parameters
string setting, string oldValue, string newValue
- setting: The setting which was changed. For instance: "*race.ghostmode"
- oldValue: The previous value. Please note that this value is in JSON. To get a normal Lua value, use fromJSON
- newValue: The new value. Also in JSON
Source
The source of this event is the root element.
Example
function makeSettingsChangesVisible(setting, oldValue, newValue) local whatItWas = fromJSON(oldValue) local whatItsNow = fromJSON(newValue) outputDebugString("The setting "..setting.." was "..whatItWas.." and has been changed to "..whatItsNow..".") -- Making the setting change visible in debug (use /debugscript [number] to see it) end addEventHandler("onSettingChange", root, makeSettingsChangesVisible)
See Also
Server events
Event functions
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled