Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Welcome to this tutorial about how to use the Developer API Module to fit your purposes!
- -- PREPARING FOR YOUR GAME --
- So, to start off with this Developer API, you just need to do some easy steps.
- First off, we'd like to require the module.
- Do so by typing this into your code : "local devAPI = require(993003470)" (without the quotation marks).
- That was easy, wasn't it?
- Now, if this is your first time, please note that once you make your place ready, it will only show your username and password once.
- Notes away and your code should now look similar to this:
- "local devAPI = require(993003470)
- devAPI:Initiate()
- "
- Make two variables. Username and Password in your script and assign them with the Username and password in the output.
- ------------------------------
- You have now prepared the server for your game data.
- You can now continue to any of the steps below!
- -- SAVING AND GETTING DATA --
- You need to save data before you can retrieve it, otherwise it will return an error.
- To save data you will need to use the ":SaveAsync()" method.
- It requires 3 arguments to be provided: Username, Password, Table .
- Like this : "
- local Username = "xxxxxx"
- local Password = "XXXXXXXXXXXXX"
- local saveData = devAPI:SaveAsync(Username, Password, Table)
- "
- This will return a table with information.
- It will return "status", "info".
- You need to make security measures, so your script won't break if anything happens.
- You should do:
- "
- local Username = "xxxxxx"
- local Password = "XXXXXXXXXXXXX"
- local saveData = devAPI:SaveAsync(Username, Password, Table)
- if saveData["status"] == "success" then --If the saving was a success
- print'Saving data was a success'
- else --If it wasn't a success
- print("Status : ", saveData["status"] , " | Info: ", saveData["info"])
- end
- "
- Now you have secured your code.
- -Getting data-
- To get the data you stored you will use the method ":GetAsync()";
- It requires 2 arguments: Username, Password
- It will return a table with : "status", "info", "data"
- "data" contains the data you saved.
- To use it:
- "
- local Username = "xxxxxx"
- local Password = "XXXXXXXXXXXXX"
- local fetchData = devAPI:GetAsync(Username, Password)
- if fetchData["status"] == "success" and fetchData["data"] ~= nil then
- print'Retrieving data was a success"
- local YOURDATA = fetchData["data"]
- else
- print("Status: ", fetchData["status"], " | Info: ", fetchData["info"] )
- end
- "
- Now, you know how to save and get data!
- Congratulations!
- ----------------------------------------------
- Below here are some functions for you as a developer who needs the Roblox API for your game.
- -- Getting roblox group information --
- To return a table with information about a group you will use the ":GetGroupInfo()"
- It requires one argument, two are optional.
- The first argument is the group id.
- This is a string or integer.
- The second argument is optional and is if you want it to return a decoded version table, otherwise it will return a JSON Encoded table.
- This is a bool
- The third argument is depending on the second argument to be "true", this argument is if you want the script to just return the value of the name you set (i.e "Name" will return the name of the group).
- This is a string
- Example :
- "
- local Username = "xxxxxx"
- local Password = "XXXXXXXXXXXXX"
- local groupInfo = devAPI:GetGroupInfo("2", true, "Name")
- print(groupInfo)
- --> "LOL"
- "
- Now you know that, moving on to the next step ..
- -------------------------------------------
- -- Checking if two users are friends --
- If you ever wondered if two users are friends or not, then this function is handy for you.
- You use this function like this ":IsFriends()"
- It requires 2 arguments, the user id of user1 and the user id of user 2.
- This will return a bool (true / false)
- Note that if you try to see if user1 is friends with user1 it will return true.
- Example :
- "
- local Username = "xxxxxx"
- local Password = "XXXXXXXXXXXXX"
- local friends = devAPI:IsFriends("1", "1")
- printt(friends)
- if friends then
- print' They are friends !!'
- else
- print' They are not friends :( '
- end
- "
- Nice, you have come far, still more to go...
- -----------------------------------------
- -- Get name from user id --
- This function might be handy sometimes, who knows??
- You use it by doing ":NameFromId()"
- It requires 1 argument, and 1 is optional.
- First argument is the user id.
- The second argument is optional, and is a bool if you want it to just print the username, or return a regular table with a bit more info.
- Example:
- "
- local Username = "xxxxxx"
- local Password = "XXXXXXXXXXXXX"
- local getName = devAPI:NameFromId("18442032", true)
- print(getName)
- --> Kekulator
- "
- Soon, you know all them' secrets..
- ----------------------------------------------
- --Getting the id from the name --
- Well, this also might be handy sometimes in the future, and no one still knows..
- To use this do ":IdFromName()"
- It requires 1 argument, 1 is optional.
- First argument is the username.
- Second argument is if you want it just to return the user id.
- Example :
- "
- local Username = "xxxxxx"
- local Password = "XXXXXXXXXXXXX"
- local getID = devAPI:IdFromName("Kekulator", true)
- print(getID)
- -->18442032
- "
- Coming far, I can tell..
- ---------------------------------------------
- -- Getting a user's friends --
- Well, hope you enjoy!!
- To use this, you need to do ":GetUserFriends()"
- It requires 1 argument and 1 is optional
- The first argument is the id of the user
- The second argument is optional, and returns the page you want.
- Each page is a new user btw.
- Example : "
- local Username = "xxxxxx"
- local Password = "XXXXXXXXXXXXX"
- local getFriends = devAPI:GetUserFriends("18442032", 15)
- print(getFriends["Username"])
- --> CaptainXafius
- "
- Soon TM reaching the end I guess, hope you like it so far..
- --------------------------------------------------------------
- This is the last function (yet) in the developer API.
- -- Custom API --
- To use this, you need to go to "http://api.roblox.com/docs#" and find the info you need there.
- Afterwards you need to call the ":CustomAPI()"
- It requires 1 argument: The link (i.e "users/USERID/friends")
- NOTE THIS ONLY SUPPORTS "GET" METHODS!
- Example :
- "
- local Username = "xxxxxx"
- local Password = "XXXXXXXXXXXXX"
- local customone = devAPI:CustomAPI("/users/USERID")
- print(customone)
- --Returns a JSON Encoded table, what you do with it is up to you.
- "
- The end.
- JK.
- ------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement