Deleting save file after player dies (permadeath)

Just like in Roguelikes, id like to have a permadeath system. I found one permadeath plugin, but the problem is, after death, player could still just load the game from the last save point, which defeats the whole purpose.

would it be possible to also delete the save file after player dies? So that they have to start from the beginning.
This might be able to help. Archeia had an answer to delete all save files with a script call. All you would need would be a plugin to run a common event on game over.
Archeia post: https://forums.rpgmakerweb.com/index.php?threads/delete-save-file-automatically.101850/
SumRndmDde Gave Oover Plugin: http://sumrndm.site/game-over-core/
Which save file?

If player saves in multiple save files, you'd need to delete them all in order to force them to start over, as if you only delete the most recent one they could go back to an earlier point.

However, if I were playing in one save file, and someone else were playing on the same PC and using a different save file, I'd be pretty cranky if my save file got deleted because they were playing and got killed.

Hope you're prepared for people to give your game a miss as soon as they find out it does that. I wouldn't play a game that forced me to start over.
@ninja Thanks a lot!

@Shaz All of them 😛

Hope you're prepared for people to give your game a miss as soon as they find out it does that. I wouldn't play a game that forced me to start over.
Then you're not the target. The whole point of Roguelikes is permadeath and starting from the beginning every time, and Im sure people playing those games are well aware of that 😛
But you should at least allow multiple profiles so that if two persons or more are playing in that computer then only the current player who dies loses his progress.. or force a single save file only in your game, so that only one character can be played to avoid this problem of multiple users

Also, deleting upon death wont be foolprof because we can actually just copy the save file into a backup after saving, when the file gets deleted after the character dies, the player can just paste his backup save.
FYI: I'm working on a plugin for this. What I'm planning is to make it so save files aren't deleted but "invalidated" so they can't be loaded.
I should have something you can test out by tonight.
I'll work on the profile suggestions after I get the main stuff working properly.
I wrote a quick plugin that should be able to handle this. It works by having a specific saveID that is generated when you create a new game and all saves of that run will have the associated saveID. So if you reach the defeat screen it will look through all your saves and delete any save with the save ID. This allows for having multiple different games saved on your pc.

It also allows for having different saves from different parts of the same gametrough, however if you die in either all of them will be deleted. If you don't want this to be possible I do have a possible fix in mind.

This also does not prevent someone from making a backup of the save file to use after they have died.

If you have any questions feel free to ask me 🙂

Code:
//=============================================================================
// PermaDefeat.js
//=============================================================================

/*:
 * @plugindesc This plugin adds permanent defeat to the game.
 * @author Magnus0808
 *
 * @help If a player reaches the defeat screen then all saves associated with the
 *    current save be deleted. This allows for having multiple saves but still having
 *    permanent defeat.
 */
 (function() {
    
    var $saveID        = null;
    
    Scene_Gameover.prototype.create = function() {
        Scene_Base.prototype.create.call(this);
        this.playGameoverMusic();
        this.createBackground();
        this.deleteSaveFiles();
    };
    
    Scene_Gameover.prototype.deleteSaveFiles = function() {
        for (var i = 0; i < DataManager.maxSavefiles(); i++) {
            if (DataManager.isThisGameFile(i)) {
                var json = StorageManager.load(i);
                var contents = JsonEx.parse(json);
                if(contents.saveID == $saveID) {
                    StorageManager.remove(i);
                }
            }
        }
    }
    
    DataManager.makeSaveContents = function() {
        // A save data does not contain $gameTemp, $gameMessage, and $gameTroop.
        var contents = {};
        contents.system       = $gameSystem;
        contents.screen       = $gameScreen;
        contents.timer        = $gameTimer;
        contents.switches     = $gameSwitches;
        contents.variables    = $gameVariables;
        contents.selfSwitches = $gameSelfSwitches;
        contents.actors       = $gameActors;
        contents.party        = $gameParty;
        contents.map          = $gameMap;
        contents.player       = $gamePlayer;
        contents.saveID          = $saveID;
        return contents;
    };
    
    DataManager.extractSaveContents = function(contents) {
        $gameSystem        = contents.system;
        $gameScreen        = contents.screen;
        $gameTimer         = contents.timer;
        $gameSwitches      = contents.switches;
        $gameVariables     = contents.variables;
        $gameSelfSwitches  = contents.selfSwitches;
        $gameActors        = contents.actors;
        $gameParty         = contents.party;
        $gameMap           = contents.map;
        $gamePlayer        = contents.player;
        $saveID               = contents.saveID;
    };
    
    DataManager.setupNewGame = function() {
        this.createGameObjects();
        this.selectSavefileForNewGame();
        $gameParty.setupStartingMembers();
        $gamePlayer.reserveTransfer($dataSystem.startMapId,
            $dataSystem.startX, $dataSystem.startY);
        Graphics.frameCount = 0;
        $saveID = this.makeSaveID();
    };
    
    DataManager.makeSaveID = function() {
      var text = "";
      var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
      for (var i = 0; i < 16; i++) {
        text += possible.charAt(Math.floor(Math.random() * possible.length));
      }
      return text;
    }

    
 })();
Done with mine too.
Managed to get the "Profile" part working as well.

Mine doesn't delete the saves; just makes them unselectable.
Also, if they are ALL unselectable, the title screen will act as if there were no saves at all!
(Continue button will be greyed out.)
Will work even if saves are copied/pasted.

So let me know how this works for you.
😀
@Maliki79 Hey this is awesome and exactly what I was looking for I just missed it. Thank you so much I am going to test it now. Whats your terms?
Free to use with a mention in game credits.
Glad you like

Link to main thread of my plugin
https://forums.rpgmakerweb.com/inde...-permadeath-ver-1-2-save-file-disable.105527/

Original thread: https://forums.rpgmakerweb.com/threads/deleting-save-file-after-player-dies-permadeath.105322/