Chaos Project

RPG Maker => RPG Maker Scripts => RMVX Ace Script Database => Topic started by: G_G on April 17, 2012, 05:32:31 pm

Title: [XP][VX][VXA] One Game Instance
Post by: G_G on April 17, 2012, 05:32:31 pm
One Game Instance
Authors: game_guy
Version: 1.0
Type: System Utility
Key Term: Misc Add-on


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

(Released awhile ago on RMRK)







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"

 if FileTest.exists?(TOKEN_FILE)
   rescue Errno::EACCES
     if !DEBUG && !$TEST
       msgbox ERROR
 $token =, "w")


In script.


Works with everything.
XP/VX/VX Ace compatibility.

Credits and Thanks

Author's Notes

Prevent dem hackahs! >:U
Title: Re: [XP][VX][VXA] One Game Instance
Post by: Kiwa on January 06, 2013, 11:07:36 am
Thanks for making this!
As im sure most ppl are aware of that have seen me here i fully intend to make an online game.
(its been a lot of work so far lol but im having fun making it and playing with all these scripts!)

Ill probably be using this and asking a ton of dumb questions in the future :P i am a terribad scripter...
Title: Re: [XP][VX][VXA] One Game Instance
Post by: Heretic86 on January 07, 2013, 02:35:25 am
Good idea!

I have one question, however.  When I test my stuff, I find that there are times that I have to use the task manager to kill the instance.  If I kill one instance of a game (say like a power outage), the file will remain the next time the game starts up, could this falsely report an instance of the game already running?
Title: Re: [XP][VX][VXA] One Game Instance
Post by: G_G on January 07, 2013, 06:49:53 am
No, because the script deletes the file if the file already exists. The script is super simple. If the file exists, delete it, then open the file and never close it. Now when the program closes, the program no longer has that file open and any other program can alter the file. Which means, next time you run the game, the game checks for the file and deletes it then re-opens it. An error will occur if the file is already open in another program.