Tony Brand Posted October 25, 2018 Posted October 25, 2018 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?
Dimos7 Posted October 25, 2018 Posted October 25, 2018 (edited) local Time = getRealTime() local Hour = Time.Hour local Minute = Time.Minute local payTime = Hour+Minute*60*60*1000 -- that put it on Timer 2 argument setTimer Like this Edited October 25, 2018 by Dimos7
Dimos7 Posted October 25, 2018 Posted October 25, 2018 (edited) local Time = getRealTime() local Hour = Time.Hour local payTime = Hour+60*60 -- that put it on Timer 2 argument setTimer Edited October 25, 2018 by Dimos7 1
Tony Brand Posted October 25, 2018 Author Posted October 25, 2018 (edited) 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 October 25, 2018 by Tony Brand
Dimos7 Posted October 25, 2018 Posted October 25, 2018 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) 1
Tony Brand Posted October 25, 2018 Author Posted October 25, 2018 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)
Dimos7 Posted October 26, 2018 Posted October 26, 2018 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)
N3xT Posted October 26, 2018 Posted October 26, 2018 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 )
Tony Brand Posted October 26, 2018 Author Posted October 26, 2018 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?
Dimos7 Posted October 26, 2018 Posted October 26, 2018 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 )
Insigne Posted October 29, 2018 Posted October 29, 2018 (edited) 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 October 29, 2018 by Insigne
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now