generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: os.time() would this work for daily bonus?

Previous Thread :: Next Thread 
xXRevengeCreeperXx is not online. xXRevengeCreeperXx
Joined: 22 Nov 2012
Total Posts: 699
15 May 2015 05:59 PM
local sc = script.Parent
local gd = sc.MainFrame.GUIData

game.Players.PlayerAdded:connect(function(player)
if math.floor(os.time()) >= t1 then
if t1 - t2 >= 1 then
gd.Cash.Value = gd.Cash.Value + 250
end
end
end)
Report Abuse
ImageLabel is not online. ImageLabel
Joined: 08 Dec 2012
Total Posts: 428
15 May 2015 06:02 PM
"t1"
Report Abuse
xXRevengeCreeperXx is not online. xXRevengeCreeperXx
Joined: 22 Nov 2012
Total Posts: 699
15 May 2015 06:04 PM
local t1 = what
I have no clue honestly?
Report Abuse
xXRevengeCreeperXx is not online. xXRevengeCreeperXx
Joined: 22 Nov 2012
Total Posts: 699
15 May 2015 06:10 PM
Idk what t1 should =
Report Abuse
MTNDewSlayer is not online. MTNDewSlayer
Joined: 19 Feb 2010
Total Posts: 45
15 May 2015 06:28 PM
Heres a snippet of my code for the daily rewards in my game. Use if if you can.

local lastOSTime = os.time() --This value should be saved, then loaded when the player joins back to allow them to join back after 24 hours and get a reward.

if lastOSTime and (os.difftime(os.time(), lastOSTime.Value)) >= 86400 then
lastOSTime = os.time()
print(Player.Name .. " has recieved a daily bonus!")
else
lastOSTime = round((86400 - os.difftime(os.time(), lastOSTime.Value))/3600, 2)
print(Player.Name .. " has not recieved a daily bonus, not enough time has passed!")
end
Report Abuse
xXRevengeCreeperXx is not online. xXRevengeCreeperXx
Joined: 22 Nov 2012
Total Posts: 699
15 May 2015 06:43 PM
what about round its not accounted for? what should it be accounted for?
Report Abuse
xXRevengeCreeperXx is not online. xXRevengeCreeperXx
Joined: 22 Nov 2012
Total Posts: 699
15 May 2015 07:00 PM
Bump
Report Abuse
MTNDewSlayer is not online. MTNDewSlayer
Joined: 19 Feb 2010
Total Posts: 45
15 May 2015 07:08 PM
Whoops, here's the round function.

function round(number, toDigits)
number = math.floor(number*10^toDigits+.5)/(10^toDigits)
return number
end
Report Abuse
xXRevengeCreeperXx is not online. xXRevengeCreeperXx
Joined: 22 Nov 2012
Total Posts: 699
15 May 2015 08:12 PM
19:12:06.263 - Players.Player.PlayerGui.Gameplay.GUIScript:255: attempt to index local 'lastOSTime' (a number value)
Report Abuse
xXRevengeCreeperXx is not online. xXRevengeCreeperXx
Joined: 22 Nov 2012
Total Posts: 699
15 May 2015 08:33 PM
Bump
Report Abuse
BattleFieldPwner is not online. BattleFieldPwner
Joined: 05 May 2013
Total Posts: 233
15 May 2015 08:37 PM
I don't understand your coding, you have t1 and t2 but you don't have what they =?

Report Abuse
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
15 May 2015 08:45 PM
local bonusDataStore = game:GetService("DataStoreService"):GetDataStore("BonusDataStore")
local timebetweenBonus = 24 -- How much time(in hours) a player must wait in-between bonuses.

-- This function is fired when the player earns an award.
-- So change it to do what you want when a player
-- Earns an award
local function giveBonus(player)
local stats = player:WaitForChild("leaderstats")
local money = stats:WaitForChild("Money")

money.Value = money.Value + 14151418418490148901840124812048129089012
end

local function playerAdded(player)
local lastJoinTime = bonusDataStore:GetAsync(player.userId)
if lastJoinTime and (os.time() - lastJoinTime) > (60 * 60) * timebetweenBonus then
giveBonus(player)
bonusDataStore:SetAsync(player.userId, os.time())
elseif lastJoinTime == nil then
bonusDataStore:SetAsync(player.userId, os.time())
end
end

game.Players.PlayerAdded:connect(playerAdded)
Report Abuse
xXRevengeCreeperXx is not online. xXRevengeCreeperXx
Joined: 22 Nov 2012
Total Posts: 699
16 May 2015 01:57 AM
Would it be possible to do a countdown clock? HH:MM:SS
Report Abuse
xXRevengeCreeperXx is not online. xXRevengeCreeperXx
Joined: 22 Nov 2012
Total Posts: 699
16 May 2015 08:45 AM
Bump
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
16 May 2015 08:49 AM
preview.
c9.
io/lunate/skyewashere/Time.mod.lua

Contains code for formatting seconds to easy to use data. Works with os.time and tick, including differences.
Report Abuse
xXRevengeCreeperXx is not online. xXRevengeCreeperXx
Joined: 22 Nov 2012
Total Posts: 699
16 May 2015 10:43 AM
Didn't understand a word you said.
Report Abuse
xXRevengeCreeperXx is not online. xXRevengeCreeperXx
Joined: 22 Nov 2012
Total Posts: 699
16 May 2015 12:17 PM
Bump
Report Abuse
xXRevengeCreeperXx is not online. xXRevengeCreeperXx
Joined: 22 Nov 2012
Total Posts: 699
16 May 2015 12:20 PM
Ok so the daily bonus is working. I just need a countdown timer with it. Any help?
Report Abuse
xXRevengeCreeperXx is not online. xXRevengeCreeperXx
Joined: 22 Nov 2012
Total Posts: 699
16 May 2015 01:57 PM
Bump
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
16 May 2015 02:17 PM
It's a url you silly cheeseball.

Copy paste the whole thing (From preview to .lua) into your url bar and look.
Report Abuse
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
16 May 2015 02:28 PM
eLunate, you're checking to see if a year is a leap year incorrectly.
Report Abuse
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
16 May 2015 02:31 PM
Imagine if some poor soul is incorrectly told the year 2100 is a leep year 85 years in the future. How would you live with yourself?
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
16 May 2015 02:32 PM
If you're about to make the smart comment about %100 and %400 I don't want to hear it.
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
16 May 2015 02:33 PM
You damned well did too.

I knew that was coming from the moment I made the script. Thanks calenders.
Report Abuse
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
16 May 2015 02:34 PM
I don't see why you don't check for that, though.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image