Guest User

Untitled

a guest
Jun 23rd, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.07 KB | None | 0 0
  1. --
  2. --  PLAYER DATA MANAGMENT
  3. --
  4. accountRoot = createElement("accountNode", "accountNode")
  5.  
  6. -- This function initializes the account node for the given player, with the accountData table from MySQL.
  7. -- PRECONDITION: The player must be logged out, the account must be empty.
  8. function initializeAccountNode(player, accountData)
  9.     if getElementType(player) ~= "player" or type(accountData) ~= "table" then
  10.         error("Invalid arguments to initializePlayerNode()!", 1)
  11.     end
  12.    
  13.     if isAccountInUse(accountData.id) or isPlayerLoggedIn(player) then
  14.         return false
  15.     end
  16.    
  17.     local accountNode = createElement("accountNode", "account"..accountData.id)
  18.     setElementData(accountNode, "ID", accountData.id)
  19.     setElementData(accountNode, "playerElement", player, false)
  20.    
  21.     for key, value in pairs(accountData) do
  22.         if key ~= "id" and key ~= "password" and key ~= "mta_serial" then
  23.             setElementData(accountNode, key, value)
  24.         end
  25.     end
  26.    
  27.     setElementParent(accountNode, accountRoot)
  28.    
  29.     setElementData(player, "ID", accountData.id)
  30.     setElementData(player, "accountNode", newNode)
  31.     return true
  32. end
Add Comment
Please, Sign In to add comment