Jump to content

Время на сервере.


Recommended Posts

Спасибо, Kernell. Все получилось. На WIKI нашелся отличный пример.

Проверку по таймеру так сделать надо было?:

function resourceStart() 
    local realtime = getRealTime() 
    setTime(realtime.hour, realtime.minute) 
    setMinuteDuration(60000) 
    setTimer(resourceStart,61*1000,0) 
end 
addEventHandler ("onResourceStart",resourceRoot,resourceStart) 

Link to comment

Flaker,

в твоём коде нет проверки. Вот что я имел ввиду:

local function TimeUpdate() 
    local tReal = getRealTime(); 
    local tGameHour, tGameMins = getTime(); 
     
    if tGameHour ~= tReal.hour or tGameMins ~= tReal.minute then 
        setTime( tReal.hour, tReal.minute ); -- при частом использовании setTime, мир будет "дёргаться", поэтому лучше сделать такую проверочку. 
    end 
end 
  
setMinuteDuration( 60000 ); 
  
setTimer( TimeUpdate, 5000, 0 ); 

И ставить таймер на 61000 мс слишком много, время может легко сбиться :)

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