Discussion: Conditional statements in BF1942
Re: Discussion: Conditional statements in BF1942
Modding templates while the round is running is a bit tricky, but doable.
-
- Posts: 590
- Joined: Mon Oct 01, 2012 3:13 pm
- Location: Canada
- Contact:
Re: Discussion: Conditional statements in BF1942
Is there any command from the game engine that returns the amount of time in seconds remaining in a round? It would make it easier to create time dependent events instead of having an admin change the time limit manually.russ wrote:Modding templates while the round is running is a bit tricky, but doable.
See my Strasbourg map project here.
Re: Discussion: Conditional statements in BF1942
Doesn't appear to be any direct way to return the elapsed or remaining time in a round. You might be able to use a timer to keep track though:
http://www.battlefieldsingleplayer.info ... leProfiler
http://www.battlefieldsingleplayer.info ... leProfiler
-
- Posts: 590
- Joined: Mon Oct 01, 2012 3:13 pm
- Location: Canada
- Contact:
Re: Discussion: Conditional statements in BF1942
I tried using some of the commands in that category but nothing seems to be happening. Maybe these commands only work with the debugger.
ConsoleProfiler.startTimer takes a string as an argument. Is that to name the timer?
I tried messing around with the Profiler commands, but nothing happens as well. Some code:
ConsoleProfiler.startTimer takes a string as an argument. Is that to name the timer?
I tried messing around with the Profiler commands, but nothing happens as well. Some code:
Code: Select all
Var v_start
var v_end
var v_inter
Const c_on = 0
Const c_off = 1
Const c_start = 0
Const c_end = 200
profiler.enable c_off
profiler.enableTimer c_start -> v_start
profiler.disableTimer c_end -> v_end
Utils.mathExprI v_end - v_start -> v_inter
if v_inter < 200
debug.debugOutputMessage "Timer on" 1
elseif v_inter > 200
debug.debugOutputMessage "Timer off" 1
endIf
See my Strasbourg map project here.
-
- Posts: 590
- Joined: Mon Oct 01, 2012 3:13 pm
- Location: Canada
- Contact:
Re: Discussion: Conditional statements in BF1942
So this only works on a local server, on an Internet server the console will output an Unknown command or method error when the script is run. Any idea why that might be?Classical Modder wrote:I fixed the problem. I can confirm that the following code works correctly:
This will output the correct message, which will be seen by everyone in the server I think (needs to be tested on an Internet server).Code: Select all
Var v_time Const c_time1 = 3600 Const c_time2 = 1800 Const c_time3 = 900 Const c_time4 = 450 admin.timelimit -> v_time if v_time < c_time4 admin.serverMessage "Test 4" elseif v_time < c_time3 admin.serverMessage "Test 3" elseif v_time < c_time2 admin.serverMessage "Test 2" elseif v_time < c_time1 admin.serverMessage "Test 1" endIf
Even better still, an admin that has in-game rights can change the time limit with an alias like !timeXX, where XX is the amount of minutes (this is how they do it on SiMPLE). In a sense, this means that events can happen in-game depending on the time that is set by the admin.
For example, an admin could set the time to under 7.5 minutes and disable all weapons except zooks and knives, for a short zook and knives round. Of course, this still has to be tested. Working on it atm.
See my Strasbourg map project here.
Re: Discussion: Conditional statements in BF1942
I did some more searching. You can start and stop timers, but the output is not consumable by scripts. There doesn't appear to be any way to get elapsed or remaining round time from within the console. It can only be obtained via the server info query port.
-
- Posts: 590
- Joined: Mon Oct 01, 2012 3:13 pm
- Location: Canada
- Contact:
Re: Discussion: Conditional statements in BF1942
Well that’s disappointing. Thanks for the information though. Out of curiosity, how would one start a timer and end it? Do you have an example of a script?russ wrote:I did some more searching. You can start and stop timers, but the output is not consumable by scripts. There doesn't appear to be any way to get elapsed or remaining round time from within the console. It can only be obtained via the server info query port.
See my Strasbourg map project here.
Re: Discussion: Conditional statements in BF1942
Code: Select all
> ConsoleProfiler.enable 1
> ConsoleProfiler.report
No profiling data available
> ConsoleProfiler.startGlobalTimer
> ConsoleProfiler.report
No profiling data available
> ConsoleProfiler.stopGlobalTimer
> ConsoleProfiler.report
Frames: 1
Seconds: 10.8271
------------------
Average fps: 0.0923611
Min fps: 0.0923611
Max fps: 0.0923611
------------------
Average ms/frame: 10827.1
Min ms/frame: 10827.1
Max ms/frame: 10827.1
------------------
Process 0: userTime/f = 0.00ms [100000000376832.00, 0.00]
, kernelTime/f = 0.00ms [999999986991104.00, 0.00]
Threads:
0 Global timer 10827.0690 ms/f, 100.0000%
0 Global timer 0.00% (sum)
-
- Posts: 590
- Joined: Mon Oct 01, 2012 3:13 pm
- Location: Canada
- Contact:
Re: Discussion: Conditional statements in BF1942
I think these commands could have an interesting use. If one would like to know, for example, how long it takes them to move their tank from their main base to one of the flags on a map in Conquest mode, these commands could be used. This is especially useful in clanwars, where every second counts.russ wrote:Note that this appears to be tied into the renderer, so on dedicated the frames value isn't valid nor are any of the values derived from it.Code: Select all
> ConsoleProfiler.enable 1 > ConsoleProfiler.report No profiling data available > ConsoleProfiler.startGlobalTimer > ConsoleProfiler.report No profiling data available > ConsoleProfiler.stopGlobalTimer > ConsoleProfiler.report Frames: 1 Seconds: 10.8271 ------------------ Average fps: 0.0923611 Min fps: 0.0923611 Max fps: 0.0923611 ------------------ Average ms/frame: 10827.1 Min ms/frame: 10827.1 Max ms/frame: 10827.1 ------------------ Process 0: userTime/f = 0.00ms [100000000376832.00, 0.00] , kernelTime/f = 0.00ms [999999986991104.00, 0.00] Threads: 0 Global timer 10827.0690 ms/f, 100.0000% 0 Global timer 0.00% (sum)
I still want to try to use this command to make a script out of it that could possibly make events happen based on the time elapsed in the Global Timer.
This is the code I previously used to try to make time-based events happen in game. It doesn't work, either because the code is faulty (most likely), or the commands involved do not return anything or are unused by the game engine.
Code: Select all
Var v_start
var v_end
var v_inter
Const c_on = 0
Const c_off = 1
Const c_start = 0
Const c_end = 200
profiler.enable c_off
profiler.enableTimer c_start -> v_start
profiler.disableTimer c_end -> v_end
Utils.mathExprI v_end - v_start -> v_inter
if v_inter < 200
debug.debugOutputMessage "Timer on" 1
elseif v_inter > 200
debug.debugOutputMessage "Timer off" 1
endIf
Code: Select all
Var v_start
var v_end
var v_inter
ConsoleProfiler.enable 1
ConsoleProfiler.report
ConsoleProfiler.startGlobalTimer -> v_start
ConsoleProfiler.stopGlobalTimer -> v_end
Utils.mathExprI v_end - v_start -> v_inter
if v_inter < 200
debug.debugOutputMessage "Timer on" 1
elseif v_inter > 200
debug.debugOutputMessage "Timer off" 1
endIf
See my Strasbourg map project here.
Re: Discussion: Conditional statements in BF1942
It returns a huge long stanza of text you'd need to parse to get the one line where it has a time. It just isn't doable.