One Game Instance
Authors: game_guy
Version: 1.0
Type: Cheating Prevention
Key Term: Misc System
IntroductionWas 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
ScreenshotsN/A
DemoN/A
ScriptPlace at very top!
#===============================================================================
# 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
InstructionsIn script.
CompatibilityWorks with everything.
XP/VX compatibility.
Credits and Thanks
- game_guy ~ For creating it.
- ZenVirZan ~ For requesting it.
Author's NotesPrevent dem hackahs! >:U
And the beauty of the script is that you can put it anywhere! :O
i think i gonna need this for my RMX-OS server. Thanks!
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 ^^
No, seriously. This is a rare script that can be put anywhere in the script editor, the order doesn't matter.
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 =)
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.
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.
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.
XD thanks for explaining ^^
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: