Jump to content

Help with RealTime


Tony Brand

Recommended Posts

hi guys
i want to make a payday system that get time from RealTime
for example if VPS time is 13:00 then resource Sends a message to all players "You Recived your Payday"
but my problem is i can't understand how to do this with getRealTime and add an hourly timer too it,may any help?

Link to comment
function Payday()
local Hour = Time.Hour
local Minute = Time.Minute
local payTime = Hour+60*60


D = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24]
 for Hour in ipairs(D) do
  outputChatBox("Your Payday Is Here")
  setTimer(payTime)
 end
end
addEventHandler(OnResourceStart,root)

do you mean something like this?@Dimos7

Edited by Tony Brand
Link to comment
function Payday()
local Hour = Time.Hour
local payTime = Hour+60*60


D = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24]
 for _,Hour in ipairs(D) do
  outputChatBox("Your Payday Is Here")
  setTimer(payday,payTime, 1)
 end
end
addEventHandler("onResourceStart",root, payday)

 

  • Thanks 1
Link to comment

Error in Line4: attempt to perform arithmetic on local 'Hour' (a nil value)

 

function Payday()
    local Time = getRealTime() 
    local Hour = Time.Hour
    local payTime = (Hour+60)*60
    
    
    D = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24}
     for _,Hour in ipairs(D) do
      outputChatBox("Your Payday Is Here")
      setTimer(payday,payTime, 1)
     end
    end
    addEventHandler("onResourceStart",root, Payday)

 

Link to comment
function Payday()
    local time = getRealTime() 
    local hour = time.hour
    local payTime = (hour+60)*60
    
    
    D = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24}
     for _,hour in ipairs(D) do
      outputChatBox("Your Payday Is Here")
      setTimer(payday,payTime, 1)
     end
    end
    addEventHandler("onResourceStart",root, Payday)

 

Link to comment
setTimer ( function ( )
	local time = getRealTime ( )
	local hours = time.hour
	local minutes = time.minute
	local seconds = time.second
	if ( hours == 13 and minutes == 0 and seconds == 0 ) then
		outputChatBox ( "", root, 255, 255, 255, true )
	end
end, 1000, 0 )

 

Link to comment
38 minutes ago, N3xT said:

setTimer ( function ( )
	local time = getRealTime ( )
	local hours = time.hour
	local minutes = time.minute
	local seconds = time.second
	if ( hours == 13 and minutes == 0 and seconds == 0 ) then
		outputChatBox ( "", root, 255, 255, 255, true )
	end
end, 1000, 0 )

 

i need to use an event that checks time every second ,then if find 1:00 2:00 3:00 4:00 5:00 ... 23:00 00:00 for time,give a payday and start a hour timer,may better help?

Link to comment
setTimer ( function ( )
	local time = getRealTime ()
	local hours = time.hour
	local minutes = time.minute
	local seconds = time.second
    local D ={1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23} 
    for _, hour in ipairs(D) do
         if hours == hour and minutes == 0 and seconds == 0 then
        outputChatBox("", root, 255, 255, 255, true) 
        end 
	end 
end, 1000, 0 )

 

Link to comment

realTime function.

function getRealTimeForIPB(time)
    local time = getRealTime(time)
    local str = ""
    if (time.hour < 10) then
        str = "0"..time.hour
    else
        str = time.hour
    end
    if (time.minute < 10) then
        str = str..":0"..time.minute
    else
        str = str..":"..time.minute
    end
    if (time.second < 10) then
        str = str..":0"..time.second
    else
        str = str..":"..time.second
    end
    return str
end

 

Edited by Insigne
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...