Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Server backend for random wheel commission
- -- Author: grillkol (discord)
- -- Copying or distributing this script is not permitted without explicit permission from the author.
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local HttpService = game:GetService("HttpService")
- local RandomizerMap = require(ReplicatedStorage.Modules.RandomizerMap)
- local RNG = require(ReplicatedStorage.Modules.RNG)
- local rewardCache = {}
- local RandomizerHandler = {}
- function RandomizerHandler.Initialize()
- ReplicatedStorage.Remotes.RandomizerNetworker.OnServerEvent:Connect(function(player, topic, data)
- if topic == "requestSpin" then
- RandomizerHandler.InitiateSpin(player, "shogun")
- elseif topic == "completedSpin" then
- RandomizerHandler.CompletedSpin(player, data)
- end
- end)
- end
- function RandomizerHandler.CompletedSpin(player, data)
- if data.id then
- local rewardData = rewardCache[data.id]
- if rewardData then
- rewardCache[data.id] = nil
- print(rewardData)
- -- Here you can run any needed functions such as giving player the item
- end
- end
- end
- function RandomizerHandler.TimeoutReward(data)
- task.delay(60, function()
- rewardCache[data.id] = nil
- end)
- end
- function RandomizerHandler.InitiateSpin(player, randomizerType) -- randomizerType = "shogun"
- local data = {}
- data.randomizerType = randomizerType
- data.item, data.rarity = RandomizerMap[data.randomizerType]()
- data.id = HttpService:GenerateGUID()
- rewardCache[data.id] = data
- ReplicatedStorage.Remotes.RandomizerNetworker:FireClient(player, "startSpin", data)
- end
- return RandomizerHandler
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement