Advertisement
Guest User

old cb skin system

a guest
Jan 20th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.26 KB | None | 0 0
  1. --Let's begin. You can do it!
  2. branch = game.ServerScriptService.branch.Value --Last one was test21
  3. currencybranch = game.ServerScriptService.currencybranch.Value
  4. invenData = game:GetService("DataStoreService"):GetDataStore("Inventory", branch)
  5. loadoutDataCT = game:GetService("DataStoreService"):GetDataStore("LoadoutCT", branch)
  6. loadoutDataT = game:GetService("DataStoreService"):GetDataStore("LoadoutT", branch)
  7. currencyData = game:GetService("DataStoreService"):GetDataStore("Currency",currencybranch)
  8. local HTTP = game:GetService("HttpService")
  9.  
  10. local databaseService = nil
  11. local databaseCT = nil
  12. local databaseT = nil
  13. if script.DatabaseServiceEnabled.Value then
  14. databaseService = require(game:GetService("ServerScriptService").DatabaseService)
  15. databaseCT = databaseService:GetDatabase("LoadoutCT")
  16. databaseT = databaseService:GetDatabase("LoadoutT")
  17. end
  18.  
  19. function postdiscordfunction(player, msg,webhook)
  20. spawn(function()
  21. local payload = HTTP:JSONEncode({
  22. content = msg,
  23. username = player.Name.." - (#"..player.UserId..")"
  24. })
  25.  
  26. HTTP:PostAsync(webhook, payload)
  27. end)
  28. end
  29.  
  30. function AddSkin(UserId,Skin,OnlyOne)
  31. local Reward = true
  32. invenData:UpdateAsync(tostring(UserId), function(oldValue)
  33. local newValue = oldValue
  34. if not newValue then
  35. newValue = DefInven
  36. end
  37. --if OnlyOne then
  38.  
  39. for i=1, #newValue do
  40. --print("Checking ")
  41. if newValue[i] == Skin then
  42. Reward = false
  43. --print("Already exists")
  44. end
  45. end
  46. if Reward then
  47. table.insert(newValue,1,Skin)
  48.  
  49. end
  50. --end
  51. -- for key, value in pairs(newValue) do
  52. -- --print(key, "=", value)
  53. -- end
  54. --print("JOINED, Inventory length = "..#newValue)
  55. return newValue
  56. end)
  57. if Reward then
  58. local player = game.Players:GetPlayerByUserId(0)
  59. postdiscordfunction(player,"JUST REDEEMED THEIR GOLDEN KARAMBIT :OO","https://discordapp.com/api/webhooks/289170412984860672/bLVw9k9Jqe64H_31fhJTJdiLMc73gTrXMLKHVpYYNn2XSRlvssHKW3AfLcU5SHMzjhZV")
  60. end
  61. end
  62. DefInven = {
  63.  
  64. "Glock_Stock",
  65. "DualBerettas_Stock",
  66. "P250_Stock",
  67. "Tec9_Stock",
  68. "DesertEagle_Stock",
  69. "USP_Stock",
  70. "P2000_Stock",
  71. "FiveSeven_Stock",
  72.  
  73. "CZ_Stock",
  74. --R8 = "Stock",
  75.  
  76. "Galil_Stock",
  77. "AK47_Stock",
  78. "Scout_Stock",
  79. "SG_Stock",
  80. "AWP_Stock",
  81. "G3SG1_Stock",
  82.  
  83. "Famas_Stock",
  84. "M4A4_Stock",
  85. "M4A1_Stock",
  86. "AUG_Stock",
  87. "Scar_Stock",
  88.  
  89. "Nova_Stock",
  90. "XM_Stock",
  91. "MAG7_Stock",
  92. "M249_Stock",
  93. "Negev_Stock",
  94.  
  95. "SawedOff_Stock",
  96.  
  97. "MAC10_Stock",
  98. "MP9_Stock",
  99. "MP7_Stock",
  100. "UMP_Stock",
  101. "P90_Stock",
  102. "Bizon_Stock" ,
  103.  
  104. "Knife_Karambit",
  105. "Knife_Butterfly Jade Dream",
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112. }
  113.  
  114. TLoadout = {
  115. CZOver = false,
  116. R8Over = false,
  117. KnifeOver = false,
  118. --pistols
  119. Glock = "Stock",
  120. DualBerettas = "Stock",
  121. P250 = "Stock",
  122. Tec9 = "Stock",
  123. DesertEagle = "Stock",
  124. CZ = "Stock",
  125. --smgs
  126. MAC10 = "Stock",
  127. MP7 = "Stock",
  128. UMP = "Stock",
  129. P90 = "Stock",
  130. Bizon = "Stock",
  131.  
  132. Nova = "Stock",
  133. XM = "Stock",
  134. SawedOff = "Stock",
  135. M249 = "Stock",
  136. Negev = "Stock",
  137.  
  138. Galil = "Stock",
  139. AK47 = "Stock",
  140. Scout = "Stock",
  141. SG = "Stock",
  142. AWP = "Stock",
  143. G3SG1 = "Stock",
  144.  
  145. TKnife = "Stock",
  146.  
  147. R8 = "Stock",
  148. Knife = "Butterfly",
  149. }
  150. CTLoadout = {
  151. CZOver = false,
  152. R8Over = false,
  153. M4A1Over = false,
  154. USPOver = false,
  155. KnifeOver = false,
  156.  
  157. --pistols
  158. P2000 = "Stock",
  159. USP = "Stock",
  160. DualBerettas = "Stock",
  161. P250 = "Stock",
  162. FiveSeven = "Stock",
  163. DesertEagle = "Stock",
  164. CZ = "Stock",
  165. --smgs
  166. MP9 = "Stock",
  167. MP7 = "Stock",
  168. UMP = "Stock",
  169. P90 = "Stock",
  170. Bizon = "Stock",
  171.  
  172. Nova = "Stock",
  173. XM = "Stock",
  174. MAG7 = "Stock",
  175. M249 = "Stock",
  176. Negev = "Stock",
  177.  
  178. Famas = "Stock",
  179. M4A4 = "Stock",
  180. M4A1 = "Stock",
  181. Scout = "Stock",
  182. AUG = "Stock",
  183. AWP = "Stock",
  184. Scar = "Stock",
  185.  
  186. CTKnife = "Stock",
  187.  
  188. R8 = "Stock",
  189. Knife = "Butterfly",
  190.  
  191. }
  192. --DefLoadout["SHOOTYGUN"] = "Stock"
  193. --table.insert(DefLoadout,"shootygun","Stock")
  194. game.Players.PlayerAdded:connect(function(player)
  195. --If nothing exists, create it
  196. local F = Instance.new("Folder")
  197. F.Name = "SkinFolder"
  198. F.Parent=player
  199. local CT = Instance.new("Folder")
  200. CT.Name = "CTFolder"
  201. CT.Parent=F
  202. local T = Instance.new("Folder")
  203. T.Name = "TFolder"
  204. T.Parent=F
  205. local Currency = Instance.new("IntValue")
  206. Currency.Name = "Funds"
  207. Currency.Parent = F
  208. loadoutDataCT:UpdateAsync(tostring(player.userId), function(oldValue)
  209. local newValue = oldValue
  210. if not newValue then
  211. newValue = CTLoadout
  212. end
  213. for key, value in pairs(newValue) do
  214. --print(key, "=", value)
  215. local currentslot = Instance.new("StringValue")
  216. currentslot.Name = key
  217. currentslot.Value = tostring(value)
  218. currentslot.Parent = CT
  219. end
  220. return newValue
  221. end)
  222. loadoutDataT:UpdateAsync(tostring(player.userId), function(oldValue)
  223. local newValue = oldValue
  224. if not newValue then
  225. newValue = TLoadout
  226. end
  227. for key, value in pairs(newValue) do
  228. --print(key, "=", value)
  229. local currentslot = Instance.new("StringValue")
  230. currentslot.Name = key
  231. currentslot.Value = tostring(value)
  232. currentslot.Parent = T
  233. end
  234. return newValue
  235. end)
  236.  
  237.  
  238.  
  239. invenData:UpdateAsync(tostring(player.userId), function(oldValue)
  240. local newValue = oldValue
  241. if not newValue then
  242. newValue = DefInven
  243. end
  244. return newValue
  245. end)
  246. currencyData:UpdateAsync(tostring(player.userId),function(oldValue)
  247. local newValue = oldValue
  248. if not newValue then
  249. newValue = 0
  250. end
  251. Currency.Value = newValue
  252. return newValue
  253. end)
  254. print("now comparing gamepasses")
  255. 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
  256. local SpecialSkin = "AK47_Hallows"
  257. AddSkin(player.userId,SpecialSkin)
  258. end
  259. if player.userId == 48632902 or 319577704 then
  260. print("Has stupid retard golden karambit")
  261.  
  262. local SpecialSkin = "Knife_Karambit Gold"
  263.  
  264. AddSkin(player.userId,SpecialSkin)
  265.  
  266. end
  267. if game:GetService("MarketplaceService"):PlayerOwnsAsset(player,344259784) then
  268. print("Has donation gamepass")
  269. --postdiscordfunction(player,"JUST REDEEMED THEIR GOLDEN KARAMBIT :OO","https://discordapp.com/api/webhooks/289170412984860672/bLVw9k9Jqe64H_31fhJTJdiLMc73gTrXMLKHVpYYNn2XSRlvssHKW3AfLcU5SHMzjhZV")
  270. local SpecialSkin = "MAG7_Molten"
  271. AddSkin(player.userId,SpecialSkin)
  272. end
  273. if player.userId ==48632902 or 319577704 then
  274. print("Has med donation gamepass")
  275. local SpecialSkin = "AK47_Variant Camo"
  276. AddSkin(player.userId,SpecialSkin)
  277. end
  278. if player.userId == 48632902 or 319577704 then
  279. print("Has upper donation gamepass")
  280.  
  281. local SpecialSkin = "Knife_Gut Knife Rusty"
  282. AddSkin(48632902,SpecialSkin)
  283. --postdiscordfunction(player,"JUST REDEEMED THEIR GOLDEN KARAMBIT :OO","https://discordapp.com/api/webhooks/289170412984860672/bLVw9k9Jqe64H_31fhJTJdiLMc73gTrXMLKHVpYYNn2XSRlvssHKW3AfLcU5SHMzjhZV")
  284. end
  285.  
  286. end)
  287.  
  288. --for key, value in pairs(DefLoadout) do
  289. -- print(key, "=", value)
  290. --end
  291. function game.ReplicatedStorage.SaveLoadouts.OnServerInvoke(player,Team,Gun,Skin,SpecialOver)
  292. --print("UPdating lodout")
  293. --print("updating slot "..Gun .. " to "..Skin)
  294. -- print(CTLoadoutnew["AWP"])
  295. -- print(TLoadoutnew["AWP"])
  296. local Inventory = invenData:GetAsync(tostring(player.userId))
  297. local exists = false
  298.  
  299. for i=1,#Inventory do
  300. if Inventory[i] == Gun.."_"..Skin then
  301. print("Item exists in inventory :)")
  302. exists = true
  303. break
  304. end
  305. end
  306. if not exists then
  307. print("What user does not own that item :(")
  308. end
  309. if Team == "CT" or Team == "Both" and exists then
  310. loadoutDataCT:UpdateAsync(tostring(player.userId), function(oldValue)
  311. local newValue = oldValue
  312. newValue[Gun] = Skin
  313.  
  314. if SpecialOver[1] ~= "" then
  315. print("Now thats a special one! " ..SpecialOver[1].. " now equals "..tostring(SpecialOver[2]))
  316. newValue[SpecialOver[1]] = SpecialOver[2] -- tru or false
  317. end
  318. player.SkinFolder.CTFolder:ClearAllChildren()
  319. for key, value in pairs(newValue) do
  320. local currentslot = Instance.new("StringValue")
  321. currentslot.Name = key
  322. currentslot.Value = tostring(value)
  323. currentslot.Parent=player.SkinFolder.CTFolder
  324. end
  325. return newValue
  326. end)
  327. end
  328. if Team == "T" or Team == "Both" and exists then
  329. loadoutDataT:UpdateAsync(tostring(player.userId), function(oldValue)
  330. local newValue = oldValue
  331. newValue[Gun] = Skin
  332. if SpecialOver[1] ~= "" then
  333. print("Now thats a special one! " ..SpecialOver[1].. " now equals "..tostring(SpecialOver[2]))
  334. newValue[SpecialOver[1]] = SpecialOver[2] -- tru or false
  335. end
  336. player.SkinFolder.TFolder:ClearAllChildren()
  337. for key, value in pairs(newValue) do
  338. --print(key, "=", value)
  339. local currentslot = Instance.new("StringValue")
  340. currentslot.Name = key
  341. currentslot.Value = tostring(value)
  342. currentslot.Parent=player.SkinFolder.TFolder
  343. end
  344. --end
  345. return newValue
  346. end)
  347. end
  348. return true
  349. end
  350. function game.ReplicatedStorage.GetSkins.OnServerInvoke(player)
  351. local inven = invenData:GetAsync(tostring(player.userId))
  352. --print("SERVER: Inventory Length = "..#inven)
  353. local loadoutCT = loadoutDataCT:GetAsync(tostring(player.userId))
  354. local loadoutT = loadoutDataT:GetAsync(tostring(player.userId))
  355. if inven == nil or loadoutCT == nil or loadoutT == nil then
  356. --print("inven"..inven)
  357. --print("lodout"..loadout)
  358. inven = DefInven
  359. loadoutCT = CTLoadout
  360. loadoutT = TLoadout
  361.  
  362. end
  363. return inven,loadoutCT,loadoutT
  364. end
  365.  
  366. game.Players.PlayerRemoving:connect(function(plyrLeaving)
  367. if script.DatabaseServiceEnabled.Value then
  368. local loadoutCT = loadoutDataCT:GetAsync(tostring(plyrLeaving.UserId))
  369. local loadoutT = loadoutDataT:GetAsync(tostring(plyrLeaving.UserId))
  370.  
  371. if loadoutCT ~= nil then
  372. databaseCT:PostAsync(tostring(plyrLeaving.UserId), loadoutCT)
  373. else
  374. databaseCT:PostAsync(tostring(plyrLeaving.UserId), CTLoadout)
  375. end
  376. if loadoutT ~= nil then
  377. databaseT:PostAsync(tostring(plyrLeaving.UserId), loadoutT)
  378. else
  379. databaseT:PostAsync(tostring(plyrLeaving.UserId), TLoadout)
  380. end
  381. end
  382. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement