Jump to content

Coding for TimeLeft,


WiBox

Recommended Posts

For use as

Help please? I was trying but I don't got a idea from where i start 

outputChatBox("......., Time left:"..Time1.. "seconds.", localPlayer, 255, 255, 0)   

time which I need is 1 hour ( 3600 seconds ) I need that the time left will be 1 hour and each each 5 minutes I made it appear my only problem i need the time left to work, I don't know the basics of make how much time left... I appreciate who help.

Edited by SSKE
Link to post

You should use setTimer(), set 5 minute to execute and make a recursive algorithm with an outside counter. If the counter reach the 12 value, it means you reach the 1 hour... And you can decrease your variable in each loop and write out into the chat... 

Edited by Awang
Link to post

What I mean example:                                                                    Time left is 12300 second!

 after 2300 seconds.. 

                                                                                                            Time left is 10000 second!

that what I don't know the basics or what the command for use..

And if you can make it or make a example I'll appreciate that.

Edited by SSKE
Link to post
local Timer = 12300

function timer() 
setTimer(function()
     if Timer <= 0 then
    Timer = Timer-2300
      outputChatBox("Time is:".. Timer) 
    timer() 
     end
end, 2300,1) 
  end

Thats what you can do with setTimer() 

 

Edited by Awang
Link to post

Thanks, I'll try it, what I'm doing is a event, each 1 hour it will be auto-started, so I made every 5 minutes it will appear a message for they know which time left for the event start, i need a way to they know how much remain so the event starts. I appreciate you're help 

Link to post

Sorry for asking but can you fix this coding?

local Time1 = 3600000
function a( plr ) 
    function timer()
        setTimer(function()
            if Time1 >= 0 then
                Time1 = Time1-600000 
                    for _, in ipairs () do
                        outputChatBox("The event will start every hour once. TimeLeft:"..Time1" Seconds.", localPlayer, 0, 255, 0)
                    timer()
                    end
            end
        end, 600, 1 )
    end
    addEventHandler("onResourceStart", root, timer )       
end

 

Edited by SSKE
Link to post
35 minutes ago, SSKE said:

Sorry for asking but can you fix this coding?


local Time1 = 3600000
function a( plr ) 
    function timer()
        setTimer(function()
            if Time1 >= 0 then
                Time1 = Time1-600000 
                    for _, in ipairs () do
                        outputChatBox("The event will start every hour once. TimeLeft:"..Time1" Seconds.", localPlayer, 0, 255, 0)
                    timer()
                    end
            end
        end, 600, 1 )
    end
    addEventHandler("onResourceStart", root, timer )       
end

 

write debugscript 3 in the console panel to see your errors  and try to fix it by yourself first

Link to post

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...