Advertisement
Guest User

Untitled

a guest
Jun 16th, 2016
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.40 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 Minigun Permanently";  ID=12345;   Function="GiveGear";        Option="Minigun";   Option2=true; };
  32. };
  33.  
  34. local DeveloperProducts = {
  35.     { Name="Give 50 Cash";              ID=00000;   Function="GiveCash";        Option=50; };                   -- Don't forget this symbol ;
  36.     { Name="Give 25 Max Health";        ID=0000;    Function="GiveMaxHealth";   Option = 25; };
  37.     { Name="Give 5 WalkSpeed";          ID=0000;    Function="GiveSpeed";       Option = 5; };
  38.     { Name="Give Minigun Temporarily";  ID=0000;    Function="GiveGear";        Option="Minigun";   Option2=false; };
  39. };
  40.  
  41. -- Tip: 'Username' is not used, it's just to keep track of who you're giving passes to because UserIDs are hard to remember!
  42. -- 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.
  43.  
  44. local FreePasses = {
  45.     { Username="Player1";   UserID=-1;      Passes={ 12345,11111,595959 };          };
  46.     { Username="Nikilis";   UserID=1848960; Passes={ 12345,11111,595959 };          };
  47.     { Username="Thexz";     UserID=4242824; Passes={ 12345,11111,595959 };          };
  48. }
  49.  
  50.  
  51.  
  52.  
  53.  
  54. -- Nothing below to edit
  55.  
  56. local MarketplaceService = game:GetService("MarketplaceService")
  57. local Keys = {};
  58. function MarketplaceService.ProcessReceipt(ReceiptInfo)
  59.     local playerProductKey = ReceiptInfo.PlayerId .. ":" .. ReceiptInfo.PurchaseId
  60.     if Keys[playerProductKey] then return Enum.ProductPurchaseDecision.PurchaseGranted; end
  61.  
  62.     local Player = game:GetService("Players"):GetPlayerByUserId(ReceiptInfo.PlayerId)
  63.     if not Player then return Enum.ProductPurchaseDecision.NotProcessedYet; end
  64.  
  65.     for _,ProductData in pairs(DeveloperProducts) do
  66.         if ProductData.ID == ReceiptInfo.ProductId then
  67.             PurchaseFunctions[ProductData.Function](Player,ProductData.Option,ProductData.Option2);
  68.             Keys[playerProductKey] = true;
  69.             return Enum.ProductPurchaseDecision.PurchaseGranted    
  70.         end
  71.     end
  72.    
  73.     return Enum.ProductPurchaseDecision.NotProcessedYet
  74. end
  75.  
  76. local MaxHealths = {};
  77. local Speeds = {};
  78.  
  79. PurchaseFunctions.GiveCash = function( Target, Option )
  80.     Target.leaderstats.Cash.Value = Target.leaderstats.Cash.Value + Option;
  81. end
  82.  
  83. PurchaseFunctions.GiveMaxHealth = function( Target, Option )
  84.     MaxHealths[Target] = (MaxHealths[Target] and MaxHealths[Target]+Option) or Option;
  85.     Target.Character.Humanoid.MaxHealth = 100 + MaxHealths[Target];
  86. end
  87.  
  88. PurchaseFunctions.GiveSpeed = function( Target, Option )
  89.     Speeds[Target] = (Speeds[Target] and Speeds[Target]+Option) or Option;
  90.     Target.Character.Humanoid.WalkSpeed = 16 + Speeds[Target];
  91. end
  92.  
  93. PurchaseFunctions.GiveGear = function( Target, Gear, Permanent )
  94.     game.ServerStorage.Gear[Gear]:Clone().Parent = Target.Backpack;
  95.     if Permanent then
  96.         game.ServerStorage.Gear[Gear]:Clone().Parent = Target.StarterGear;
  97.     end
  98. end
  99.  
  100.  
  101. local function Debug(Player,Function,Option,Option2)
  102.     PurchaseFunctions[Function](Player,Option,Option2);
  103. end
  104. local Debugger = Instance.new("RemoteEvent")
  105. Debugger.Name = "PurchaseDebugger";
  106. Debugger.Parent = game.ReplicatedStorage;
  107.  
  108.  
  109. game.Players.PlayerAdded:connect(function(Player)  
  110.     Player.CharacterAdded:connect(function(Character)
  111.         Character:WaitForChild("Humanoid").MaxHealth = 100 + (MaxHealths[Player] or 0);
  112.         Character:WaitForChild("Humanoid").WalkSpeed = 16 + (Speeds[Player] or 0);
  113.     end)
  114.     repeat wait(); until Player.Character~=nil;
  115.     for _,GamepassData in pairs(Gamepasses) do
  116.         local HasFreePass = false;
  117.         for _,PD in pairs(FreePasses) do
  118.             if PD.UserID == Player.userId then
  119.                 for _,ID in pairs(PD.Passes) do
  120.                     if ID == GamepassData.ID then
  121.                         HasFreePass = true;
  122.                     end
  123.                 end
  124.             end;
  125.         end
  126.         if HasFreePass or MarketplaceService:PlayerOwnsAsset(GamepassData.ID) then
  127.             PurchaseFunctions[GamepassData.Function](Player,GamepassData.Option,GamepassData.Option2);
  128.         end
  129.     end;
  130. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement