Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Let's begin. You can do it!
- branch = game.ServerScriptService.branch.Value --Last one was test21
- currencybranch = game.ServerScriptService.currencybranch.Value
- invenData = game:GetService("DataStoreService"):GetDataStore("Inventory", branch)
- loadoutDataCT = game:GetService("DataStoreService"):GetDataStore("LoadoutCT", branch)
- loadoutDataT = game:GetService("DataStoreService"):GetDataStore("LoadoutT", branch)
- currencyData = game:GetService("DataStoreService"):GetDataStore("Currency",currencybranch)
- local HTTP = game:GetService("HttpService")
- local databaseService = nil
- local databaseCT = nil
- local databaseT = nil
- if script.DatabaseServiceEnabled.Value then
- databaseService = require(game:GetService("ServerScriptService").DatabaseService)
- databaseCT = databaseService:GetDatabase("LoadoutCT")
- databaseT = databaseService:GetDatabase("LoadoutT")
- end
- function postdiscordfunction(player, msg,webhook)
- spawn(function()
- local payload = HTTP:JSONEncode({
- content = msg,
- username = player.Name.." - (#"..player.UserId..")"
- })
- HTTP:PostAsync(webhook, payload)
- end)
- end
- function AddSkin(UserId,Skin,OnlyOne)
- local Reward = true
- invenData:UpdateAsync(tostring(UserId), function(oldValue)
- local newValue = oldValue
- if not newValue then
- newValue = DefInven
- end
- --if OnlyOne then
- for i=1, #newValue do
- --print("Checking ")
- if newValue[i] == Skin then
- Reward = false
- --print("Already exists")
- end
- end
- if Reward then
- table.insert(newValue,1,Skin)
- end
- --end
- -- for key, value in pairs(newValue) do
- -- --print(key, "=", value)
- -- end
- --print("JOINED, Inventory length = "..#newValue)
- return newValue
- end)
- if Reward then
- local player = game.Players:GetPlayerByUserId(0)
- postdiscordfunction(player,"JUST REDEEMED THEIR GOLDEN KARAMBIT :OO","https://discordapp.com/api/webhooks/289170412984860672/bLVw9k9Jqe64H_31fhJTJdiLMc73gTrXMLKHVpYYNn2XSRlvssHKW3AfLcU5SHMzjhZV")
- end
- end
- DefInven = {
- "Glock_Stock",
- "DualBerettas_Stock",
- "P250_Stock",
- "Tec9_Stock",
- "DesertEagle_Stock",
- "USP_Stock",
- "P2000_Stock",
- "FiveSeven_Stock",
- "CZ_Stock",
- --R8 = "Stock",
- "Galil_Stock",
- "AK47_Stock",
- "Scout_Stock",
- "SG_Stock",
- "AWP_Stock",
- "G3SG1_Stock",
- "Famas_Stock",
- "M4A4_Stock",
- "M4A1_Stock",
- "AUG_Stock",
- "Scar_Stock",
- "Nova_Stock",
- "XM_Stock",
- "MAG7_Stock",
- "M249_Stock",
- "Negev_Stock",
- "SawedOff_Stock",
- "MAC10_Stock",
- "MP9_Stock",
- "MP7_Stock",
- "UMP_Stock",
- "P90_Stock",
- "Bizon_Stock" ,
- "Knife_Karambit",
- "Knife_Butterfly Jade Dream",
- }
- TLoadout = {
- CZOver = false,
- R8Over = false,
- KnifeOver = false,
- --pistols
- Glock = "Stock",
- DualBerettas = "Stock",
- P250 = "Stock",
- Tec9 = "Stock",
- DesertEagle = "Stock",
- CZ = "Stock",
- --smgs
- MAC10 = "Stock",
- MP7 = "Stock",
- UMP = "Stock",
- P90 = "Stock",
- Bizon = "Stock",
- Nova = "Stock",
- XM = "Stock",
- SawedOff = "Stock",
- M249 = "Stock",
- Negev = "Stock",
- Galil = "Stock",
- AK47 = "Stock",
- Scout = "Stock",
- SG = "Stock",
- AWP = "Stock",
- G3SG1 = "Stock",
- TKnife = "Stock",
- R8 = "Stock",
- Knife = "Butterfly",
- }
- CTLoadout = {
- CZOver = false,
- R8Over = false,
- M4A1Over = false,
- USPOver = false,
- KnifeOver = false,
- --pistols
- P2000 = "Stock",
- USP = "Stock",
- DualBerettas = "Stock",
- P250 = "Stock",
- FiveSeven = "Stock",
- DesertEagle = "Stock",
- CZ = "Stock",
- --smgs
- MP9 = "Stock",
- MP7 = "Stock",
- UMP = "Stock",
- P90 = "Stock",
- Bizon = "Stock",
- Nova = "Stock",
- XM = "Stock",
- MAG7 = "Stock",
- M249 = "Stock",
- Negev = "Stock",
- Famas = "Stock",
- M4A4 = "Stock",
- M4A1 = "Stock",
- Scout = "Stock",
- AUG = "Stock",
- AWP = "Stock",
- Scar = "Stock",
- CTKnife = "Stock",
- R8 = "Stock",
- Knife = "Butterfly",
- }
- --DefLoadout["SHOOTYGUN"] = "Stock"
- --table.insert(DefLoadout,"shootygun","Stock")
- game.Players.PlayerAdded:connect(function(player)
- --If nothing exists, create it
- local F = Instance.new("Folder")
- F.Name = "SkinFolder"
- F.Parent=player
- local CT = Instance.new("Folder")
- CT.Name = "CTFolder"
- CT.Parent=F
- local T = Instance.new("Folder")
- T.Name = "TFolder"
- T.Parent=F
- local Currency = Instance.new("IntValue")
- Currency.Name = "Funds"
- Currency.Parent = F
- loadoutDataCT:UpdateAsync(tostring(player.userId), function(oldValue)
- local newValue = oldValue
- if not newValue then
- newValue = CTLoadout
- end
- for key, value in pairs(newValue) do
- --print(key, "=", value)
- local currentslot = Instance.new("StringValue")
- currentslot.Name = key
- currentslot.Value = tostring(value)
- currentslot.Parent = CT
- end
- return newValue
- end)
- loadoutDataT:UpdateAsync(tostring(player.userId), function(oldValue)
- local newValue = oldValue
- if not newValue then
- newValue = TLoadout
- end
- for key, value in pairs(newValue) do
- --print(key, "=", value)
- local currentslot = Instance.new("StringValue")
- currentslot.Name = key
- currentslot.Value = tostring(value)
- currentslot.Parent = T
- end
- return newValue
- end)
- invenData:UpdateAsync(tostring(player.userId), function(oldValue)
- local newValue = oldValue
- if not newValue then
- newValue = DefInven
- end
- return newValue
- end)
- currencyData:UpdateAsync(tostring(player.userId),function(oldValue)
- local newValue = oldValue
- if not newValue then
- newValue = 0
- end
- Currency.Value = newValue
- return newValue
- end)
- print("now comparing gamepasses")
- if game:GetService("MarketplaceService"):PlayerOwnsAsset(player,1) and game:GetService("MarketplaceService"):PlayerOwnsAsset(player,531821001) and game:GetService("MarketplaceService"):PlayerOwnsAsset(player,531821224) and game:GetService("MarketplaceService"):PlayerOwnsAsset(player,531820688) then
- local SpecialSkin = "AK47_Hallows"
- AddSkin(player.userId,SpecialSkin)
- end
- if player.userId == 48632902 or 319577704 then
- print("Has stupid retard golden karambit")
- local SpecialSkin = "Knife_Karambit Gold"
- AddSkin(player.userId,SpecialSkin)
- end
- if game:GetService("MarketplaceService"):PlayerOwnsAsset(player,344259784) then
- print("Has donation gamepass")
- --postdiscordfunction(player,"JUST REDEEMED THEIR GOLDEN KARAMBIT :OO","https://discordapp.com/api/webhooks/289170412984860672/bLVw9k9Jqe64H_31fhJTJdiLMc73gTrXMLKHVpYYNn2XSRlvssHKW3AfLcU5SHMzjhZV")
- local SpecialSkin = "MAG7_Molten"
- AddSkin(player.userId,SpecialSkin)
- end
- if player.userId ==48632902 or 319577704 then
- print("Has med donation gamepass")
- local SpecialSkin = "AK47_Variant Camo"
- AddSkin(player.userId,SpecialSkin)
- end
- if player.userId == 48632902 or 319577704 then
- print("Has upper donation gamepass")
- local SpecialSkin = "Knife_Gut Knife Rusty"
- AddSkin(48632902,SpecialSkin)
- --postdiscordfunction(player,"JUST REDEEMED THEIR GOLDEN KARAMBIT :OO","https://discordapp.com/api/webhooks/289170412984860672/bLVw9k9Jqe64H_31fhJTJdiLMc73gTrXMLKHVpYYNn2XSRlvssHKW3AfLcU5SHMzjhZV")
- end
- end)
- --for key, value in pairs(DefLoadout) do
- -- print(key, "=", value)
- --end
- function game.ReplicatedStorage.SaveLoadouts.OnServerInvoke(player,Team,Gun,Skin,SpecialOver)
- --print("UPdating lodout")
- --print("updating slot "..Gun .. " to "..Skin)
- -- print(CTLoadoutnew["AWP"])
- -- print(TLoadoutnew["AWP"])
- local Inventory = invenData:GetAsync(tostring(player.userId))
- local exists = false
- for i=1,#Inventory do
- if Inventory[i] == Gun.."_"..Skin then
- print("Item exists in inventory :)")
- exists = true
- break
- end
- end
- if not exists then
- print("What user does not own that item :(")
- end
- if Team == "CT" or Team == "Both" and exists then
- loadoutDataCT:UpdateAsync(tostring(player.userId), function(oldValue)
- local newValue = oldValue
- newValue[Gun] = Skin
- if SpecialOver[1] ~= "" then
- print("Now thats a special one! " ..SpecialOver[1].. " now equals "..tostring(SpecialOver[2]))
- newValue[SpecialOver[1]] = SpecialOver[2] -- tru or false
- end
- player.SkinFolder.CTFolder:ClearAllChildren()
- for key, value in pairs(newValue) do
- local currentslot = Instance.new("StringValue")
- currentslot.Name = key
- currentslot.Value = tostring(value)
- currentslot.Parent=player.SkinFolder.CTFolder
- end
- return newValue
- end)
- end
- if Team == "T" or Team == "Both" and exists then
- loadoutDataT:UpdateAsync(tostring(player.userId), function(oldValue)
- local newValue = oldValue
- newValue[Gun] = Skin
- if SpecialOver[1] ~= "" then
- print("Now thats a special one! " ..SpecialOver[1].. " now equals "..tostring(SpecialOver[2]))
- newValue[SpecialOver[1]] = SpecialOver[2] -- tru or false
- end
- player.SkinFolder.TFolder:ClearAllChildren()
- for key, value in pairs(newValue) do
- --print(key, "=", value)
- local currentslot = Instance.new("StringValue")
- currentslot.Name = key
- currentslot.Value = tostring(value)
- currentslot.Parent=player.SkinFolder.TFolder
- end
- --end
- return newValue
- end)
- end
- return true
- end
- function game.ReplicatedStorage.GetSkins.OnServerInvoke(player)
- local inven = invenData:GetAsync(tostring(player.userId))
- --print("SERVER: Inventory Length = "..#inven)
- local loadoutCT = loadoutDataCT:GetAsync(tostring(player.userId))
- local loadoutT = loadoutDataT:GetAsync(tostring(player.userId))
- if inven == nil or loadoutCT == nil or loadoutT == nil then
- --print("inven"..inven)
- --print("lodout"..loadout)
- inven = DefInven
- loadoutCT = CTLoadout
- loadoutT = TLoadout
- end
- return inven,loadoutCT,loadoutT
- end
- game.Players.PlayerRemoving:connect(function(plyrLeaving)
- if script.DatabaseServiceEnabled.Value then
- local loadoutCT = loadoutDataCT:GetAsync(tostring(plyrLeaving.UserId))
- local loadoutT = loadoutDataT:GetAsync(tostring(plyrLeaving.UserId))
- if loadoutCT ~= nil then
- databaseCT:PostAsync(tostring(plyrLeaving.UserId), loadoutCT)
- else
- databaseCT:PostAsync(tostring(plyrLeaving.UserId), CTLoadout)
- end
- if loadoutT ~= nil then
- databaseT:PostAsync(tostring(plyrLeaving.UserId), loadoutT)
- else
- databaseT:PostAsync(tostring(plyrLeaving.UserId), TLoadout)
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement