• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GML Code to check for other instances of entire game? How to foil multiple clickers?

M

Mobie

Guest
Is there any way to write some sort of script that checks to see if there are other instances of your game running on a computer? I would like to write something that checks to see if my game is already open and playing on a computer, if it is, I like to refuse to open a second copy of my game. Sort of like "if_instance_exists" but for checking to see if the game is already running.

Here's my problem: I'm having great success with an educational game I wrote for some of the classes I teach, however, children are impatient with the opening process and click many times on my game icon because it does not open instantly. (no matter how much I tell them not to) This multiple clicking opens up multiple copies of my game and causes the whole thing to run very poorly.
 

Jakylgamer

Member
you could have a variable that when the game starts it saves to the ini file and also check if the variable is 1 game_end();


step 1: load from ini. (game start event)
step 2: check variable if 1 game_end(); (an alarm event)
step 3: on game end save variable to ini file. (game end event)

idk could work but not sure havent tested
 
E

Edmanbosch

Guest
you could have a variable that when the game starts it saves to the ini file and also check if the variable is 1 game_end();


step 1: load from ini. (game start event)
step 2: check variable if 1 game_end(); (an alarm event)
step 3: on game end save variable to ini file. (game end event)

idk could work but not sure havent tested
It would probably be better to use true and false for that instead.
 
M

Mobie

Guest
They're identical to GM.
you could have a variable that when the game starts it saves to the ini file and also check if the variable is 1 game_end();


step 1: load from ini. (game start event)
step 2: check variable if 1 game_end(); (an alarm event)
step 3: on game end save variable to ini file. (game end event)

idk could work but not sure havent tested
It would probably be better to use true and false for that instead.
So the question would be how to make that variable in the game ini accessible to other copies of the game running on the same computer. IOW, how can the second copy of the game look outside of itself and see a variable in another game?
 

TheouAegis

Member
The ini file is outside the game. You boot up the game, write to the ini file that the game is open, then if any ither copy tries to open the ini file,the value will be wrong.

The ini file may or may not need to be outside the working directory.
 
M

Mobie

Guest
The ini file is outside the game. You boot up the game, write to the ini file that the game is open, then if any ither copy tries to open the ini file,the value will be wrong.

The ini file may or may not need to be outside the working directory.
How do you tell gamemaker to write to an outside file?
 

Slyddar

Member
Look up "file system functions" and "ini files" in the help. file_exists, ini_open, ini_close, ini_write_string/real and ini_read_string/real are what you would probably need.
 
M

Mobie

Guest
Look up "file system functions" and "ini files" in the help. file_exists, ini_open, ini_close, ini_write_string/real and ini_read_string/real are what you would probably need.
Thanks so much. I'll look into that.
 
Top