PlayerINIs

PlayerINIs are online .ini files, which are different for everyone in the game. PlayerINIs are linked to a username or an account. Logging in is required to access PlayerINIs.

All data in a PlayerINI can be read or edited by one person.

Replies (57)

Last message on 5 Apr 2020

Dublann on 3 Nov 2016, 21:18:40
Hi, Im trying to use these functions, but I am not able to make them work...

I want to load and save the global.oro variable each time the game is running. In a persistent object, located the main room, I have as loading the INI file:

if gms_ini_player_exists("Save","Oro")
{
global.oro=string(gms_ini_player_read("Save","Oro"))
}
else {global.oro=0}

And when the play room finish, I have in the same object as saving in the INI file:

if gms_ini_player_exists("Save","Oro")
{
gms_ini_player_delete("Save","Oro")
gms_ini_player_write("Save","Oro",string(global.oro))
}
else{gms_ini_player_write("Save","Oro",string(global.oro))}

Why is it not working?

Thanks!
amkgames on 7 Nov 2016, 19:17:01
Hey, if your game is ending right after calling save code then it will not save. You need to use alarm here.
Dublann on 7 Nov 2016, 21:33:43
mmm how would it be?

I have tried also to modify this value in the developer area to check if it is well loaded in the game, but it seem that is not loading. It returns me this value as 0.
Size43 (Administrator) on 10 Nov 2016, 12:00:14
Are you using the INI editor on the site? The INIs are heavily cached, which means it might take up to a few hours before they are synced to the site.
amkgames on 8 Nov 2016, 05:45:12
Is game being saved?
Dublann on 10 Nov 2016, 23:06:49
Is not saved neither. Maybe is because i am using the room end/room start event. Should it be included in the async cloud event or async event?
Size43 (Administrator) on 11 Nov 2016, 12:14:24
If you save right before the game ends, there might not be enough time to send the changes to the server.
Dublann on 12 Nov 2016, 20:31:59
Hi, Im not able to make it works. I explain what Im using exactly:

In obj_room_GMS, which is persistent and placed in the first room:

- In Game start and Room start I have:

if gms_ini_player_exists("Save","Oro")
{
global.oro=gms_ini_player_read("Save","Oro")
}
else {global.oro=0}

gms_highscore_self_score(1320)

- In game end and room end:

if gms_ini_player_exists("Save","Oro")
{
gms_ini_player_delete("Save","Oro")
gms_ini_player_write("Save","Oro",string(global.oro))
}
else{gms_ini_player_write("Save","Oro",string(global.oro))}

gms_highscore_add(1320,string(global.oro))

I have tried to remove them in the game end and game start and it doesnt work neither.

The highscore is already available in my game developer page with the HighscoreID 1320. Also, the player INI data is already available.

What am I doing wrong?
Size43 (Administrator) on 14 Nov 2016, 21:41:38
Does the highscore show up?

Can you try temporarily moving the save code to the step event? Does that make it work correctly?

Also note, gms_highscore_self_score on its own will do nothing. It simply returns the score of the player that's logged in. Since you're not storing that value anywhere, it doesn't do anything.
Dublann on 14 Nov 2016, 23:35:24
Hi! With the save code in the step event, it happens:

FATAL ERROR in
action number 2
of Step Event0
for object obj_room_GMS:

global variable __ini_player(100201, -2147483648) not set before reading it.
at gml_Script_XServer_ini_player_exists (line 1) - return ds_map_exists(global.__ini_player, argument0);
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Script_XServer_ini_player_exists (line 1)
called from - gml_Script_gms_ini_player_exists (line 1) - return XServer_ini_player_exists(string(argument0)+">"+string(argument1))
called from - gml_Object_obj_room_GMS_StepNormalEvent_2 (line 8) - if gms_ini_player_exists("Save","Oro")
Dublann on 18 Nov 2016, 12:35:46
Hi Size! Did you have the oportunity of checking it?

Thx for your support ????!
Size43 (Administrator) on 18 Nov 2016, 15:38:34
Hey, sorry. Seems like I missed this post.

It looks like the extension is not initializing properly. What does your login script look like?
Dublann on 18 Nov 2016, 19:37:09
Hi Size!

Im not sure what you mean with "login script". The extension is not adding to my project any script.

I have added the objects required in the "Getting started" section with the code indicated. If it helps, in the extension, the gms_login_execute, in properties it says gms_login_execute(callback_script) with argument0 double.

PS: I have removed the extension and added again because of your comment, and now it is telling me that the gms_chat_toggle and gms_logout are the GoogleMobileAds_AddBannerAt functions in the bottom area of the window of the code????
Size43 (Administrator) on 20 Nov 2016, 16:10:02
What version of GM are you using?

There's been a version of GM that broke all extensions.
Dublann on 20 Nov 2016, 17:21:58
Im using the v1.4.1757.

Which version do you recomend me?
Dublann on 21 Nov 2016, 18:16:30
Hi Size,

I have change the version of my GM to the v1.4.1657 (because I read in this website that it is not giving issues) and it is the error that appears:

for object obj_room_GMS:

Push :: Execution Error - Variable Get -5.__ini_player(100638, -2147483648)
at gml_Script_XServer_ini_player_exists (line 1) - return ds_map_exists(global.__ini_player, argument0);
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Script_XServer_ini_player_exists (line 1)
called from - gml_Script_gms_ini_player_exists (line 1) - return XServer_ini_player_exists(string(argument0)+">"+string(argument1))
called from - gml_Object_obj_room_GMS_StepNormalEvent_2 (line 8) - if gms_ini_player_exists("Save","Oro")

It seems that is not an issue of the version
Dublann on 23 Nov 2016, 21:12:51
Hi again Size :)

Sorry for being so tedious, but Im very excited about what Im making :D

I have got some progress, now I can save and load data from the server after unistalling the GM. I am finally using the v1.4.1757.

The only thing that I detected is that the website needs some time until it is updated, but the data is saved in the correct way even the website is not updated.
Size43 (Administrator) on 28 Nov 2016, 15:08:11
Yeah, the server can cache the INI data for a few hours after you've logged out before it's pushed to the server.

There's unfortunately not much that I can do about this in the current version, since updating everything immediately would flood the database with too many requests and make everything unresponsive.

I'm working on a full rewrite of GameMaker Server in which all INIs will be stored outside the database, so it will be visible on the site immediately.
Dublann on 18 Nov 2016, 12:36:37
Thx for your support!!!! (Mistake above)
BabyGolden12 on 5 Apr 2020, 04:18:54
how would i use this for player stats and stuff
Size43 (Administrator) on 5 Apr 2020, 18:24:57
They basically work as INI files (If you're not familiar with INI files you might want to look up a GameMaker tutorial on them), except that they're opened and closed automatically and will be saved on the server instead of on the computer itself.

So you can use this similar to how you would save player stats in a normal INI file, just substitute the normal ini functions with the gms_* variants.
TheRetroBoy on 11 Apr 2019, 07:18:59
Hey, problem.

If i do anything with a variable saved via INI, it'll reset to its normal value
TheRetroBoy on 11 Apr 2019, 07:01:23
Hey, problem.

If i do anything with a variable saved via INI, it'll reset to its normal value
TheRetroBoy on 11 Apr 2019, 06:59:55
Hey, problem.

If I do anything with a variable saved via INI, it'll reset back to its normal value!
Size43 (Administrator) on 24 Apr 2019, 11:51:20
TypicalAndy on 29 Sep 2018, 16:46:50
Can I draw a Ini variable like currency? if yes then how?
Size43 (Administrator) on 30 Sep 2018, 12:50:23
You can draw something in a player INI like this:

draw_text(100100gms_ini_player_read("data", "currency"))


Obviously you need to replace "data" and "currency" with the INI section and key in which you're storing the data.
TypicalAndy on 30 Sep 2018, 16:23:31
Thanks man!
TypicalAndy on 30 Aug 2018, 20:58:28
is there anyway to make a if variable with < (greater than/less than) ?
TypicalAndy on 30 Aug 2018, 21:55:23
I mean if you can make a If state with greater/less than.

like gms_ini_player_read("var","var") < 200
Size43 (Administrator) on 31 Aug 2018, 13:50:42
gms_ini_player_read just returns whatever is stored in the PlayerINI. If that's a number, then yes, you can use comparison operators like you normally use them.
Help_PW on 30 Aug 2017, 17:17:12
It works well for me, but how do i make it add value not set value?

For example
Collision with object = add +1 to the PlayerINI, not like
Collision with object = set value to 1.
Size43 (Administrator) on 4 Sep 2017, 11:39:07
You can combine reading and writing to the INI:

gms_ini_player_write("a", "b", gms_ini_player_read("a", "b") + 1)
Help_PW on 5 Sep 2017, 13:52:05
Thank you so much! :)
Vitiik on 11 Jul 2016, 09:42:24
I have problem with " image_angle = point_direction(x, y, mouse_x, mouse_y); "
Size43 (Administrator) on 25 Jul 2016, 17:14:11
Apologies for the delay. I've been working a lot in the past few weeks, at some points up to 10 hours a day. That left very little time for me to do anything besides work.

