Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- UniqueRewards = {}
- UniqueRewards.TimeDelay = 180 -- every 180 sec all players get 1 progress point. Player must play 18000 sec (5 hours) in 1 day, for get 100% of progress.
- UniqueRewards.SaveProgress = true -- when player leave, we save his progress, but only for 1 day.
- UniqueRewards.ChatCommand = "!chest" -- chat command to open menu
- UniqueRewards.CanStoleReward = false -- it must be funny, when your reward get other player :DD
- UniqueRewards.RewardsTable = {}
- UniqueRewards.RewardsTable["LOW"] = { -- progress 0 - 10
- -- ["points"] = 100,
- -- ["points"] = 10, -- We can spam those simple items to reduce the chance of dropping a better one.
- -- ["points"] = 10, -- We can spam those simple items to reduce the chance of dropping a better one.
- -- ["points"] = 10, -- We can spam those simple items to reduce the chance of dropping a better one.
- -- ["points"] = 10, -- We can spam those simple items to reduce the chance of dropping a better one.
- -- ["points"] = 10, -- We can spam those simple items to reduce the chance of dropping a better one.
- -- ["points"] = 10, -- We can spam those simple items to reduce the chance of dropping a better one.
- -- ["points"] = 10, -- We can spam those simple items to reduce the chance of dropping a better one.
- -- ["points"] = 10, -- We can spam those simple items to reduce the chance of dropping a better one.
- -- ["points"] = 10, -- We can spam those simple items to reduce the chance of dropping a better one.
- -- ["points"] = 10, -- We can spam those simple items to reduce the chance of dropping a better one.
- -- ["pointshopitem"] = "afro",
- -- ["pointshopitem"] = "afro",
- -- ["pointshopitem"] = "afro",
- -- ["pointshopitem"] = "afro",
- -- ["pointshopitem"] = "afro",
- ["rpmoney"] = 5000, -- WARNING! Pls, use RPMoney only for DarkRP!!!
- -- ["gLevel"] = 500,
- -- ["karma"] = 100, -- WARNING! Pls, use karma only for TTT!!!!!!!
- -- ["weapon"] = "weapon_crossbow",
- -- ["health"] = 200,
- -- ["armor"] = 150,
- -- ["runspeed"] = 300,
- -- ["jumppower"] = 400
- }
- UniqueRewards.RewardsTable["MEDIUM"] = { -- progress 11 - 25
- -- ["points"] = 200,
- ["rpmoney"] = 10000,
- -- ["gLevel"] = 1000,
- -- ["health"] = 220
- }
- UniqueRewards.RewardsTable["MEDIUM2"] = { -- progress 26 - 50
- -- ["points"] = 300,
- ["rpmoney"] = 20000,
- -- ["gLevel"] = 2000,
- -- ["health"] = 250
- }
- UniqueRewards.RewardsTable["GOOD"] = { -- progress 51 - 75
- -- ["points"] = 400,
- ["rpmoney"] = 30000,
- -- ["gLevel"] = 3000,
- ["dark-rp-shipments"] = "m9k_usp",
- -- ["health"] = 300
- }
- UniqueRewards.RewardsTable["GOOD2"] = { -- progress 76 - 95
- -- ["points"] = 500,
- ["rpmoney"] = 40000,
- -- ["gLevel"] = 4000,
- ["dark-rp-shipments"] = "m9k_mp9",
- -- ["health"] = 400
- }
- UniqueRewards.RewardsTable["BEST"] = { -- progress 96 - 100
- -- ["points"] = 1000,
- ["rpmoney"] = 50000,
- -- ["gLevel"] = 5000,
- ["dark-rp-shipments"] = "m9k_spas12"
- -- ["health"] = 500,
- -- ["pointshopitem"] = "afro",
- -- ["pointshopitem"] = "afro",
- -- ["pointshopitem"] = "afro",
- -- ["pointshopitem"] = "afro"
- }
- resource.AddWorkshop("936709043")
- util.AddNetworkString('open_chestmenu')
- util.AddNetworkString('chestmenu_trydrop')
- util.AddNetworkString('chestmenu_saytoall')
- ---------------------- REWARDS FUNCTION -------------
- ---------------------- REWARDS FUNCTION -------------
- ---------------------- REWARDS FUNCTION -------------
- local function AllMustKnowIt(text)
- net.Start('chestmenu_saytoall') net.WriteString(text) net.Broadcast()
- end
- UniqueRewards.Functions = {}
- UniqueRewards.Functions['points'] = function(ply,count)
- ply:PS_GivePoints(count)
- --ply:ChatPrint('You gets '..tostring(count)..' points for pointshop!')
- AllMustKnowIt(ply:Nick()..' gets '..tostring(count)..' points for pointshop!')
- end
- UniqueRewards.Functions['pointshopitem'] = function(ply,item)
- ply:PS_GiveItem(item)
- --ply:ChatPrint('You gets '..item..' for pointshop!')
- AllMustKnowIt(ply:Nick()..' gets '..item..' for pointshop!')
- end
- UniqueRewards.Functions['rpmoney'] = function(ply,int)
- local meta = FindMetaTable("Player")
- if meta.AddMoney then
- ply:AddMoney(int)
- elseif meta.addMoney then
- ply:addMoney(int)
- else
- ply:ChatPrint('This reward is for DarkRP only, Sorry :(') return
- end
- --ply:ChatPrint('You gets '..tostring(int)..'$ !!!')
- AllMustKnowIt(ply:Nick()..' gets '..tostring(int)..'$ !!!')
- end
- UniqueRewards.Functions['karma'] = function(ply,count)
- local karm = ply:GetNWFloat("karma", 1000)
- ply:SetNWFloat("karma",karm+count)
- --ply:ChatPrint("Your karma is now "..tostring(karm+count).."!")
- AllMustKnowIt(ply:Nick().."gets karma "..tostring(karm+count).."!")
- end
- UniqueRewards.Functions['weapon'] = function(ply,class)
- ply:Give(class)
- --ply:ChatPrint('You gets new weapon - '..class..'!')
- AllMustKnowIt(ply:Nick()..' gets new weapon - '..class..'!')
- end
- UniqueRewards.Functions['health'] = function(ply,hp)
- ply:SetHealth(hp)
- --ply:ChatPrint('Your health is now '..tostring(hp)..'!')
- AllMustKnowIt(ply:Nick()..' gets health pack '..tostring(hp)..'!')
- end
- UniqueRewards.Functions['armor'] = function(ply,arm)
- ply:SetArmor(arm)
- AllMustKnowIt(ply:Nick()..' gets armor pack '..tostring(arm)..'!')
- end
- UniqueRewards.Functions['runspeed'] = function(ply,spd)
- ply:SetRunSpeed(spd)
- --ply:ChatPrint('Your speedrun is now '..tostring(spd)..'!')
- AllMustKnowIt(ply:Nick()..' gets speed pack '..tostring(spd)..'!')
- end
- UniqueRewards.Functions['jumppower'] = function(ply,pwr)
- ply:SetJumpPower(pwr)
- --ply:ChatPrint('Your jump power is now '..tostring(pwr)..'!')
- AllMustKnowIt(ply:Nick()..' gets jump pack '..tostring(pwr)..'!')
- end
- UniqueRewards.GetRewards = function(ply,progress)
- if not IsValid(ply) then return end
- local Prize = "LOW"
- if progress >=11 and progress <= 25 then
- Prize = "MEDIUM"
- elseif progress >= 26 and progress <= 50 then
- Prize = "MEDIUM2"
- elseif progress >= 51 and progress <= 75 then
- Prize = "GOOD"
- elseif progress >= 76 and progress <= 95 then
- Prize = "GOOD2"
- elseif progress >= 96 and progress <= 100 then
- Prize = "BEST"
- end
- local value,funcname = table.Random(UniqueRewards.RewardsTable[Prize])
- UniqueRewards.Functions[funcname](ply,value)
- end
- ------------------- TIME SECTION ------------------
- ------------------- TIME SECTION ------------------
- ------------------- TIME SECTION ------------------
- local function CalculateTimeForDelay(day,hours,min)
- local curday = (os.date("%y") - 1)*12*30 + os.date("%j")
- local curhours = os.date("%H")
- local curmin = os.date("%M")
- curday = tonumber(curday) curhours = tonumber(curhours) curmin = tonumber(curmin)
- day = tonumber(day) hours = tonumber(hours) min = tonumber(min)
- if curday > day then return 0 end
- if curday!=day then
- hours = hours + (23-curhours)
- min = min + (60-curmin)
- else
- hours = hours - curhours
- min = min - curmin
- end
- --local result = hours.." "..min.." "..(hours*60*60 + min * 60)
- local result = hours*60*60 + min * 60
- result = math.Clamp(result,0,180000)
- return result
- end
- local function testfunc()
- local d = (os.date("%y") - 1)*12*30 + os.date("%j") +1
- local h =os.date("%H")
- local m = os.date("%M")
- return(CalculateTimeForDelay(d,h,m))
- end
- --local a,b = testfunc()
- --print(a,b)
- local function SaveTimerData(ply)
- local today = (os.date("%y") - 1)*12*30 + os.date("%j") +1 // +1 for working
- local hours = os.date("%H")
- local minuts = os.date("%M")
- local savestr = today.."#"..hours.."#"..minuts
- ply:SetPData('nextReward',savestr)
- ply.NextReward = CurTime() + CalculateTimeForDelay(today,hours,minuts)
- end
- --------- CODE FOR OUR REWARDS
- --------- CODE FOR OUR REWARDS
- --------- CODE FOR OUR REWARDS
- local function SaveProgress(ply)
- if IsValid(ply) then
- local day = os.date('%d')
- local savestr = tostring(day).."#"..tostring(ply.RewProgress)
- ply:SetPData('AllLikeRewards',savestr)
- end
- end
- hook.Add('PlayerDisconnected','GuysImLeave',function(ply)
- if IsValid(ply) then
- SaveProgress(ply)
- end
- end)
- net.Receive('chestmenu_trydrop',function(leng,ply)
- if not IsValid(ply) then return end
- if ply.NextReward > CurTime() then ply:ChatPrint('Not now!') return end
- if not ply:Alive() then ply:ChatPrint('You must be alive!') return end
- SaveTimerData(ply)
- SaveProgress(ply)
- local enta = ents.Create('reward_chest')
- enta:SetPos(ply:GetPos()+ply:GetForward()*30+Vector(0,0,20))
- enta:SetAngles(ply:GetAngles())
- enta:Spawn()
- enta.ply = ply
- enta.Progress = ply.RewProgress
- ply.RewProgress = 0
- end)
- local function chatCommand( ply, text, public )
- if string.sub(text, 1, #UniqueRewards.ChatCommand) == UniqueRewards.ChatCommand then
- print('g'..ply.RewProgress)
- net.Start('open_chestmenu') net.WriteDouble(ply.RewProgress) net.WriteDouble(ply.NextReward) net.Send(ply)
- end
- end
- hook.Add( "PlayerSay", "WhereMyRewardMenu!?", chatCommand );
- hook.Add("PlayerInitialSpawn",'GuysImHere',function(ply)
- timer.Simple(3,function()
- if IsValid(ply) then
- local progress = ply:GetPData('AllLikeRewards',0)
- local loctable = string.Explode("#",progress)
- ply:SendLua([[notification.AddLegacy("Write ']]..UniqueRewards.ChatCommand..[[' in chat to open the menu.",3,4 )]])
- if loctable[1] == os.date('%d') then
- ply.RewProgress = tonumber(loctable[2])
- else
- ply.RewProgress = 0
- end
- local nextrew = ply:GetPData('nextReward',0)
- if nextrew == 0 then SaveTimerData(ply) return end
- local tbl = string.Explode("#",nextrew)
- ply.NextReward = CurTime() + CalculateTimeForDelay(tbl[1],tbl[2],tbl[3])
- end
- end)
- end)
- local function GiveProgress(ply)
- if IsValid(ply) and ply.RewProgress != nil then
- ply.RewProgress = ply.RewProgress + 1
- if UniqueRewards.SaveProgress then
- SaveProgress(ply)
- end
- end
- end
- timer.Create('AllPlayersWannaRewards',UniqueRewards.TimeDelay,0,function()
- for i,v in pairs(player.GetAll()) do
- GiveProgress(v)
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement