vJASS & Zinc Documentation
For the latest documentation about how it works vJASS and Zinc language layers for Warcraft III, please follow these links:
Jasshelper documentation - Zinc documentation - WC3 Optimizer documentation

[Snippet] NoSaveGame

nel · 177

0 Members and 1 Guest are viewing this topic.

Rating

Average Score - 5 / 5

« Created: November 29, 2018, 07:20:28 PM by moyack »

[Snippet] NoSaveGame
on: November 28, 2018, 11:50:18 PM
Category: Interface
Language: ZINC
Download Demo Map

NoSaveGame

It prevents to use Save Game function to all players.

Code: jass
  1. //! zinc
  2. library NoSaveGame /* v1.0.0.4
  3. ************************************************************************************
  4. *
  5. *    No Save Game
  6. *        by nel
  7. *
  8. *       It prevents to use Save Game function to all players.
  9. *
  10. ***********************************************************************************/
  11.  
  12.  
  13.        requires
  14.  
  15.            SimError /* http://www.wc3c.net/showthread.php?t=101260 */
  16.  
  17.  
  18. /***********************************************************************************
  19. *
  20. *
  21. *    boolean nsg
  22. *       - Set false, to allow to all players to use Save Game.
  23. *
  24. *    string nsgErrMsg
  25. *       - Error Message
  26. *
  27. *    boolean nsgDisplayErrMsg
  28. *       - Set false, if you don't want to show the Error Message in-game.
  29. *
  30. *
  31. ***********************************************************************************/
  32. {
  33.     public {    
  34.         string  nsgErrMsg = "You are not allowed to use Save Game.";
  35.         boolean nsgDisplayErrMsg = true;
  36.         boolean nsg = true;
  37.     }
  38.  
  39.     private {
  40.         constant dialog DIALOG = DialogCreate();
  41.         constant timer   TIMER = CreateTimer();
  42.  
  43.         module inc { private static method onInit() {
  44.             trigger trgSave = CreateTrigger();
  45.             trigger trgStop = CreateTrigger();
  46.  
  47.             TriggerRegisterGameEvent( trgSave, EVENT_GAME_SAVE );
  48.             TriggerAddCondition( trgSave, Condition( function() -> boolean {
  49.                 player pl;
  50.  
  51.                 if( nsg ) {
  52.                     pl = GetLocalPlayer();
  53.                     DialogDisplay( pl, DIALOG, true );
  54.                     TimerStart( TIMER, 0, false, null);
  55.                    
  56.                     if( nsgDisplayErrMsg ) { SimError( pl, nsgErrMsg ); }
  57.                     pl = null;
  58.                 }
  59.  
  60.                 return false;
  61.             }));
  62.  
  63.             TriggerRegisterTimerExpireEvent( trgStop, TIMER );
  64.             TriggerAddCondition( trgStop, Condition( function() -> boolean {
  65.                 if( nsg ) { DialogDisplay( GetLocalPlayer(), DIALOG, false ); }
  66.                 return false;
  67.             }));
  68.  
  69.             trgSave = null;
  70.             trgStop = null;
  71.         }}
  72.  
  73.         struct Z extends array { module inc; }
  74.     }
  75. }
  76. //! endzinc
« Last Edit: January 09, 2019, 12:31:45 PM by nel »



Re: [Snippet] NoSaveGame
Reply #1 on: November 30, 2018, 12:17:02 PM

Map updated? because I was going to suggest add a text that explain how to test the snippet. Anyways, nice code: simple and straight to the point.
« Last Edit: November 30, 2018, 01:13:45 PM by moyack »



Re: [Snippet] NoSaveGame
Reply #2 on: December 01, 2018, 03:08:42 AM

Map updated? because I was going to suggest add a text that explain how to test the snippet. Anyways, nice code: simple and straight to the point.

Ok, I'll update the demo map and the documentation. :)



 

Vivir aprendiendo.co - A place for learning stuff, in Spanish   Chaos Realm - The world of Game modders and wc3 addicts   Diplo, a gaming community   WC3JASS.com - The JASS Vault + vJASS and Zinc   Jetcraft - A Starcraft II mod