DS_MAP SAVE TO PLAYER INI

Posted by dirtycow
I have a ds_map inventory how can i save it ? in player ini and get load if the players open the game

Replies (1)

Last message on 8 Dec 2018

jdev on 8 Dec 2018, 17:34:17
Hi,

You can save your inventory data to a .ini file, given that you understand that this file can easily and intentionally be accessed and edited by the user in the file directory in which the game is installed.

You could save your ds_map to a string by doing the following:
// Store the ds_map as a string
var dsMap = ds_map_read(yourValueHere, yourValueHere);
var dsMapString = string(ds_map_read(yourValueHere, yourValueHere));
// Save to playerInventory.ini file
ini_open( 'playerInventory.ini' );
ini_write_string("Inventory", "InventoryData"string(dsMapString));
ini_close();


You should also add checks to make sure the playerInventory.ini file exists before you try to open it to make sure you or your users do not encounter any crashes or errors. Again, this is fairly easy to do:

if(file_exists("playerInventory.ini")) {
     ini_open("playerInventory.ini");
     // playerInventory.ini file exists: say we opened it!
     show_message("playerInventory.ini file opened!");
}