GetTickCount Shared function

From Gothic 2 Online: Wiki
Jump to navigation Jump to search

This function was added in version: 0.0.4.1

Returns the CPU time of the actual machine in milliseconds.

Syntax

unsigned getTickCount()

Returns

  • Machine time as milliseconds.

Example

local function onInitHandler() 
{     
    enableEvent_Render(true); // Switch on "onRender" event
}   

addEventHandler("onInit", onInitHandler);

local timerRender = 0;

local function onRenderHandler() 
{     
    if (timerRender < getTickCount())
    {
        local position = getPlayerPosition(heroId);
        if (getDistance2d(position.x, position.z, 0, 0) > 1000)
        {
            setPlayerPosition(heroId, 0, 0, 0);
            print("You can't leave this place!");
        }
        timerRender = getTickCount() + 50; // interval
    }
}

addEventHandler("onRender", onRenderHandler);

Related functions