IronNoob

Please login or register.

Login with username, password and session length
Advanced search  

News:

Migrated to dedicated hosting. Post any weirdness you observe in the Lounge.

Author Topic: SAVETOOLSSCRIPT  (Read 164 times)

0 Members and 1 Guest are viewing this topic.

uyjulian

  • Hero Member
  • *****
  • Offline Offline
  • Posts: 1058
  • Don't call me an idiot. Atleast tellme whats wrong
    • View Profile
    • Download Chrono Trigger here
SAVETOOLSSCRIPT
« on: December 12, 2012, 03:38:01 pm »

All coded by my own, no free models :D

Code: [Select]
local mains = script.Parent
local window = mains.DPFrame
local bttn1 = window.SaveBttn
local bttn2 = window.LoadBttn
local NameOfLeaderstatToDonate = "Coins"
local BadgeService = game:GetService("BadgeService")
local VipFrame = mains.VIPFrame
local VipFrameAck = VipFrame.Frame.ex
local Utils = assert(LoadLibrary("RbxUtility"))

function waitForChild(p, c)
while not p:FindFirstChild(c) do
p.ChildAdded:wait();
end
return p[c];
end

local localplayervalue = waitForChild(mains, "LocalPlayer")
local player = localplayervalue.Value
local leaderstatss = waitForChild(player, "leaderstats")
local theleaderstat = waitForChild(leaderstatss, NameOfLeaderstatToDonate)

function ifusritm(id)
return BadgeService:UserHasBadge(player.userId, id)
end

function loadScore(plyr, clickCounter)
local score = plyr:LoadNumber("stage")
if not score == 0 then
clickCounter.Value = score
else
print("Nothing to load../..score was 0")
end
end

function SaveScore(plyr, score)
plyr:SaveNumber("stage", score)
end

function loadToolz(plyr, clickCounter)
local score = plyr:LoadString("tools")
if not score == "" then
local T = Utils.DecodeJSON(score)
local E = game:GetService("Lighting"):FindFirstChild("Inventory")
if T == nil then return end
for i=1,#T do
local lol = T[i]
local child = E:FindFirstChild(lol)
if child then
child:Clone().Parent = player.Backpack
child:Clone().Parent = player.StarterGear
end
end
else
print("Nothing to load../..score was blank")
end
end

function SaveToolz(plyr, score)
plyr:SaveString("tools", score)
end

function SpecialToolSaver()
local Tools = {}
local T = player.StarterGear:GetChildren()
for i=1,#T do
local lol = T[i]
if lol:IsA("HopperBin") or lol:IsA("Tool") then
table.insert(lol.Name,Tools)
end
end
Utils.EncodeJSON(Tools)
end

function onClicked()
player:WaitForDataReady()
if player.DataReady == true then
loadScore(player, theleaderstat)
m = Instance.new("Message",player.PlayerGui)
m.Text = NameOfLeaderstatToDonate.. " loaded!"
game:service("Debris"):AddItem(m, 3)
else
m = Instance.new("Message",player.PlayerGui)
m.Text = "Wait until DataReady!"
game:service("Debris"):AddItem(m, 3)
end
end

function onClicked1()
player:WaitForDataReady()
if player.DataReady == true then
SaveScore(player, theleaderstat.Value)
m = Instance.new("Message",player.PlayerGui)
m.Text = NameOfLeaderstatToDonate.. " saved!"
game:service("Debris"):AddItem(m, 3)
else
m = Instance.new("Message",player.PlayerGui)
m.Text = "Wait until DataReady!"
game:service("Debris"):AddItem(m, 3)
end
end

function onClickd() --VIP, SVIP, SUVIP
if ifusritm(100288988) or ifusritm(100289007) or ifusritm(100289030) then
if theleaderstat.Value <= 500 then
theleaderstat.Value = 500
end
T = game:GetService("Lighting").Inventory:GetChildren()
for i=1,#T do
if T[i]:FindFirstChild("VIP") then
if player.Backpack:FindFirstChild(T[i].Name) == nil then
T[i]:Clone().Parent = player.Backpack
T[i]:Clone().Parent = player.StarterGear
end
end
end
end
if ifusritm(100289007) or ifusritm(100289030) then
if theleaderstat.Value <= 1500 then
theleaderstat.Value = 1500
end
T = game:GetService("Lighting").Inventory:GetChildren()
for i=1,#T do
if T[i]:FindFirstChild("SVIP") then
if player.Backpack:FindFirstChild(T[i].Name) == nil then
T[i]:Clone().Parent = player.Backpack
T[i]:Clone().Parent = player.StarterGear
end
end
end
end
if ifusritm(100289030) then
if theleaderstat.Value <= 10000 then
theleaderstat.Value = 10000
end
T = game:GetService("Lighting").Inventory:GetChildren()
for i=1,#T do
if T[i]:FindFirstChild("SUVIP") then
if player.Backpack:FindFirstChild(T[i].Name) == nil then
T[i]:Clone().Parent = player.Backpack
T[i]:Clone().Parent = player.StarterGear
end
end
end
end
end

bttn1.MouseButton1Click:connect(onClicked1)
bttn2.MouseButton1Click:connect(onClicked)
VipFrameAck.MouseButton1Click:connect(onClickd)

awas3

  • Jr. Member
  • **
  • Offline Offline
  • Posts: 77
    • View Profile
Re: SAVETOOLSSCRIPT
« Reply #1 on: April 01, 2013, 09:31:48 pm »

A nice efficient piece of code. Goos job!
Logged
~A3~
 

Page created in 0.053 seconds with 22 queries.