[XP][VX] One Game Instance

Started by G_G, August 04, 2011, 08:52:05 am

Previous topic - Next topic

G_G

August 04, 2011, 08:52:05 am Last Edit: February 29, 2012, 12:10:20 am by game_guy
One Game Instance
Authors: game_guy
Version: 1.0
Type: Cheating Prevention
Key Term: Misc System



Introduction

Was reading this thread. http://www.hbgames.org/forums/viewtopic.php?f=12&t=74963&start=0 The guy who resolved it made it way overcomplicated. I decided to make a smaller more compact version.

This script is to prevent multiple instances of your game. This is really only for online games so players can't cheat.


Features


  • Prevents Multiple Instances

  • Custom File/Error

  • XP/VX Compatible




Screenshots

N/A


Demo

N/A


Script

Place at very top!
Spoiler: ShowHide

#===============================================================================
# One Game Instance
# Version 1.0
# Author game_guy
#-------------------------------------------------------------------------------
# Intro:
# Prevents players from opening multiple instances of your games.
#
# Features:
# Prevents Multiple Instances
# Custom File/Error
# XP/VX Compatible
#
# Instructions:
# Place as first script.
# Configure the 2 variables and thats all!
#
# Compatibility:
# Works with everything.
#
# Credits:
# game_guy ~ For creating it.
# ZenVirZan ~ For requesting it.
#===============================================================================

# Custom error message.
ERROR = "Instance already running."
# Custom file name, I'd recommend leaving the ENV[Appdata]
TOKEN_FILE = ENV['APPDATA'] + "game_name.token"

begin
 if FileTest.exists?(TOKEN_FILE)
   begin
     File.delete(TOKEN_FILE)
   rescue Errno::EACCES
     if !DEBUG && !$TEST
       print ERROR
       exit
     end
   end
 end
 $token = File.open(TOKEN_FILE, "w")
end



Instructions

In script.


Compatibility

Works with everything.
XP/VX compatibility.


Credits and Thanks


  • game_guy ~ For creating it.

  • ZenVirZan ~ For requesting it.




Author's Notes

Prevent dem hackahs! >:U

Blizzard

And the beauty of the script is that you can put it anywhere! :O
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

GamerGeeks

i think i gonna need this for my RMX-OS server. Thanks!

Apidcloud

Quote from: Blizzard on August 04, 2011, 10:52:36 am
And the beauty of the script is that you can put it anywhere! :O


Roflmao  :O.o:  :facepalm:  :uhm:

Great snippet g_g ^^
Instead of wanting to be somebody else, rather become somebody else



"I will treasure the knowledge like a squirrel treasures acorns."


Gibbo Glast 2D Engine - The sky is no longer a limit

Blizzard

No, seriously. This is a rare script that can be put anywhere in the script editor, the order doesn't matter.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Apidcloud

August 21, 2011, 11:38:51 am #5 Last Edit: August 21, 2011, 11:50:38 am by Apidcloud
lol, if it doesn't need any class that is on the editor, it can be used in everywhere(as you said previously) xD

A great script really =)
Instead of wanting to be somebody else, rather become somebody else



"I will treasure the knowledge like a squirrel treasures acorns."


Gibbo Glast 2D Engine - The sky is no longer a limit

G_G

Thanks guys. :3 I don't think it can be placed under main though. It'll start the loop before it'll reach the script. Then when the loop ends it'll make a derp moment.

Apidcloud

I think you're entirely correct.
I ever heard that scripts under main won't work, although, as your script only uses 'begin' I think it won't be a problem even if it is placed under main.
Instead of wanting to be somebody else, rather become somebody else



"I will treasure the knowledge like a squirrel treasures acorns."


Gibbo Glast 2D Engine - The sky is no longer a limit

G_G

It would be a problem. Main is a loop. When the game is ran, it loads scripts from top to bottom so its going to hit main before mine. When it hits main, it loops and updates $scene until it becomes nil. After that it would then hit  my script, then close. Thats what happens to any script put below main.

Apidcloud

Instead of wanting to be somebody else, rather become somebody else



"I will treasure the knowledge like a squirrel treasures acorns."


Gibbo Glast 2D Engine - The sky is no longer a limit

Blizzard

August 21, 2011, 01:39:27 pm #10 Last Edit: August 21, 2011, 01:42:35 pm by Blizzard
Scripts under main are run when you do a clean game exit (that means no "exit", no ALT+F4 and no pressing the X to close the window). Obviously you can put it wherever you want above main. :roll:
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.