Login Register






How to Use Real Time in a Batch Application/Game filter_list
Author
Message
How to Use Real Time in a Batch Application/Game #1
I Recently made a Post about Making a Batch Game that uses Real time. I Didnt Know How i Would Use Real Time in it. I Now Have Come up with a Method of Using Real Time in a Game. For Example, You Exit the Game and Go away from your PC for a While and When you Play the Game again there are Events that may happen based on the time you werent playing the game. Something Like what happens in the PC Game Virtual Villagers.


Explanation
-------------------


What I did is I made a Test Batch Application that is Run by the User. It Has a Few Lines of text to Explain what is going to Happen and then You Press any Key to Start the test

When you start the Test, it exits and Runs bgtimer.exe that i made in batch and compiled to EXE. Its Special, because i Compiled it so it WOULD run Invisible, or In the Background. It constantly Writes the Minutes and Seconds that you Dont Have the Test Application Running to "results.bat". When bgtimer.exe starts, it Also Generates a TXT file Called "flag.txt". This is used as a "Check File". So When you Run the Test Application again, it checks for flag.txt. If it Exists, It Stops the bgtimer.exe Process then Shows the Reuslts from results.bat of How long you Werent Running the Test Application. If it Doesnt Exist, That Means that The Test Application Was Never Started. I Even Added Something to Add $5.00 to a Counter for Each Minute. Just Another Example of What you Could Do.

The Source Codes are Below or You can Download the RAR file at the Bottom of the Post Where i already Put it Together. You Will Need a BAT to EXE Compiler to Compile the bgtimer.bat to EXE.

Source for the Test Application. Leave it as a batch file.
Code:
@echo off title Background Time Test - Coded by ReaperX color 0a cls if exist flag.txt goto RESULTS echo You Get $5.00 Every Minute you wait. When you Start, This Will Close. Open this echo Up Again in a Few Minutes to See How much Money you Got and How Long You Waited. echo. echo Press any Key to Start Test... pause >nul start bgtimer.exe exit :RESULTS cls TASKKILL /F /IM bgtimer.exe /T del flag.txt cls call results.bat echo You Earned: $%money%.00 echo. echo You Waited: %min%Minutes, %sec%Seconds. del results.bat echo. pause exit


Heres the Source for the bgtimer.bat. You Need to Compile this from a Batch File to EXE. When You Do, Make Sure you Compile it as A Ghost Application. Which Means it Will Run in the Background or "Invisible".

Code:
@echo off REM Coded by ReaperX if NOT exist flag.txt ( echo. >>"flag.txt" ) set sec=0 set min=0 set money=0 :refresh set /a sec=%sec% + 1 if %sec%==60 ( set /a min=%min% + 1 set /a money=%money% + 5 set sec=0 ) echo set sec=%sec% >"results.bat" echo set min=%min% >>"results.bat" echo set money=%money% >>"results.bat" ping localhost -n 2 >nul goto refresh

Download RAR File: Download
Download Compiler: Click Here

Note: The RAR file Has bgtimer.bat Compiled and Ready along with Test Application but it isnt Compiled.

Post Comments!
(This post was last modified: 10-23-2011, 09:26 PM by doojan.)

Reply

RE: How to Use Real Time in a Batch Application/Game #2
Thanks man, will explore the whole file and learn new things Biggrin
Hack Community - My 2nd family, my best friends, my 2nd school.

====================
====================

====================
====================
====================


Latvija.

Reply

RE: How to Use Real Time in a Batch Application/Game #3
(10-24-2011, 07:05 PM)WoLF_TSC Wrote: Thanks man, will explore the whole file and learn new things Biggrin

No Problem. Let me know if you find any better improvements. :ok:

Reply

RE: How to Use Real Time in a Batch Application/Game #4
(10-24-2011, 09:39 PM)ReaperX Wrote:
(10-24-2011, 07:05 PM)WoLF_TSC Wrote: Thanks man, will explore the whole file and learn new things Biggrin

No Problem. Let me know if you find any better improvements. :ok:

Will do it Wink
Hack Community - My 2nd family, my best friends, my 2nd school.

====================
====================

====================
====================
====================


Latvija.

Reply