A little C++ app

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
thelaptopkiller
Posts: 66
Joined: Sun 25 Oct 2009, 14:23
Location: The only place in tornado ally with no tornadoes

A little C++ app

#1 Post by thelaptopkiller »

So I have been working on a (not so)simple little program for a few days and wanted to post it here.

It is a little timer app for a online MMOG game called Roblox.

I let some kids use my computer and don't want them to stay on for 2 hours playing it.
(Don't ask why I do it)

So far it is window$ only just because the game only works on window$.
(Pity....)

I have it set as a bat script,a launcher for that bat script and the timer/roblox launcher that fires a log off script.

Here is the code I decided on for the main launcher:

Code: Select all

#include <iostream>
#include <windows.h>
#include <dos.h>
#include <unistd.h>


using namespace std;

int main()
{
cout << "========================================================";
cout << "\n=====================Warning!===========================";
cout << "\n======If you close this program you will log off!=======";
cout << "\n========================================================";
cout << "\n========================================================";
cout << "\n\nWaiting for internet to load...\n";
Sleep(10000);
cout << "Starting Roblox\n";
system("E:\\Roblox.exe");
cout << "\n\n\nYou have 30 minutes before I log you off.";
Sleep(3300000);
PlaySound("E:\\WINDOWS\\Media\\Windows XP Ringout.wav", NULL, SND_FILENAME|SND_LOOP);
PlaySound("E:\\WINDOWS\\Media\\Windows XP Ringout.wav", NULL, SND_FILENAME|SND_LOOP);
PlaySound("E:\\WINDOWS\\Media\\Windows XP Ringout.wav", NULL, SND_FILENAME|SND_LOOP);
PlaySound("E:\\WINDOWS\\Media\\Windows XP Ringout.wav", NULL, SND_FILENAME|SND_LOOP);
PlaySound("E:\\WINDOWS\\Media\\Windows XP Ringout.wav", NULL, SND_FILENAME|SND_LOOP);
Sleep(300000);
system("E:\\Log_off.bat");
}
Here is the code for the startup launcher:

Code: Select all

#include <iostream>
#include <windows.h>



using namespace std;

int main()
{
system("E:\\Startup.bat.bat");
}

Any comments?

At all?

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#2 Post by technosaurus »

It's pretty simple in Linux (or any *nix for that matter) using a script.

This should let you time any game - just save it as timedgame and call it like:

timedgame Roblox

Code: Select all

#!/bin/sh

echo "======================================"
echo "==================Warning!==============="
echo "======If you close this program you will log off!======="
echo "======================================"
echo "======================================"
echo
##############NOT REALLY DOING ANYTHING - SO COMMENTED
#echo "Waiting for internet to load..."; 
#sleep 10
##########################################

$1 &
sleep 3300
echo "You only have 5 minutes left"
aplay /usr/share/audio/2barks.wav
sleep 300
aplay /usr/share/audio/leave.wav
killall $1 
(note that you will need to be in a terminal to see the echoes ... would be better to use Xdialog, xmessage or yaf-splash etc ... this was just an example)
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

thelaptopkiller
Posts: 66
Joined: Sun 25 Oct 2009, 14:23
Location: The only place in tornado ally with no tornadoes

#3 Post by thelaptopkiller »

And THAT is why I love puppy!

bash is so much easier than C++ for sure
no chance of blowing off my foot with one letter :roll:

I can't get playsound() to play for over 20 seconds though, what's with that?

if only roblox would work in wine... :(



TLK

Post Reply