What problem are you having? Do you see an error?
SaitoZero on 5 Nov 2015, 22:34:59
Sometime I tryna view one's INI on the site, it shows me (usernam) ........... 5 (since I only saved 5 so far) but when I click the username, it shows nothing but new INIs and delete all INIs options.
How to deal with it?
Size43 (Administrator) on 15 Nov 2015, 20:32:09
Does it work properly in-game? If it does, this is most likely a caching issue. Log out, and wait +- 5 minutes, and log back in. At that point the cached INI keys will have been written to the database, and the site should be able to access them.
alibay15 on 3 Nov 2015, 19:14:26
Dear Size43 Hello
i don't know how can i create online level.
can you help me please?
Thank You
Size43 (Administrator) on 3 Nov 2015, 19:38:33
Hey,

Please elaborate on what you're trying to do. What kind of game are you making and what do you mean by "online level"?

Thanks,
Size43
alibay15 on 3 Nov 2015, 19:59:24
i am making a simple game . i mean a player level can sync with server . for example online score or money or food.
Thanks
alibay15 on 3 Nov 2015, 20:19:18
for example save a value on the server and then player sign in get the saved value on the server and show it to the player.
Size43 (Administrator) on 3 Nov 2015, 21:52:13
You can use Online INIs for this. Make sure to check out a tutorial for the normal INI files if you're not familiar with the concept. After that, you can use this to save and load values:

// Save 10 to section "my" and key "value"
gms_ini_player_write("my", "value"10)
// Load the value at section "my" and key "value"
my_value = gms_ini_player_read("my", "value")
show_message(my_value)
alibay15 on 4 Nov 2015, 13:09:04
WoW I got it and working very well
Thank You So Much Dear Size43
Aaron13ps on 1 Jul 2015, 04:25:20
Hello Size43; Once again great work on Game Maker Server.

I noticed that if you exceed the bytes per player you get this message:

"The PlayerINI data limit has been exceeded. The current limit is 4096 bytes per player. If you need more space, you can upgrade to a maximum of 65536 bytes on the GameMaker Server site."

I looked and looked and can not find a way to upgrade. I would love to give you money and support what you are doing, but I also want perks like this.

If I were to make a suggestion, there should be "upgrades" next to certain things. For this instance, when I click INI (in my game info) and then Player INIs, there should be an option SOMEWHERE that takes me to a page where i can buy upgrades.

If you do this, I will for sure buy some stuff (for the extra bytes and too support you :D)
amkgames on 17 Feb 2016, 06:09:16
Aaron13ps on 17 Feb 2016, 06:11:42
Lol this post was made so long ago. So long that I'm a moderator on here now :P
amkgames on 17 Feb 2016, 06:13:45
lol xD So did you donated him already?
Aaron13ps on 17 Feb 2016, 06:15:08
Indeed. My game is almost Greenlit on steam! Check it out on steam Greenlight by searching Project Amaranth :3
amkgames on 17 Feb 2016, 06:15:49
I would like to check it here. :P
I don't use steam.
Aaron13ps on 17 Feb 2016, 06:16:45
A ahhh ok. It's vary un-updated here (description ect.) but the link should still work
amkgames on 17 Feb 2016, 06:20:44
Wait, when did you became a mod here?
amkgames on 17 Feb 2016, 06:24:32
If you really became a mod here then you can help us when Size43 is busy. :P
amkgames on 17 Feb 2016, 06:17:27
Oh, looks cool, I will try it out later in my pc.
amkgames on 17 Feb 2016, 06:19:19
Btw, I also want to donate Size43, when I will get credit card.
tifongames on 28 Mar 2015, 12:57:09
Hi Size43, How can I delete test user accounts on the server?
On April 1st I'll release the game to the public, I'm very optimistic about it, if the game has good acceptance I'll contact you to make monthly donations for all the great work you're doing. Thank you very much.
Size43 (Administrator) on 28 Mar 2015, 13:38:37
You can delete INI keys by going to the developer-page of your game, clicking INIs and then clicking either GameINI or PlayerINI. An entire INI file or just one key can be cleared. Sections are deleted automatically.