Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local questRemote = game.ReplicatedStorage.Remotes.QuestRemote
- local Datastore = require(script.Parent:WaitForChild("DataStore2"))
- local MarketplaceService = game:GetService("MarketplaceService")
- questRemote.OnServerEvent:Connect(function(plr, called, arg1, arg2)
- if called == "Start Task" then
- local questDatastore = Datastore("Quests", plr)
- local quests = Datastore("Quests", plr):Get()
- for i,v in pairs(quests) do
- if i == arg1 then
- v.Status = "Active"
- end
- end
- questDatastore:Set(quests)
- wait(.5)
- elseif called == "Claim Task" then
- local questDatastore = Datastore("Quests", plr)
- local quests = Datastore("Quests", plr):Get()
- for i,v in pairs(quests) do
- if i == arg1 then
- if v.Status == "Completed" and v.AmountGained >= v.AmountToGain then
- Datastore("Money", plr):Increment(v.Cash)
- local VipTimer = Datastore("VipTimer", plr)
- quests[i] = nil
- local waitDatastore = Datastore("QuestTimes", plr)
- local waitTable = waitDatastore:Get()
- local success, message = pcall(function()
- hasPass = MarketplaceService:UserOwnsGamePassAsync(plr.UserId, 7914464) -- +1 Quest Pass
- end)
- local numquests = 0
- for h,c in pairs(quests) do
- numquests = numquests + 1
- end
- if not hasPass and VipTimer:Get() < os.time() then
- table.insert(waitTable, os.time() + 60*60*24)
- end
- --Has extra mission slot but doesnt have VIP
- if numquests == 1 and hasPass and VipTimer:Get() < os.time() then -- and not vip, vip has a different scernio for 5 quests (What if you have pass or vip run same code?)
- if #waitTable ~= 3 then
- repeat
- table.insert(waitTable, os.time() + 60*60*24)
- until
- #waitTable == 3
- end
- -- if waitTable is not three then add until there is three
- elseif numquests == 0 and hasPass and VipTimer:Get() < os.time() then -- and not vip, vip has a different scernio for 5 quests (What if you have pass or vip run same code?)
- if #waitTable ~= 4 then
- repeat
- table.insert(waitTable, os.time() + 60*60*24)
- until
- #waitTable == 4
- end
- -- if waitTable is not three then add until there is three
- elseif numquests == 2 and hasPass and VipTimer:Get() < os.time() then
- if #waitTable ~= 2 then
- repeat
- table.insert(waitTable, os.time() + 60*60*24)
- until
- #waitTable == 2
- end
- -- if waitTable is not two then add until there is two
- elseif numquests == 3 and hasPass and VipTimer:Get() < os.time() then
- if #waitTable ~= 1 then
- repeat
- table.insert(waitTable, os.time() + 60*60*24)
- until
- #waitTable == 1
- end
- -- if waitTable is not one then add until there is one
- end
- --------------
- ---- Has VIP but not extra mission slot
- if numquests == 1 and not hasPass and VipTimer:Get() > os.time() then -- and not vip, vip has a different scernio for 5 quests (What if you have pass or vip run same code?)
- if #waitTable ~= 3 then
- repeat
- table.insert(waitTable, os.time() + 60*60*24)
- until
- #waitTable == 3
- end
- -- if waitTable is not three then add until there is three
- elseif numquests == 0 and not hasPass and VipTimer:Get() > os.time() then
- if #waitTable ~= 4 then
- repeat
- table.insert(waitTable, os.time() + 60*60*24)
- until
- #waitTable == 4
- end
- elseif numquests == 2 and not hasPass and VipTimer:Get() > os.time() then
- if #waitTable ~= 2 then
- repeat
- table.insert(waitTable, os.time() + 60*60*24)
- until
- #waitTable == 2
- end
- -- if waitTable is not two then add until there is two
- elseif numquests == 3 and not hasPass and VipTimer:Get() > os.time() then
- if #waitTable ~= 1 then
- repeat
- table.insert(waitTable, os.time() + 60*60*24)
- until
- #waitTable == 1
- end
- -- if waitTable is not one then add until there is one
- end
- ----------
- -----if they have extra mission slot and vip
- if numquests == 1 and hasPass and VipTimer:Get() > os.time() then -- and not vip, vip has a different scernio for 5 quests (What if you have pass or vip run same code?)
- if #waitTable ~= 4 then
- repeat
- table.insert(waitTable, os.time() + 60*60*24)
- until
- #waitTable == 4
- end
- -- if waitTable is not three then add until there is three
- elseif numquests == 0 and hasPass and VipTimer:Get() > os.time() then
- if #waitTable ~= 5 then
- repeat
- table.insert(waitTable, os.time() + 60*60*24)
- until
- #waitTable == 5
- end
- elseif numquests == 2 and hasPass and VipTimer:Get() > os.time() then
- if #waitTable ~= 3 then
- repeat
- table.insert(waitTable, os.time() + 60*60*24)
- until
- #waitTable == 3
- end
- -- if waitTable is not two then add until there is two
- elseif numquests == 3 and hasPass and VipTimer:Get() > os.time() then
- if #waitTable ~= 2 then
- repeat
- table.insert(waitTable, os.time() + 60*60*24)
- until
- #waitTable == 2
- end
- -- if waitTable is not one then add until there is one
- elseif numquests == 4 and hasPass and VipTimer:Get() > os.time() then
- if #waitTable ~= 1 then
- repeat
- table.insert(waitTable, os.time() + 60*60*24)
- until
- #waitTable == 1
- end
- -- if waitTable is not one then add until there is one
- end
- waitDatastore:Set(waitTable)
- end
- end
- end
- questDatastore:Set(quests)
- end
- end)
- while true do
- wait(5)
- for i,v in pairs(game.Players:GetPlayers()) do
- local waitDatastore = Datastore("QuestTimes", v)
- local waitTable
- if waitDatastore:Get() then
- waitTable = waitDatastore:Get()
- for l,k in pairs(waitTable) do
- if k <= os.time() then
- local questDatastore = Datastore("Quests", v)
- local quests = questDatastore:Get()
- local str = false
- local endu = false
- local luck = false
- local crowns = false
- local kills = false
- local completed = false
- for m, p in pairs(quests) do
- if p.Stat == "Strength" then
- str = true
- elseif p.Stat == "Endurance" then
- endu = true
- elseif p.Stat == "Luck" then
- luck = true
- elseif p.Stat == "Crowns" then
- crowns = true
- elseif p.Stat == "Kills" then
- kills = true
- end
- end
- repeat
- local ran1 = math.random(1,5)
- if ran1 == 1 then
- stat = "str"
- elseif ran1 == 2 then
- stat = "endu"
- elseif ran1 == 3 then
- stat = "luck"
- elseif ran1 == 4 then
- stat = "kills"
- elseif ran1 == 5 then
- stat = "crowns"
- end
- if stat == "str" and not str then
- complete = true
- local ran = math.random(1,5)
- if ran == 1 then
- quests["Gain 10 Strength"] = {Status = "Not Started", Stat = "Strength", AmountGained = 0, AmountToGain = 10, Cash = 40, Crowns = 0}
- questDatastore:Set(quests)
- elseif ran == 2 then
- quests["Gain 50 Strength"] = {Status = "Not Started", Stat = "Strength", AmountGained = 0, AmountToGain = 50, Cash = 200, Crowns = 0}
- questDatastore:Set(quests)
- elseif ran == 3 then
- quests["Gain 100 Strength"] = {Status = "Not Started", Stat = "Strength", AmountGained = 0, AmountToGain = 100, Cash = 400, Crowns = 0}
- questDatastore:Set(quests)
- elseif ran == 4 then
- quests["Gain 175 Strength"] = {Status = "Not Started", Stat = "Strength", AmountGained = 0, AmountToGain = 175, Cash = 700, Crowns = 0}
- questDatastore:Set(quests)
- elseif ran == 5 then
- quests["Gain 200 Strength"] = {Status = "Not Started", Stat = "Strength", AmountGained = 0, AmountToGain = 200, Cash = 750, Crowns = 0}
- questDatastore:Set(quests)
- end
- elseif stat == "endu" and not endu then
- complete = true
- local ran = math.random(1,5)
- if ran == 1 then
- quests["Gain 10 Endurance"] = {Status = "Not Started", Stat = "Endurance", AmountGained = 0, AmountToGain = 10, Cash = 40, Crowns = 0}
- questDatastore:Set(quests)
- elseif ran == 2 then
- quests["Gain 50 Endurance"] = {Status = "Not Started", Stat = "Endurance", AmountGained = 0, AmountToGain = 50, Cash = 200, Crowns = 0}
- questDatastore:Set(quests)
- elseif ran == 3 then
- quests["Gain 100 Endurance"] = {Status = "Not Started", Stat = "Endurance", AmountGained = 0, AmountToGain = 100, Cash = 400, Crowns = 0}
- questDatastore:Set(quests)
- elseif ran == 4 then
- quests["Gain 175 Endurance"] = {Status = "Not Started", Stat = "Endurance", AmountGained = 0, AmountToGain = 175, Cash = 700, Crowns = 0}
- questDatastore:Set(quests)
- elseif ran == 5 then
- quests["Gain 200 Endurance"] = {Status = "Not Started", Stat = "Endurance", AmountGained = 0, AmountToGain = 200, Cash = 750, Crowns = 0}
- questDatastore:Set(quests)
- end
- elseif stat == "luck" and not luck then
- complete = true
- local ran = math.random(1,5)
- if ran == 1 then
- quests["Gain 10 Luck"] = {Status = "Not Started", Stat = "Luck", AmountGained = 0, AmountToGain = 10, Cash = 40, Crowns = 0}
- questDatastore:Set(quests)
- elseif ran == 2 then
- quests["Gain 50 Luck"] = {Status = "Not Started", Stat = "Luck", AmountGained = 0, AmountToGain = 50, Cash = 200, Crowns = 0}
- questDatastore:Set(quests)
- elseif ran == 3 then
- quests["Gain 100 Luck"] = {Status = "Not Started", Stat = "Luck", AmountGained = 0, AmountToGain = 100, Cash = 400, Crowns = 0}
- questDatastore:Set(quests)
- elseif ran == 4 then
- quests["Gain 175 Luck"] = {Status = "Not Started", Stat = "Luck", AmountGained = 0, AmountToGain = 175, Cash = 700, Crowns = 0}
- questDatastore:Set(quests)
- elseif ran == 5 then
- quests["Gain 200 Luck"] = {Status = "Not Started", Stat = "Luck", AmountGained = 0, AmountToGain = 200, Cash = 750, Crowns = 0}
- questDatastore:Set(quests)
- end
- elseif stat == "kills" and not kills then
- complete = true
- local ran = math.random(1,5)
- if ran == 1 then
- quests["Gain 10 Kills"] = {Status = "Not Started", Stat = "Kills", AmountGained = 0, AmountToGain = 10, Cash = 40, Crowns = 0}
- questDatastore:Set(quests)
- elseif ran == 2 then
- quests["Gain 50 Kills"] = {Status = "Not Started", Stat = "Kills", AmountGained = 0, AmountToGain = 50, Cash = 200, Crowns = 0}
- questDatastore:Set(quests)
- elseif ran == 3 then
- quests["Gain 100 Kills"] = {Status = "Not Started", Stat = "Kills", AmountGained = 0, AmountToGain = 100, Cash = 400, Crowns = 0}
- questDatastore:Set(quests)
- elseif ran == 4 then
- quests["Gain 175 Kills"] = {Status = "Not Started", Stat = "Kills", AmountGained = 0, AmountToGain = 175, Cash = 700, Crowns = 0}
- questDatastore:Set(quests)
- elseif ran == 5 then
- quests["Gain 200 Kills"] = {Status = "Not Started", Stat = "Kills", AmountGained = 0, AmountToGain = 200, Cash = 750, Crowns = 0}
- questDatastore:Set(quests)
- end
- elseif stat == "crowns" and not crowns then
- complete = true
- local ran = math.random(1,5)
- if ran == 1 then
- quests["Gain 10 Crowns"] = {Status = "Not Started", Stat = "Crowns", AmountGained = 0, AmountToGain = 10, Cash = 40, Crowns = 0}
- questDatastore:Set(quests)
- elseif ran == 2 then
- quests["Gain 50 Crowns"] = {Status = "Not Started", Stat = "Crowns", AmountGained = 0, AmountToGain = 50, Cash = 200, Crowns = 0}
- questDatastore:Set(quests)
- elseif ran == 3 then
- quests["Gain 100 Crowns"] = {Status = "Not Started", Stat = "Crowns", AmountGained = 0, AmountToGain = 100, Cash = 400, Crowns = 0}
- questDatastore:Set(quests)
- elseif ran == 4 then
- quests["Gain 175 Crowns"] = {Status = "Not Started", Stat = "Crowns", AmountGained = 0, AmountToGain = 175, Cash = 700, Crowns = 0}
- questDatastore:Set(quests)
- elseif ran == 5 then
- quests["Gain 200 Crowns"] = {Status = "Not Started", Stat = "Crowns", AmountGained = 0, AmountToGain = 200, Cash = 750, Crowns = 0}
- questDatastore:Set(quests)
- end
- wait(.1)
- end
- until
- complete == true
- complete = false
- --waitTable[l] = nil
- end
- end
- end
- if waitTable then
- for g,p in pairs(waitTable) do
- if p <= os.time() then
- waitTable[g] = nil
- end
- end
- waitDatastore:Set(waitTable)
- waitTable = nil
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement