RU/setMinuteDuration

From Multi Theft Auto: Wiki
Revision as of 09:16, 8 March 2010 by PoliticalOrel (talk | contribs)
Jump to navigation Jump to search

Устанавливает продолжительность минуты в игре. В GTA изначально равна 1000.

Использование

bool setMinuteDuration ( int milliseconds )

Необходимые параметры

  • milliseconds: новая продолжительность игровой минуты.

Что возвращается

Возвращается true, если изменение успешно произошло, или false, если изменение не произошло.

Пример

This example will make the ingame time correspond to the real-world time of the server.

Click to collapse [-]
Сервер
function syncRealTime(player)
    -- get the current real time and send it to the player
    local realtime = getRealTime()
    triggerClientEvent(player, "doSyncRealTime", getRootElement(), realtime.hour, realtime.minute)
end

function resourceStart()
    -- when the resource starts, send the real time to all players currently in the server
    local players = getElementsByType("player")
    for i,player in ipairs(players) do
        syncRealTime(player)
    end
end
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), resourceStart)

function playerJoin()
    -- send the real time to joining players
    syncRealTime(source)
end
addEventHandler("onPlayerJoin", getRootElement(), playerJoin)
Click to collapse [-]
Client
function syncRealTime(h, m)
    -- set the ingame time
    setTime(h, m)
    -- make ingame time progress at the same rate as real time (60 seconds per minute)
    setMinuteDuration(60000)
end
-- attach the above function to the doSyncRealTime event
addEvent("doSyncRealTime", true)
addEventHandler("doSyncRealTime", getRootElement(), syncRealTime)

Смотри также