Login x
User Name:
Password:
Social Links Facebook Twitter YouTube Steam RSS News Feeds

Members Online

»
0 Active | 102 Guests
Online:

LATEST FORUM THREADS

»
CoD: Battle Royale
CoD+UO Map + Mod Releases
Damaged .pk3's
CoD Mapping
heli to attack ai
CoD4 SP Mapping

Tutorials

»
OFP2
ratings:
Awful Rating
Poor Rating
Average Rating
Good Rating
Excellent Rating
Adding a clock/watch function to your games
Versions: You must be logged in to view history.

Adding time display to system message window

I wrote this because I needed to have players
reach an objective by a certain time to observe
some event that I was planning.

--[[
=================================================
***Display the Current Time***
Ron "Ronbocop" Carroll
=================================================
I wrote this because I needed to have players
reach an objective by a certain time to observe
some event that I was planning.
I couldn't find any reference to display the
time except for the mission time, which doesn't
help players to know that they are 23mins into
the game after an arbitrary mission start time
of 11:45 in the morning, especially since my
mates just skip the whole menu thing to get into
the game. This game also does not have a watch
a la ARMA either.
To do this I had to get the script to know
what time it was at the start of the mission.
This is the time that is set up in the Mission
Properties area under Environment, Date & Time.
In my case this was 2009/12/05 21:03 (my team
having landed on site around 21:00 and having
unloaded the ingress boat of a cache of weapons.

IMPORTANT: If you decide to change your mission
start time, do not forget to change the
"CurrentTime" parameter to match

IMPORTANT: Remember that onTimer is one of the
few commands that does not have an underscore,
"_" to separate the function-type from the
function-name.

You can call the displayCurrentTime()
function at any point you wish, ie, after
destroying an objective, retrieving some intel
or whatever. It will not interfere with you
minute by minute update.

Hope this fleshes out your missions &
campaigns. Enjoy
=================================================
]]
function onMissionStart()
--Display Current Mission Time
displayCurrentTime()

--Call routine to Display Current Time
--again after a minute
OFP:addTimer("DisplayTime",60000) --60x1000msec
end


--Display the CurrentTime
function displayCurrentTime()
--Mission time at start = 0
--21x60 mins per hour x60 secs per minute x1000msec
--to give 21:00hrs or 9pm +
--3x60 secs per minute x1000msec
--to give xx:03mins
CurrentTime = OFP:getMissionTime() + (21*60*60*1000) + (3*60*1000)
--Format for obtaining readable time from a calculated
--number in millisecongds
Hours, Minutes, Seconds = OFP:convertTimeToHMS(CurrentTime)
--Since 21:3:0 does not look like readable time you
--need to inflate or insert a zero into the text
if Minutes < 10 then
Minutes = "0" .. Minutes
end
if Seconds < 10 then
Seconds = "0" .. Seconds
end
--The "double full stops" is Lua's concatenate function
--The result will be a message in the bottom left corner
--ie "The Current Time is:- 21:03:00"
OFP:displaySystemMessage("Current Time is:- " .. Hours .. ":" .. Minutes .. ":" .. Seconds) -- remove the space before display
end

--Call the time every minute
function onTimerDisplayTime()
--[[You may delete the DisplayTime() timer here if you
wish as per normal but I haven't had a problem with it.]]
--OFP:removeTimer()

--Call the displayCurrentTime() function again
displayCurrentTime()
--Initiate this timer again to run 1min later
OFP:setTimer("DisplayTime",60000)
end

Latest Syndicated News

»
Codutility.com up and runn...
Nice, and there still using the logo and template for the screenshots, which...
Codutility.com up and runn...
dundy writes...Quote:Call of Duty modding and mapping is barly alive only a ...
Codutility.com up and runn...
Mystic writes...Quote:It seems to me the like the site is completely dead? ...
Codutility.com up and runn...
It seems to me the like the site is completely dead?

Partners & Friends

»