OnAccountDataChange: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Undo revision 59077 by Lizzalka (talk))
No edit summary
Line 35: Line 35:
</syntaxhighlight>
</syntaxhighlight>


{{See also/Server event|Server events}}
==See Also==
===Account events===
{{Account_events}}
===Event functions===
{{Event functions}}

Revision as of 02:01, 27 September 2018

This event is triggered when an accounts data changes through setAccountData.

Parameters

account theAccount, string theKey, string theValue
  • theAccount: the account that had data changed.
  • theKey: the string key that is being changed.
  • theValue: the value it is changing to.

Source

The source of this event is the root element.

Example

This examples prevents the key of "level" being added or changed on every account.

function preventLevelChange(account, key, value)
    if (key == "level") then
        cancelEvent()
    end
end
addEventHandler("onAccountDataChange", root, preventLevelChange)

This examples logs every single account data change to server log.

function preventLevelChange(account, key, value)
    if (wasEventCancelled()) then return end -- If the data change was aborted don't log it.
    outputServerLog(getAccountName(account) .. " key: " .. key .. " changed to: " .. tostring(value))
end
addEventHandler("onAccountDataChange", root, preventLevelChange)

See Also

Account events


Event functions