Advertisement
Guest User

Untitled

a guest
Nov 15th, 2016
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.46 KB | None | 0 0
  1. -- Setup
  2. local PurchaseFunctions = {};
  3.  
  4.  
  5. --[[
  6.    
  7.     Function: GiveCash
  8.     Description: Give a specified amount of cash when purchased
  9.     Option: Amount of cash to give
  10.    
  11.     Function: GiveMaxHealth
  12.     Description: Raises max health
  13.     Option: Amount of health to be added on top of the 100.
  14.    
  15.     Function: GiveSpeed
  16.     Description: Increases walkspeed
  17.     Option: Amount of speed to add onto base speed (16)
  18.    
  19.     Function: GiveGear
  20.     Description: Puts a gear into player's backpack
  21.     Option: Name of the gear
  22.     Option2: Put true if it saves when you die, false if it's only for one life.
  23.    
  24.    
  25. --]]
  26.  
  27.  
  28. -- Tip: Changing 'Name' doesn't do anything, it's just for organizational purposes.
  29.  
  30. local Gamepasses = {
  31.     { Name="Give #TeamJD Sign Permanently";  ID=546372998;  Function="GiveGear";  Option="#TeamJDSign";  Option2=true; };
  32.     { Name="Give JD Knife Permanently";  ID=546373770;  Function="GiveGear";  Option="JDKnife";  Option2=true; };
  33.     { Name="Give JD Gun Permanently";  ID=546373570;  Function="GiveGear";  Option="JDGun";  Option2=true; };
  34.     { Name="Give Radio Permanently";  ID=546205764;  Function="GiveGear";  Option="Radio";  Option2=true; };
  35.     { Name="Give Cloud Permanently";  ID=546371214;  Function="GiveGear";  Option="Cloud";  Option2=true; };
  36.     { Name="Give Hoverboard Permanently";  ID=546369593;  Function="GiveGear";  Option="Hoverboard";  Option2=true; };
  37. };
  38.  
  39. local DeveloperProducts = {
  40.     { Name="Give Teddy Temporarily";  ID=43414443;  Function="GiveGear";  Option="Teddy";  Option2=false; };  -- Don't forget this symbol ;
  41.     { Name="Give RAIG TABLE!!! Temporarily";  ID=43386695;  Function="GiveGear";  Option="RAIGTABLE!!!";  Option2=false; };
  42.     { Name="Give Firefly Jar Temporarily";  ID=43414837;  Function="GiveGear";  Option="FireflyJar";  Option2=false; };
  43.     { Name="Give Fireworks Temporarily";  ID=43414903;  Function="GiveGear";  Option="Fireworks";  Option2=false; };
  44.     { Name="Give Hot Chocolate Temporarily";  ID=43415111;  Function="GiveGear";  Option="HotChocolate";  Option2=false; };
  45.     { Name="Give Smore Temporarily";  ID=43415135;  Function="GiveGear";  Option="Smore";  Option2=false; };
  46. };
  47.  
  48. -- Tip: 'Username' is not used, it's just to keep track of who you're giving passes to because UserIDs are hard to remember!
  49. -- Tip: You can use this to test the gamepasses without buying or even making them, the ID can be fake and it'll still work.
  50.  
  51. local FreePasses = {
  52.     { Username="Player1";   UserID=-1;      Passes={ 546372998,546373770,546373570,546205764,546371214,546369593,43414443,43386695,43414837,43414903,43415111,43415135 };          };
  53.     { Username="Nikilis";   UserID=4242824; Passes={ 546372998,546373770,546373570,546205764,546371214,546369593,43414443,43386695,43414837,43414903,43415111,43415135 };          };
  54. }
  55.  
  56. -- Nothing below to edit
  57.  
  58. local MarketplaceService = game:GetService("MarketplaceService")
  59. local Keys = {};
  60. function MarketplaceService.ProcessReceipt(ReceiptInfo)
  61.     local playerProductKey = ReceiptInfo.PlayerId .. ":" .. ReceiptInfo.PurchaseId
  62.     if Keys[playerProductKey] then return Enum.ProductPurchaseDecision.PurchaseGranted; end
  63.  
  64.     local Player = game:GetService("Players"):GetPlayerByUserId(ReceiptInfo.PlayerId)
  65.     if not Player then return Enum.ProductPurchaseDecision.NotProcessedYet; end
  66.  
  67.     for _,ProductData in pairs(DeveloperProducts) do
  68.         if ProductData.ID == ReceiptInfo.ProductId then
  69.             PurchaseFunctions[ProductData.Function](Player,ProductData.Option,ProductData.Option2);
  70.             Keys[playerProductKey] = true;
  71.             return Enum.ProductPurchaseDecision.PurchaseGranted    
  72.         end
  73.     end
  74.    
  75.     return Enum.ProductPurchaseDecision.NotProcessedYet
  76. end
  77.  
  78. local MaxHealths = {};
  79. local Speeds = {};
  80.  
  81. PurchaseFunctions.GiveCash = function( Target, Option )
  82.     game.ServerStorage.MoneyStorage[Target.Name].Value = game.ServerStorage.MoneyStorage[Target.Name].Value + Option;
  83. end
  84.  
  85. PurchaseFunctions.GiveMaxHealth = function( Target, Option )
  86.     MaxHealths[Target] = (MaxHealths[Target] and MaxHealths[Target]+Option) or Option;
  87.     Target.Character.Humanoid.MaxHealth = 100 + MaxHealths[Target];
  88. end
  89.  
  90. PurchaseFunctions.GiveSpeed = function( Target, Option )
  91.     Speeds[Target] = (Speeds[Target] and Speeds[Target]+Option) or Option;
  92.     Target.Character.Humanoid.WalkSpeed = 16 + Speeds[Target];
  93. end
  94.  
  95. PurchaseFunctions.GiveGear = function( Target, Gear, Permanent )
  96.     game.ServerStorage.Gear[Gear]:Clone().Parent = Target.Backpack;
  97.     if Permanent then
  98.         game.ServerStorage.Gear[Gear]:Clone().Parent = Target.StarterGear;
  99.     end
  100. end
  101.  
  102.  
  103. local function Debug(Player,Function,Option,Option2)
  104.     PurchaseFunctions[Function](Player,Option,Option2);
  105. end
  106. local Debugger = Instance.new("RemoteEvent")
  107. Debugger.Name = "PurchaseDebugger";
  108. Debugger.Parent = game.ReplicatedStorage;
  109.  
  110. MarketplaceService.PromptPurchaseFinished:connect(function(Player, AssetID, IsPurchased)
  111.     if IsPurchased then
  112.         for _,GamepassData in pairs(Gamepasses) do
  113.             if AssetID == GamepassData.ID then
  114.                 PurchaseFunctions[GamepassData.Function](Player,GamepassData.Option,GamepassData.Option2);
  115.             end;
  116.         end;
  117.     end
  118. end)
  119.  
  120. game.ReplicatedStorage.BuyDP.OnServerEvent:connect(function(Player,ID)
  121.     MarketplaceService:PromptProductPurchase(Player,ID);
  122. end)
  123.  
  124. game.ReplicatedStorage.BuyGP.OnServerEvent:connect(function(Player,ID)
  125.     MarketplaceService:PromptPurchase(Player,ID);
  126. end)
  127.  
  128. game.Players.PlayerAdded:connect(function(Player)  
  129.     Player.CharacterAdded:connect(function(Character)
  130.         Character:WaitForChild("Humanoid").MaxHealth = 100 + (MaxHealths[Player] or 0);
  131.         Character:WaitForChild("Humanoid").WalkSpeed = 16 + (Speeds[Player] or 0);
  132.     end)
  133.     repeat wait(); until Player.Character~=nil and game.ServerStorage.MoneyStorage:FindFirstChild(Player.Name);
  134.     for _,GamepassData in pairs(Gamepasses) do
  135.         local HasFreePass = false;
  136.         for _,PD in pairs(FreePasses) do
  137.             if PD.UserID == Player.userId then
  138.                 for _,ID in pairs(PD.Passes) do
  139.                     if ID == GamepassData.ID then
  140.                         HasFreePass = true;
  141.                     end
  142.                 end
  143.             end;
  144.         end
  145.         if HasFreePass or MarketplaceService:PlayerOwnsAsset(Player,GamepassData.ID) then
  146.             PurchaseFunctions[GamepassData.Function](Player,GamepassData.Option,GamepassData.Option2);
  147.         end
  148.     end;
  149. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement