ScriptreMooCow

Database_main

Jun 6th, 2019
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.96 KB | None | 0 0
  1. --[[
  2.     The purpose of this system is simple. It stores player data in
  3.     databases, and retrieves player data from databases. Acts as an
  4.     interface between Magic system, NPC system, Stamina system, etc.
  5.  
  6.     The updater ties act as the middle man between the database and
  7.     other scripts that are client side (The gui scripts, aura scripts, etc).
  8.    
  9.     Naming conventions for database scripts will follow SQL conventions:
  10.     https://www.xaprb.com/blog/2008/10/26/the-power-of-a-good-sql-naming-convention/
  11. --]]
  12. local master_key = "player_user_data"
  13. local DataStore2 = require(1936396537)
  14. DataStore2.Combine(
  15.     master_key,
  16.     "MISSION_DATABASE",
  17.     "BACKPACK_DATABASE",
  18.     "INVENTORY", -- holds non tools
  19.     "PLAYER_COINS", -- holds player gold coins and blackstone fragments
  20.     "MAX_STAMINA",
  21.     "MAX_AURA",
  22.     "PLAYER_LEVEL",
  23.     "PLAYER_RANK",
  24.     "PLAYER_INFLUENCE",
  25.     "PLAYER_ENEMIES",
  26.     "PLAYER_ALLIES",
  27.     "PLAYER_ALLIANCES"
  28. )
  29. local table = require(game.ReplicatedStorage.ModuleScripts.table)
  30.  
  31. local player_userdatas = {}
  32.  
  33. game.Players.PlayerAdded:Connect(function(player)
  34.     local player_userdata = {}
  35.     player_userdata.mission_database = DataStore2("MISSION_DATABASE", player)
  36.     player_userdata.backpack_database = DataStore2("BACKPACK_DATABASE", player)
  37.     player_userdata.inventory = DataStore2("INVENTORY", player)
  38.     player_userdata.player_coins = DataStore2("PLAYER_COINS", player)
  39.     player_userdata.max_stamina = DataStore2("MAX_STAMINA", player)
  40.     player_userdata.max_aura = DataStore2("MAX_AURA", player)
  41.     player_userdata.player_level = DataStore2("PLAYER_LEVEL", player)
  42.     player_userdata.player_rank = DataStore2("PLAYER_RANK", player)
  43.     player_userdata.player_influence = DataStore2("PLAYER_INFLUENCE", player)
  44.     player_userdata.player_enemies =  DataStore2("PLAYER_ENEMIES", player)
  45.     player_userdata.player_allies = DataStore2("PLAYER_ALLIES", player)
  46.     player_userdata.player_alliances = DataStore2("PLAYER_ALLIANCES", player)
  47.     player_userdatas[player.UserId] = player_userdata
  48. end)
Advertisement
Add Comment
Please, Sign In to add comment