Advertisement
Guest User

Untitled

a guest
Apr 18th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.94 KB | None | 0 0
  1.  
  2.  
  3. UniqueRewards = {}
  4. 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.
  5. UniqueRewards.SaveProgress = true -- when player leave, we save his progress, but only for 1 day.
  6. UniqueRewards.ChatCommand = "!chest" -- chat command to open menu
  7. UniqueRewards.CanStoleReward = false -- it must be funny, when your reward get other player :DD
  8.  
  9.  
  10.  
  11.  
  12.  
  13. UniqueRewards.RewardsTable = {}
  14. UniqueRewards.RewardsTable["LOW"] = { -- progress 0 - 10
  15. -- ["points"] = 100,
  16. -- ["points"] = 10, -- We can spam those simple items to reduce the chance of dropping a better one.
  17. -- ["points"] = 10, -- We can spam those simple items to reduce the chance of dropping a better one.
  18. -- ["points"] = 10, -- We can spam those simple items to reduce the chance of dropping a better one.
  19. -- ["points"] = 10, -- We can spam those simple items to reduce the chance of dropping a better one.
  20. -- ["points"] = 10, -- We can spam those simple items to reduce the chance of dropping a better one.
  21. -- ["points"] = 10, -- We can spam those simple items to reduce the chance of dropping a better one.
  22. -- ["points"] = 10, -- We can spam those simple items to reduce the chance of dropping a better one.
  23. -- ["points"] = 10, -- We can spam those simple items to reduce the chance of dropping a better one.
  24. -- ["points"] = 10, -- We can spam those simple items to reduce the chance of dropping a better one.
  25. -- ["points"] = 10, -- We can spam those simple items to reduce the chance of dropping a better one.
  26. -- ["pointshopitem"] = "afro",
  27. -- ["pointshopitem"] = "afro",
  28. -- ["pointshopitem"] = "afro",
  29. -- ["pointshopitem"] = "afro",
  30. -- ["pointshopitem"] = "afro",
  31. ["rpmoney"] = 5000, -- WARNING! Pls, use RPMoney only for DarkRP!!!
  32. -- ["gLevel"] = 500,
  33. -- ["karma"] = 100, -- WARNING! Pls, use karma only for TTT!!!!!!!
  34. -- ["weapon"] = "weapon_crossbow",
  35. -- ["health"] = 200,
  36. -- ["armor"] = 150,
  37. -- ["runspeed"] = 300,
  38. -- ["jumppower"] = 400
  39. }
  40. UniqueRewards.RewardsTable["MEDIUM"] = { -- progress 11 - 25
  41. -- ["points"] = 200,
  42. ["rpmoney"] = 10000,
  43. -- ["gLevel"] = 1000,
  44. -- ["health"] = 220
  45. }
  46. UniqueRewards.RewardsTable["MEDIUM2"] = { -- progress 26 - 50
  47. -- ["points"] = 300,
  48. ["rpmoney"] = 20000,
  49. -- ["gLevel"] = 2000,
  50. -- ["health"] = 250
  51. }
  52. UniqueRewards.RewardsTable["GOOD"] = { -- progress 51 - 75
  53. -- ["points"] = 400,
  54. ["rpmoney"] = 30000,
  55. -- ["gLevel"] = 3000,
  56. ["dark-rp-shipments"] = "m9k_usp",
  57. -- ["health"] = 300
  58. }
  59. UniqueRewards.RewardsTable["GOOD2"] = { -- progress 76 - 95
  60. -- ["points"] = 500,
  61. ["rpmoney"] = 40000,
  62. -- ["gLevel"] = 4000,
  63. ["dark-rp-shipments"] = "m9k_mp9",
  64. -- ["health"] = 400
  65. }
  66. UniqueRewards.RewardsTable["BEST"] = { -- progress 96 - 100
  67. -- ["points"] = 1000,
  68. ["rpmoney"] = 50000,
  69. -- ["gLevel"] = 5000,
  70. ["dark-rp-shipments"] = "m9k_spas12"
  71. -- ["health"] = 500,
  72. -- ["pointshopitem"] = "afro",
  73. -- ["pointshopitem"] = "afro",
  74. -- ["pointshopitem"] = "afro",
  75. -- ["pointshopitem"] = "afro"
  76. }
  77.  
  78.  
  79. resource.AddWorkshop("936709043")
  80. util.AddNetworkString('open_chestmenu')
  81. util.AddNetworkString('chestmenu_trydrop')
  82. util.AddNetworkString('chestmenu_saytoall')
  83.  
  84.  
  85.  
  86. ---------------------- REWARDS FUNCTION -------------
  87. ---------------------- REWARDS FUNCTION -------------
  88. ---------------------- REWARDS FUNCTION -------------
  89. local function AllMustKnowIt(text)
  90. net.Start('chestmenu_saytoall') net.WriteString(text) net.Broadcast()
  91. end
  92.  
  93. UniqueRewards.Functions = {}
  94. UniqueRewards.Functions['points'] = function(ply,count)
  95. ply:PS_GivePoints(count)
  96. --ply:ChatPrint('You gets '..tostring(count)..' points for pointshop!')
  97. AllMustKnowIt(ply:Nick()..' gets '..tostring(count)..' points for pointshop!')
  98. end
  99. UniqueRewards.Functions['pointshopitem'] = function(ply,item)
  100. ply:PS_GiveItem(item)
  101. --ply:ChatPrint('You gets '..item..' for pointshop!')
  102. AllMustKnowIt(ply:Nick()..' gets '..item..' for pointshop!')
  103. end
  104.  
  105. UniqueRewards.Functions['rpmoney'] = function(ply,int)
  106. local meta = FindMetaTable("Player")
  107. if meta.AddMoney then
  108. ply:AddMoney(int)
  109. elseif meta.addMoney then
  110. ply:addMoney(int)
  111. else
  112. ply:ChatPrint('This reward is for DarkRP only, Sorry :(') return
  113. end
  114. --ply:ChatPrint('You gets '..tostring(int)..'$ !!!')
  115. AllMustKnowIt(ply:Nick()..' gets '..tostring(int)..'$ !!!')
  116. end
  117.  
  118. UniqueRewards.Functions['karma'] = function(ply,count)
  119. local karm = ply:GetNWFloat("karma", 1000)
  120. ply:SetNWFloat("karma",karm+count)
  121. --ply:ChatPrint("Your karma is now "..tostring(karm+count).."!")
  122. AllMustKnowIt(ply:Nick().."gets karma "..tostring(karm+count).."!")
  123. end
  124.  
  125. UniqueRewards.Functions['weapon'] = function(ply,class)
  126. ply:Give(class)
  127. --ply:ChatPrint('You gets new weapon - '..class..'!')
  128. AllMustKnowIt(ply:Nick()..' gets new weapon - '..class..'!')
  129. end
  130.  
  131. UniqueRewards.Functions['health'] = function(ply,hp)
  132. ply:SetHealth(hp)
  133. --ply:ChatPrint('Your health is now '..tostring(hp)..'!')
  134. AllMustKnowIt(ply:Nick()..' gets health pack '..tostring(hp)..'!')
  135. end
  136.  
  137. UniqueRewards.Functions['armor'] = function(ply,arm)
  138. ply:SetArmor(arm)
  139. AllMustKnowIt(ply:Nick()..' gets armor pack '..tostring(arm)..'!')
  140. end
  141.  
  142. UniqueRewards.Functions['runspeed'] = function(ply,spd)
  143. ply:SetRunSpeed(spd)
  144. --ply:ChatPrint('Your speedrun is now '..tostring(spd)..'!')
  145. AllMustKnowIt(ply:Nick()..' gets speed pack '..tostring(spd)..'!')
  146. end
  147.  
  148. UniqueRewards.Functions['jumppower'] = function(ply,pwr)
  149. ply:SetJumpPower(pwr)
  150. --ply:ChatPrint('Your jump power is now '..tostring(pwr)..'!')
  151. AllMustKnowIt(ply:Nick()..' gets jump pack '..tostring(pwr)..'!')
  152. end
  153.  
  154.  
  155.  
  156.  
  157. UniqueRewards.GetRewards = function(ply,progress)
  158. if not IsValid(ply) then return end
  159.  
  160. local Prize = "LOW"
  161. if progress >=11 and progress <= 25 then
  162. Prize = "MEDIUM"
  163. elseif progress >= 26 and progress <= 50 then
  164. Prize = "MEDIUM2"
  165. elseif progress >= 51 and progress <= 75 then
  166. Prize = "GOOD"
  167. elseif progress >= 76 and progress <= 95 then
  168. Prize = "GOOD2"
  169. elseif progress >= 96 and progress <= 100 then
  170. Prize = "BEST"
  171. end
  172.  
  173. local value,funcname = table.Random(UniqueRewards.RewardsTable[Prize])
  174. UniqueRewards.Functions[funcname](ply,value)
  175. end
  176.  
  177.  
  178.  
  179.  
  180.  
  181. ------------------- TIME SECTION ------------------
  182. ------------------- TIME SECTION ------------------
  183. ------------------- TIME SECTION ------------------
  184. local function CalculateTimeForDelay(day,hours,min)
  185. local curday = (os.date("%y") - 1)*12*30 + os.date("%j")
  186. local curhours = os.date("%H")
  187. local curmin = os.date("%M")
  188. curday = tonumber(curday) curhours = tonumber(curhours) curmin = tonumber(curmin)
  189. day = tonumber(day) hours = tonumber(hours) min = tonumber(min)
  190. if curday > day then return 0 end
  191. if curday!=day then
  192. hours = hours + (23-curhours)
  193. min = min + (60-curmin)
  194. else
  195. hours = hours - curhours
  196. min = min - curmin
  197. end
  198. --local result = hours.." "..min.." "..(hours*60*60 + min * 60)
  199. local result = hours*60*60 + min * 60
  200. result = math.Clamp(result,0,180000)
  201.  
  202. return result
  203. end
  204.  
  205.  
  206. local function testfunc()
  207. local d = (os.date("%y") - 1)*12*30 + os.date("%j") +1
  208. local h =os.date("%H")
  209. local m = os.date("%M")
  210. return(CalculateTimeForDelay(d,h,m))
  211. end
  212. --local a,b = testfunc()
  213. --print(a,b)
  214.  
  215. local function SaveTimerData(ply)
  216. local today = (os.date("%y") - 1)*12*30 + os.date("%j") +1 // +1 for working
  217. local hours = os.date("%H")
  218. local minuts = os.date("%M")
  219. local savestr = today.."#"..hours.."#"..minuts
  220. ply:SetPData('nextReward',savestr)
  221. ply.NextReward = CurTime() + CalculateTimeForDelay(today,hours,minuts)
  222. end
  223.  
  224. --------- CODE FOR OUR REWARDS
  225. --------- CODE FOR OUR REWARDS
  226. --------- CODE FOR OUR REWARDS
  227.  
  228. local function SaveProgress(ply)
  229. if IsValid(ply) then
  230. local day = os.date('%d')
  231. local savestr = tostring(day).."#"..tostring(ply.RewProgress)
  232. ply:SetPData('AllLikeRewards',savestr)
  233. end
  234. end
  235.  
  236. hook.Add('PlayerDisconnected','GuysImLeave',function(ply)
  237. if IsValid(ply) then
  238. SaveProgress(ply)
  239. end
  240. end)
  241.  
  242. net.Receive('chestmenu_trydrop',function(leng,ply)
  243. if not IsValid(ply) then return end
  244. if ply.NextReward > CurTime() then ply:ChatPrint('Not now!') return end
  245. if not ply:Alive() then ply:ChatPrint('You must be alive!') return end
  246.  
  247. SaveTimerData(ply)
  248. SaveProgress(ply)
  249.  
  250. local enta = ents.Create('reward_chest')
  251. enta:SetPos(ply:GetPos()+ply:GetForward()*30+Vector(0,0,20))
  252. enta:SetAngles(ply:GetAngles())
  253. enta:Spawn()
  254. enta.ply = ply
  255. enta.Progress = ply.RewProgress
  256.  
  257. ply.RewProgress = 0
  258. end)
  259.  
  260.  
  261.  
  262. local function chatCommand( ply, text, public )
  263. if string.sub(text, 1, #UniqueRewards.ChatCommand) == UniqueRewards.ChatCommand then
  264. print('g'..ply.RewProgress)
  265. net.Start('open_chestmenu') net.WriteDouble(ply.RewProgress) net.WriteDouble(ply.NextReward) net.Send(ply)
  266. end
  267. end
  268. hook.Add( "PlayerSay", "WhereMyRewardMenu!?", chatCommand );
  269.  
  270.  
  271. hook.Add("PlayerInitialSpawn",'GuysImHere',function(ply)
  272. timer.Simple(3,function()
  273. if IsValid(ply) then
  274. local progress = ply:GetPData('AllLikeRewards',0)
  275. local loctable = string.Explode("#",progress)
  276. ply:SendLua([[notification.AddLegacy("Write ']]..UniqueRewards.ChatCommand..[[' in chat to open the menu.",3,4 )]])
  277. if loctable[1] == os.date('%d') then
  278. ply.RewProgress = tonumber(loctable[2])
  279. else
  280. ply.RewProgress = 0
  281. end
  282.  
  283. local nextrew = ply:GetPData('nextReward',0)
  284. if nextrew == 0 then SaveTimerData(ply) return end
  285. local tbl = string.Explode("#",nextrew)
  286. ply.NextReward = CurTime() + CalculateTimeForDelay(tbl[1],tbl[2],tbl[3])
  287. end
  288. end)
  289. end)
  290.  
  291.  
  292. local function GiveProgress(ply)
  293. if IsValid(ply) and ply.RewProgress != nil then
  294. ply.RewProgress = ply.RewProgress + 1
  295. if UniqueRewards.SaveProgress then
  296. SaveProgress(ply)
  297. end
  298. end
  299. end
  300.  
  301. timer.Create('AllPlayersWannaRewards',UniqueRewards.TimeDelay,0,function()
  302. for i,v in pairs(player.GetAll()) do
  303. GiveProgress(v)
  304. end
  305. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement