Advertisement
1x_Gacha

Bounty System | Server

Aug 16th, 2020 (edited)
448
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.19 KB | None | 0 0
  1. local DataStore2 = require(game.ServerScriptService:WaitForChild('DataStore2'))
  2.  
  3. local function checkAssets(plr)
  4.     local Asset_Id = 000000000
  5.     local markerplaceservice = game:GetService('MarketplaceService')
  6.     local ownsasset = markerplaceservice.PlayerOwnsAsset
  7.    
  8.     local success, playerownsasset = pcall(ownsasset, markerplaceservice, plr, Asset_Id)
  9.     if playerownsasset then
  10.         print('Player Owns Asset.')
  11.         return true
  12.        
  13.        
  14.     else
  15.         warn('Player does not own Asset.')
  16.     end
  17. end
  18.  
  19. -- // [[
  20.  
  21. local rs = game:GetService('ReplicatedStorage')
  22. local remotefolder = rs:FindFirstChild('Remotes')
  23.  
  24. local bountytrigger = remotefolder:FindFirstChild('Bounty')
  25. local claimbounty = remotefolder:FindFirstChild('Claim')
  26. local toll = remotefolder:FindFirstChild('PayToll')
  27. local eventtrigger = remotefolder:FindFirstChild('EventTrigger')
  28. local teleporttrigger = remotefolder:FindFirstChild('TeleportTrigger')
  29. local blackmarkettrigger = remotefolder:FindFirstChild('BlackMarket')
  30.  
  31. local eventModule = require(rs.Resources.Events)
  32.  
  33. local function sendbountyinfo(plr, target, val)
  34.     local coinstore = DataStore2('ZetaCredit', plr)
  35.     if game.Players:FindFirstChild(target)then
  36.         local player = game.Players:FindFirstChild(target)
  37.         local bountystore = DataStore2('ZetaBounty', player)
  38.         if val <= coinstore:Get()then
  39.             coinstore:Increment(-val)
  40.             bountystore:Increment(val)
  41.         end
  42.     end
  43. end
  44.  
  45. local function claimTac(plr, event, target)
  46.     if event == 'INFO' then
  47.         print('SERVER CHECK')
  48.        
  49.     claimbounty:FireClient(plr, checkAssets(plr))
  50.    
  51.     --[[elseif event == 'CLAIM' then
  52.          if game.Players:FindFirstChild(target) then
  53.             local claimTarget = game.Players:FindFirstChild(target)
  54.             local claim = game.Players:FindFirstChild(plr.Name)
  55.            
  56.             local charTarget = game.Workspace:FindFirstChild(claimTarget.Name)
  57.            
  58.             local bountystore = DataStore2('ZetaBounty', claimTarget)
  59.             local coinstore = DataStore2('ZetaCredit', claim)
  60.             local bountycollectstore = DataStore2('ZetaBountyClaim', claim)
  61.             local bountyaccumulated = DataStore2('ZetaBountyAccumulate', claim)
  62.            
  63.             coinstore:Increment(bountystore:Get())
  64.             bountyaccumulated:Increment(bountystore:Get())
  65.             bountystore:Increment(-bountystore:Get())
  66.             bountycollectstore:Increment(1)
  67.             claimTarget:LoadCharacter()
  68.            
  69.         end]]  
  70.     end
  71. end
  72.  
  73. local function PayToll(plr, city)
  74.     local player = game.Players:FindFirstChild(plr.Name)
  75.     local coinstore = DataStore2('ZetaCredit', player)
  76.     coinstore:Increment(-10)
  77.     player.PlayerGui.TeleportGui.Enabled = true
  78.     teleporttrigger:FireClient(plr, city)
  79. end
  80.  
  81. local function EventCheck(plr, FORM, EventId)
  82.    
  83.         local m = eventModule.Events
  84.         local InEvent = plr.Bools.InEvent
  85.         local Completed = plr.Bools.IsComplete
  86.        
  87.     if game.Players:FindFirstChild(plr.Name)then
  88.         if FORM == 'CHECK' then
  89.             local folder = plr:FindFirstChild(m[EventId]['NAME'])
  90.             local count = folder:FindFirstChild(m[EventId]['GOAL'])
  91.             local goal = folder:FindFirstChild('Goal')
  92.            
  93.             local coinstore = DataStore2('ZetaCredit', plr)
  94.            
  95.             if count.Value >= goal.Value then
  96.                 print('CHECK TRUE')
  97.                 Completed.Value = true
  98.                 folder:Destroy()
  99.                 InEvent.Value = false
  100.                 coinstore:Increment(m[EventId]['PAY'])
  101.             else
  102.                 print('CHECK FALSE')
  103.                 Completed.Value = false
  104.             end
  105.         end
  106.        
  107.         if FORM == 'REGISTER'then
  108.             eventtrigger:FireClient(plr, EventId)
  109.             print('CHECK')
  110.             InEvent.Value = true
  111.             Completed.Value = false
  112.             local folder = Instance.new('Folder', plr)
  113.             folder.Name = m[EventId]['NAME']
  114.             local count = Instance.new('IntValue', folder)
  115.             count.Name  = m[EventId]['GOAL']
  116.             count.Value = 0
  117.             local goal = Instance.new('IntValue', folder)
  118.             goal.Name = 'Goal'
  119.             goal.Value = m[EventId]['AMOUNT']
  120.         end
  121.     end
  122. end
  123.  
  124. local function teleport(plr, destination)
  125.     local player = game.Players:FindFirstChild(plr.Name)
  126.     local char = player.Character
  127.     local locations = game.Workspace:FindFirstChild('EventLocations'):FindFirstChild('Teleport')
  128.     if locations:FindFirstChild(destination)then
  129.         char.Torso.CFrame = locations[destination].CFrame
  130.     end
  131.     wait(3)
  132.     player.PlayerGui.TeleportGui.Enabled = false
  133. end
  134.  
  135. local function blackmarket(plr, call, item)
  136.     local player = game.Players:FindFirstChild(plr.Name)
  137.     local char = player.Character
  138.     local location = game.Workspace:FindFirstChild('BlackmarketFolder'):WaitForChild('Center')
  139.     if call == 'OPEN' then
  140.         if (location.Position - char.Torso.Position).magnitude < 100 then
  141.             player.PlayerGui.Blackmarket.Enabled  = true
  142.         end
  143.     end
  144.    
  145.     if call == 'EXIT' then
  146.         player.PlayerGui.Blackmarket.Enabled = false
  147.     end
  148.    
  149.     if call == 'PURCHASE' then
  150.         local m = require(rs.Resources.Blackmarket)
  151.         local coinstore = DataStore2('ZetaCredit', player)
  152.         if coinstore:Get() >= m.Items[item]['price'] then
  153.             coinstore:Increment(m.Items[item]['deduct'])
  154.             local tool = game:GetService('ServerStorage'):FindFirstChild(item):Clone()
  155.             tool.Parent = plr.Backpack
  156.         end
  157.     end
  158. end
  159.  
  160. bountytrigger.OnServerEvent:Connect(sendbountyinfo)
  161. claimbounty.OnServerEvent:Connect(claimTac)
  162. toll.OnServerEvent:Connect(PayToll)
  163. eventtrigger.OnServerEvent:Connect(EventCheck)
  164. teleporttrigger.OnServerEvent:Connect(teleport)
  165. blackmarkettrigger.OnServerEvent:Connect(blackmarket)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement