-
Notifications
You must be signed in to change notification settings - Fork 3
Syntax
- Example
Allows you to test your server / credentials status
local DataStore3 = require(game:GetService("ServerScriptService").DataStore3Libary); --Imports the DataStore3 library
DataStore3.testConnection()
-
arguments -
payload
payload
The SQL payload that is sent to the server.
- Example
Auto save data every 30 seconds, In this example we save
gold
,gems
andwood
this isn't hard coded meaning you can make this anything and as many as you want
local DataStore3 = require(game:GetService("ServerScriptService").DataStore3Libary); --Imports the DataStore3 libary
local Players = game:GetService("Players")
while true do -- Infinate Loop
for i,v in pairs(game.Players:GetChildren()) do -- Get all active players in game
gold = v.leaderstats.Gold.Value -- Get players Gold Value
gems = v.leaderstats.Gems.Value -- Get players Gems Value
wood = v.Inventory.Wood.Value -- Get players Wood Value
-- Update table called userData and set gold, wood and gems where usersId = players user id
local payload = "UPDATE userData SET gold ='"..gold.."', wood ='"..wood.."', gems='"..gems.."' WHERE userId = '"..v.UserId.."';"
local response = DataStore3.PostPayload(payload) -- Send the Post request to the server
end
wait(30) -- Wait 30 seconds to loop again
end
-
arguments -
payload
payload
The SQL payload that is sent to the server.
- Example
Gets all data from a database for a user using there
UserId
and save the response asresponse
local DataStore3 = require(game:GetService("ServerScriptService").DataStore3Libary); --Imports the DataStore3 libary
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player) -- Player Join function
local userid = player.UserId -- Get UserId of joined player
local payload = "SELECT * FROM userData WHERE userId ='"..userid.."'" -- Select all from userdata table where userId = players userid (SQL CODE)
local response = DataStore3.GetPayload(payload) -- Send the post request to the server
end)
-
arguments -
TableName
,ColumnName
TableName
The name of the table where the column exists.
ColumnName
The name of the column you want to delete.
- Limitations
You can only delete 1 column at a time.
- Example
Removes the column called
gems
from the table nameduserData
local DataStore3 = require(game:GetService("ServerScriptService").DataStore3Libary); --Imports the DataStore3 libary
local Players = game:GetService("Players")
DataStore3.DeleteColumn("userData", "gems")
-
arguments -
TableName
,ColumnName
TableName
The table location you want the column to exist.
ColumnName
The name of the column you want to create.
DataType
The datatype of the column (find data types here).
- Limitations
You can only create one column at a time.
- Example
Creates a column called
gems
within the table called 'userData' with aINT(10)
data type
local DataStore3 = require(game:GetService("ServerScriptService").DataStore3Libary); --Imports the DataStore3 libary
local Players = game:GetService("Players")
DataStore3.CreateColumn("userData", "gems", "INT(10)")
-
arguments -
TableName
,ColumnName
TableName
The name of the table where the column exists.
ColumnName
The name of the column you want to delete.
- Limitations
You can only delete 1 column at a time.
- Example
Removes the column called
gems
from the table nameduserData
local DataStore3 = require(game:GetService("ServerScriptService").DataStore3Libary); --Imports the DataStore3 libary
local Players = game:GetService("Players")
DataStore3.DeleteColumn("userData", "gems")
-
arguments -
TableName
,PrimaryKey
,DataType
TableName
The table you want to create.
PrimaryKey
The name of the primary key.
DataType
The data type of the primary key.
- Limitations
You can only create 1 table and only specify 1 column (Primary key)
- Example
Creates a column called
gems
within the table called 'userData' with aINT(10)
data type
local DataStore3 = require(game:GetService("ServerScriptService").DataStore3Libary); --Imports the DataStore3 libary
local Players = game:GetService("Players")
DataStore3.DeleteTable("userData")
-
arguments -
TableName
TableName
The table you want to delete.
- Limitations
You can only delete one table at a time.
- Example
Creates a column called
gems
within the table called 'userData' with aINT(10)
data type
local DataStore3 = require(game:GetService("ServerScriptService").DataStore3Libary); --Imports the DataStore3 libary
local Players = game:GetService("Players")
DataStore3.DeleteTable("userData")