SetAccountData

From Multi Theft Auto: Wiki
Revision as of 15:15, 16 August 2007 by Arc (talk | contribs)
Jump to navigation Jump to search

This template is no longer in use as it results in poor readability. This function sets a string to be stored in an account. This can then be retrieved using getAccountData. Data stored as account data is persistent across user's sessions and maps, unless they are logged into a guest account.

Syntax

bool setAccountData ( account theAccount, string key, string value )

Required Arguments

  • theAccount: The account you wish to retrieve the data from.
  • key: The key under which you wish to store the data
  • value: The value you wish to store

Returns

Returns a true if the account data was set, false if an invalid argument was specified.

Example

On a roleplaying server, save the money of a player when he quits, so it can be loaded again when he comes back later.

function onPlayerQuit ( )
      local playeraccount = getClientAccount ( source )
      local playermoney = getPlayerMoney ( source )
      setAccountData ( playeraccount, "piraterpg.money", playermoney )
end

function onPlayerJoin ( )
      local playeraccount = getClientAccount ( source )
      local playermoney = getAccountData ( playeraccount, "piraterpg.money" )
      setPlayerMoney ( source, playermoney )
end

addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit )
addEventHandler ( "onPlayerJoin", getRootElement ( ), onPlayerJoin )

See Also