RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[XP][VX] One Game Instance

0 Members and 1 Guest are viewing this topic.

***
Rep:
Level 84
Yes, hoh my gawd!
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.

(I'll just keep one topic here instead of posting multiple topics as the script works in both XP and VX without modifications)

Features

  • Prevents Multiple Instances
  • Custom File/Error
  • XP/VX Compatible

Screenshots

N/A

Demo

N/A

Script

Place at very top!
Spoiler for:
Code: [Select]
#===============================================================================
# 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 == false || $DEBUG == nil || $TEST == false || $TEST == nil
        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

*
Rep:
Level 82
GIAW 14: 1st Place (Easy Mode)2013 Project of the Year2013 Best RPG Maker User (Programming)2013 Most Promising ProjectParticipant - GIAW 11Bronze - GIAW 10
Although there is a wide path around this protection because of its simplicity, I really like the quick and easy to implement nature of the script. This would put a stop to most casual attempts at exploiting multiple instances. Good work!

UPDATED 05-29-14


IS YOUR PROJECT OPTIMIZED?
UPDATED 07/04/15 - v2.5

RPG MAKER TOOLBOX
UPDATED 07/04/15 - v1.5