No Save Game
It prevents to use Save Game function to all players.
Code: Select all
//! zinc
library NoSaveGame /* v1.0.0.5
************************************************************************************
*
* No Save Game
* by nel
*
* It prevents to use Save Game function to all players.
*
***********************************************************************************/
requires
optional SimError, /* http://www.wc3c.net/showthread.php?t=101260 */
optional RegisterGameEvent /* https://www.hiveworkshop.com/threads/snippet-registerevent-pack.250266/ */
/***********************************************************************************
*
* SETTINGS
*
*/
{
public {
/*
* It's a content of the error message.
*/
string nsgErrMsg = "You are not allowed to use Save Game.";
/*
* Toggleable Error Message.
*/
boolean nsgDisplayErrMsg = true;
/*
* Toggleable NoSaveGame.
*/
boolean nsg = true;
}
/*
***********************************************************************************/
private {
constant dialog DIALOG = DialogCreate();
constant timer TIMER = CreateTimer();
struct NoSaveGame [] { private static method onInit() {
trigger Stop = CreateTrigger();
static if( LIBRARY_RegisterGameEvent ) {
RegisterGameEvent(EVENT_GAME_SAVE, function() {
player pl;
if( nsg ) {
pl = GetLocalPlayer();
DialogDisplay(pl, DIALOG, true);
TimerStart(TIMER, 0, false, null);
static if( LIBRARY_SimError ) {
SimError(pl, nsgErrMsg);
} else {
DisplayTimedTextToPlayer(pl, 0.52, 0.96, 2.00,
"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" +
"|cffffcc00" + nsgErrMsg + "|r"
);
}
pl = null;
}
});
TriggerRegisterTimerExpireEvent(Stop, TIMER);
TriggerAddCondition(Stop, Condition(function() -> boolean {
if( nsg ) {
DialogDisplay(GetLocalPlayer(), DIALOG, false);
}
return false;
}));
Stop = null;
} else {
trigger Save = CreateTrigger();
TriggerRegisterGameEvent(Save, EVENT_GAME_SAVE);
TriggerAddCondition(Save, Condition(function() -> boolean {
player pl;
if( nsg ) {
pl = GetLocalPlayer();
DialogDisplay(pl, DIALOG, true);
TimerStart(TIMER, 0, false, null);
if( nsgDisplayErrMsg ) {
static if( LIBRARY_SimError ) {
SimError(pl, nsgErrMsg);
} else {
DisplayTimedTextToPlayer(pl, 0.52, 0.96, 2.00,
"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" +
"|cffffcc00" + nsgErrMsg + "|r"
);
}
}
pl = null;
}
return false;
}));
TriggerRegisterTimerExpireEvent(Stop, TIMER);
TriggerAddCondition(Stop, Condition(function() -> boolean {
if( nsg ) {
DialogDisplay(GetLocalPlayer(), DIALOG, false);
}
return false;
}));
Save = null;
Stop = null;
}
}}
}
}
//! endzinc