OnAccountDataChange: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
(Undo revision 59077 by Lizzalka (talk))
Line 1: Line 1:
<font face="sans-serif">
__NOTOC__
<div style="background:#333;">
{{Server event}}
<div style="height:4px;background:#AAA;"></div>
This event is triggered when an accounts data changes through [[setAccountData]].
<font color="#FFF" size="5">
 
<p>&nbsp;Ваша версия Adobe Flash Player устарела</p>
==Parameters==
</font>
<syntaxhighlight lang="lua">
<div style="background:#FFF;">
account theAccount, string theKey, string theValue
<font color="#F00" size="2">
</syntaxhighlight>
<p>Требуется срочное обновление до текущей версии!</p>
 
</font>
*'''theAccount''': the [[account]] that had data changed.
<font color="#000" size="4">
*'''theKey''': the [[string]] key that is being changed.
<p>Adobe Flash Player 30.0.0.164 <font color="#888" size="2">(~18 kB)</font></p>
*'''theValue''': the value it is changing to.
</font>
 
<font color="#444" size="2">
==Source==
<p><b>Операционная система:</b> Windows<br><b>Язык:</b> Выбирает пользователь</p>
The [[event system#Event source|source]] of this event is the [[root]] element.
</font>
 
<font color="#000" size="4">
==Example==
<p>Скачать обновление с Яндекс.Диска: yadi.sk/d/AfbiMAr1PkGdww</p>
This examples prevents the key of "level" being added or changed on every account.
</font>
<syntaxhighlight lang="lua">
</div>
function preventLevelChange(account, key, value)
</div>
    if (key == "level") then
</font>
        cancelEvent()
    end
end
addEventHandler("onAccountDataChange", root, preventLevelChange)
</syntaxhighlight>
 
This examples logs every single account data change to server log.
<syntaxhighlight lang="lua">
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)
</syntaxhighlight>
 
{{See also/Server event|Server events}}

Revision as of 06:12, 9 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

Server events


Event functions