wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Resources > Code Resources > Scripts
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 11-06-2009, 05:39 PM   #1
TriggerHappy
 
Join Date: Feb 2008
Posts: 405

Submissions (2)

TriggerHappy will become famous soon enough (43)TriggerHappy will become famous soon enough (43)

Default PreventSave

Collapse JASS:
library PreventSave initializer onInit
/***************************************************************
*
*   v1.0.1 by TriggerHappy
*   ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
*   This library allows you to enable or disable game saving. It works by showing 
*   a dialog instantly before a game is saved, causing the save to interrupt. There
*   are no known side effects.
*   _________________________________________________________________________
*   1. Installation
*   ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
*   Copy the script to your map and save it (requires JassHelper *or* JNGP)
*   _________________________________________________________________________
*   2. API
*   ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
*   This library provides one function
*
*       function SaveGameEnable takes boolean flag returns nothing
*       function IsSaveEnabled takes nothing returns boolean
*       function PreventSave takes player p, boolean flag returns nothing
*
***************************************************************/
    
    globals
        boolean GameAllowSave = false
    endglobals
    
    //====================================
    // Do not edit below this line
    //====================================
    
    globals
        private dialog Dialog = DialogCreate()
        private timer  Timer  = CreateTimer()
        private player LocalPlayer
    endglobals
    
    function SaveGameEnable takes boolean flag returns nothing
        set GameAllowSave = flag
    endfunction
    
    function IsSaveEnabled takes nothing returns boolean
        return GameAllowSave
    endfunction
    
    function PreventSave takes player p, boolean flag returns nothing
        if (p == LocalPlayer) then
            call SaveGameEnable(not flag)
        endif
    endfunction
    
    private function Exit takes nothing returns nothing
        call DialogDisplay(LocalPlayer, Dialog, false)
    endfunction
    
    private function StopSave takes nothing returns boolean
        if not IsSaveEnabled() then
            call DialogDisplay(LocalPlayer, Dialog, true)
        endif
        call TimerStart(Timer, 0.00, false, function Exit)
        return false
    endfunction
    
    private function onInit takes nothing returns nothing
        local trigger t = CreateTrigger()
        set LocalPlayer = GetLocalPlayer()
        
        call TriggerRegisterGameEvent(t, EVENT_GAME_SAVE)
        call TriggerAddCondition(t, Filter(function StopSave))
    endfunction

endlibrary

Last edited by TriggerHappy : 04-14-2017 at 10:41 PM.
TriggerHappy is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 11-06-2009, 11:32 PM   #2
Rising_Dusk
Obscurity, the Art


Projects Director
Project Leader: OD
 
Join Date: Feb 2006
Posts: 9,729

Submissions (27)

Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)

Hero Contest #3 - 1st PlaceApproved Map: Desert of ExileApproved Map: Advent of the ZenithHero Contest #2 - 1st PlaceHero Contest - Third place>

Send a message via AIM to Rising_Dusk Send a message via MSN to Rising_Dusk
Default

Can you verify that this actually works? Testmap or something? Once you do that, this is actually a rather cool library.
__________________

Last edited by Rising_Dusk : 11-06-2009 at 11:33 PM.
Rising_Dusk is offline   Reply With Quote
Old 11-06-2009, 11:40 PM   #3
Earth-Fury
Two Blue
 
Earth-Fury's Avatar
 
Join Date: Mar 2003
Posts: 2,179

Submissions (7)

Earth-Fury is just really nice (343)Earth-Fury is just really nice (343)Earth-Fury is just really nice (343)Earth-Fury is just really nice (343)

Send a message via MSN to Earth-Fury
Default

Quote:
Originally Posted by Rising_Dusk
Can you verify that this actually works? Testmap or something? Once you do that, this is actually a rather cool library.

I can confirm this works in single player, at least under very basic conditions. (I can't think of anything that should/would make this not work..)
__________________
Useful Links:
My Resources:
Good Resources:
Search
Tutorials
Ability Guide

UnitMaxState
BonusMod

AutoIndex
ARGB
TimerUtils

Earth-Fury is offline   Reply With Quote
Old 11-06-2009, 11:40 PM   #4
Rising_Dusk
Obscurity, the Art


Projects Director
Project Leader: OD
 
Join Date: Feb 2006
Posts: 9,729

Submissions (27)

Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)

Hero Contest #3 - 1st PlaceApproved Map: Desert of ExileApproved Map: Advent of the ZenithHero Contest #2 - 1st PlaceHero Contest - Third place>

Send a message via AIM to Rising_Dusk Send a message via MSN to Rising_Dusk
Default

Sweet, this resource is very cool then. Approved.
__________________
Rising_Dusk is offline   Reply With Quote
Old 11-06-2009, 11:42 PM   #5
TriggerHappy
 
Join Date: Feb 2008
Posts: 405

Submissions (2)

TriggerHappy will become famous soon enough (43)TriggerHappy will become famous soon enough (43)

Default

I've tested online as well.
TriggerHappy is offline   Reply With Quote
Old 11-07-2009, 10:20 PM   #6
ploks
User
 
Join Date: Jun 2007
Posts: 99

ploks has little to show at this moment (6)

Default

Wouldn't it be nice to change whether or not saving is possible during runtime by calling a function?

For example if you want to allow saves when a hero is in a "safe area" but not when the hero is hunting in the woods?

Last edited by ploks : 11-07-2009 at 10:20 PM.
ploks is offline   Reply With Quote
Old 11-07-2009, 10:33 PM   #7
TriggerHappy
 
Join Date: Feb 2008
Posts: 405

Submissions (2)

TriggerHappy will become famous soon enough (43)TriggerHappy will become famous soon enough (43)

Default

Quote:
Originally Posted by ploks
Wouldn't it be nice to change whether or not saving is possible during runtime by calling a function?

For example if you want to allow saves when a hero is in a "safe area" but not when the hero is hunting in the woods?

set GAME_ALLOW_SAVE = true.
TriggerHappy is offline   Reply With Quote
Old 11-07-2009, 11:27 PM   #8
ploks
User
 
Join Date: Jun 2007
Posts: 99

ploks has little to show at this moment (6)

Default

Quote:
Originally Posted by TriggerHappy187
set GAME_ALLOW_SAVE = true.


I'm stupid and need to improve my reading skills. Because of the capital letters I thought it was a constant. Sorry about that.
ploks is offline   Reply With Quote
Old 02-05-2010, 10:07 PM   #9
TriggerHappy
 
Join Date: Feb 2008
Posts: 405

Submissions (2)

TriggerHappy will become famous soon enough (43)TriggerHappy will become famous soon enough (43)

Default

Updated with some minor efficiency improvements.
TriggerHappy is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 10:05 AM.


Affiliates
The Hubb The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2018, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services