![]() Its all saved through JSONEncodeįunction PlayerStatManager:RedeemCode(player, Code) - Function that is fired through a RemoteFunctionįor i, v in pairs(sessionData) do - Loop through codes player already used Note that sessionData is where data of the player is stored. PlayerStatManager:ChangeCurrency(player, "Gems", 50, false) - Change value of GEMS ![]() If MarketplaceService:PlayerOwnsAsset(player, 2030764761) then - Check if player has badge PlayerStatManager:ChangeCurrency(player, "Money", 250, false) Internal function that changes Money value of player it includes a Code as the index and a functioin as a value. If you think I missed or overlooked anything, please feel free to send me feedback, this is my first time making a tutorial If you do not feel comfortable using an asset to store codes, you can also do something more advanced without changing most of the code! Because we are decoding a JSON string, we can change our MarketplaceService call to a HttpService:GetAsync() request to a web server! If you need assistance implementing the changing of stats, please feel free to send me a message! The provided code may not fit your data structure. check if code was already redeemed in your DataStore Local codes = game:GetService("HttpService"):JSONDecode(game:GetService("MarketplaceService"):GetProductInfo(assetId).Description) Remember to keep this on the server, you wouldn’t want to leak the assetId where you store your codes! local function codes(player, code) Here is the finished product of our code system. We can now easily search through the codes to see if the right one was called. Local codes = game:GetService("HttpService"):JSONDecode(desc)īecause we are using JSONDecode, codes is a table. To decode the JSON string back into a table we can use: local description = game:GetService("MarketplaceService"):GetProductInfo(assetId).Description Using the MarketplaceService, we can fetch the description using the assetId like so: local description = game:GetService("MarketplaceService"):GetProductInfo(assetId).Description We now have our codes stored in an assets description, but how do we fetch them? It is actually fairly simple. We then copy and past this into the assets description! local codes = īecause this is how JSON string are encoded, we can be assured that this will work. Now lets create our table of codes that we want to turn into a JSON encoded string. Lets start to build our system: game:GetService("HttpService") ![]() To store our codes, we will need to use a method of the HttpService. Anything with an assetId that has a description will work! To do this, publish a blank model, decal, audio, or place to Roblox. With this system, you can update and add codes in live time (short delay ~30s) so you do not have to shutdown servers!įor this simple system, we will need to have an assetId handy. This is a relatively short overview on how to get started implementing a code system into your game.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |