Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Wed 26 Nov 2014, 12:17
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
A little C++ app
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
Page 1 of 1 Posts_count  
Author Message
thelaptopkiller

Joined: 25 Oct 2009
Posts: 67
Location: The only place in tornado ally with no tornadoes

PostPosted: Fri 03 Dec 2010, 14:51    Post_subject:  A little C++ app
Sub_title: For games and computer usage
 

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:
#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:
#include <iostream>
#include <windows.h>



using namespace std;

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



Any comments?

At all?
Back to top
View user's profile Send_private_message 
technosaurus


Joined: 18 May 2008
Posts: 4379

PostPosted: Sun 05 Dec 2010, 02:27    Post_subject:  

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:
#!/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)

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send_private_message 
thelaptopkiller

Joined: 25 Oct 2009
Posts: 67
Location: The only place in tornado ally with no tornadoes

PostPosted: Fri 10 Dec 2010, 18:50    Post_subject:  

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 Rolling Eyes

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

if only roblox would work in wine... Sad



TLK
Back to top
View user's profile Send_private_message 
Display_posts:   Sort by:   
Page 1 of 1 Posts_count  
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Off-Topic Area » Programming
Jump to:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0527s ][ Queries: 12 (0.0072s) ][ GZIP on ]