GetTime: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
mNo edit summary
Line 10: Line 10:


==Example==
==Example==
This example adds the command ''gettime'' which outputs the game time
<section name="Client" class="client" show="true">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function currentTime()
function currentTime()
     local hour, minutes = getTime()
     local hour, minutes = getTime()
     outputChatBox( "The current time is "..hour..":"..minutes, source )
     outputChatBox( "The current time is "..hour..":"..minutes )
end
end
addCommandHandler("gettime", currentTime)
addCommandHandler("gettime", currentTime)
</syntaxhighlight>
</syntaxhighlight>
</section>


==See Also==
==See Also==

Revision as of 09:13, 5 April 2012

This function is used to get the current time in the game. If you want to get the real server time, use getRealTime.

Syntax

int int getTime ()

Returns

Returns two ints that represent hours and minutes.

Example

This example adds the command gettime which outputs the game time

Click to collapse [-]
Client
function currentTime()
    local hour, minutes = getTime()
    outputChatBox( "The current time is "..hour..":"..minutes )
end
addCommandHandler("gettime", currentTime)

See Also