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

넬만 · 89

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 the Save Game to all players.

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

Code: jass
  1. //! zinc
  2. library Zinc { function onInit() {
  3.     BJDebugMsg( "If you want to learn something useful, go for it." );
  4. }}
  5. //! endzinc


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. :)

Code: jass
  1. //! zinc
  2. library Zinc { function onInit() {
  3.     BJDebugMsg( "If you want to learn something useful, go for it." );
  4. }}
  5. //! endzinc


 

Chaos Realm - The world of Game modders and wc3 addicts     WC3JASS.com - The JASS Vault   Jetcraft - A Starcraft II mod