1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Welcome to the new Hive! Be advised that we're still working on the site. There are still many rough edges, so please bear with us.
    Dismiss Notice
  3. The member Kam is making HIVE coasters. Take a look. For every coaster you buy, Hive gets $1.
    Dismiss Notice
  4. The poll for Icon Contest #14 - Seven Deadly Sins is out!
    Dismiss Notice
  5. The 25th Texturing Contest has started! Contestants are to create a skin representing a dark elf person/being or any construct related to it using the vanilla models or the custom ones found on the site.
    Dismiss Notice
  6. Buy it, use it, break it, fix it, trash it, change it, mail - upgrade it. Join (Optionally) Paired Techtree Contest #11 - Techno Magic now!
    Dismiss Notice
  7. Voting squad, line up! Cast your vote on the poll for Modeling Contest #29 - Squads!
    Dismiss Notice
  8. Hero Contest #8 is up and running! This time it's a joint contest between artists and coders. Go here for team matchmaking.
    Dismiss Notice
  9. The poll for the theme of our StarCraft II Terraining Contest is up. Cast your note now!
    Dismiss Notice
  10. The ninth Concept Art Contest has launched. Enter now!
    Dismiss Notice

[System] Mode Manager

Discussion in 'JASS Resources' started by Magtheridon96, Jun 24, 2011.

  1. Nestharus

    Nestharus
    Joined:
    Jul 10, 2007
    Messages:
    6,101
    Why is the run thingie public??


    Also, I already mentioned that this is slower than a hashtable- boolean auth[12];
     
  2. Magtheridon96

    Magtheridon96
    Joined:
    Dec 12, 2008
    Messages:
    6,027
    Because then it won't compile? (See how mean I am when I ask rhetorical questions? :ogre_datass: =P)

    Yeah, I'll fix that..
     
  3. Nestharus

    Nestharus
    Joined:
    Jul 10, 2007
    Messages:
    6,101
    Anything that shouldn't be accessed outside of the library should be private and shouldn't be documented in the header >.>
     
  4. Magtheridon96

    Magtheridon96
    Joined:
    Dec 12, 2008
    Messages:
    6,027
    Ok then.
     
    Last edited: Jun 29, 2011
  5. Magtheridon96

    Magtheridon96
    Joined:
    Dec 12, 2008
    Messages:
    6,027
    Updated to Mode Manager 3.0.0.0!

    Changelog:
    - New API (Making it a requirement to go to 3.0.0.0)
    - Fixed a huge bug
    - Added debug messages everywhere :p
    - Fixed Mode/Command collisions.


    There are still some potential bugs that allow a player to ruin a game, but that can be easily fixed (via the 'flag' boolean).
    For example, a player could ruin the game if he enters a mode string like -apar (All Pick and All Random).
    If you want to fix that, this is how:

    Your functions should look like this:

    Code (vJASS):
    function Ap takes nothing returns boolean
        if not AR.flag then
            set AP.flag = true
            // your code here
        endif
        return false
    endfunction

    function Ar takes nothing returns boolean
        if not AP.flag then
            set AR.flag = true
            // your code here
        endif
        return false
    endfunction


    I told you the 'flag' is useful ;)

    edit
    Updated to 3.0.1.0
    - You may now completely lock players to render them unable to use any commands/modes.
     
    Last edited: Jun 30, 2011
  6. Magtheridon96

    Magtheridon96
    Joined:
    Dec 12, 2008
    Messages:
    6,027
    Update: Fixed a small bug :)
     
  7. Magtheridon96

    Magtheridon96
    Joined:
    Dec 12, 2008
    Messages:
    6,027
    Update:

    Huge optimization.

    Bribe, could you change the title to "[System] ModeManager" cause I rewrote the system in vJASS because I was too lazy to lookup how to make a struct extend an array in Zinc =P
     
  8. Bribe

    Bribe

    Code Moderator

    Joined:
    Sep 26, 2009
    Messages:
    7,335
    struct title[]

    sized structs are struct[size] title
     
  9. Magtheridon96

    Magtheridon96
    Joined:
    Dec 12, 2008
    Messages:
    6,027
    I'll keep that in mind next time I upload a Zinc resource xD
    Thanks :)

    edit
    Not so silent update:
    - Fixed a huge bug that didn't allow the system to function at all :p
     
  10. Bribe

    Bribe

    Code Moderator

    Joined:
    Sep 26, 2009
    Messages:
    7,335
    How did that happen to both scripts?
     
  11. Magtheridon96

    Magtheridon96
    Joined:
    Dec 12, 2008
    Messages:
    6,027
    I forgot to initialize integers ic (instance count) and ir (instance recycler) :p
     
  12. Bribe

    Bribe

    Code Moderator

    Joined:
    Sep 26, 2009
    Messages:
    7,335
    The names are a bit generic. "Mode" would be better as "GameMode",
    if you think about it "Mode" could mean anything.
     
  13. Magtheridon96

    Magtheridon96
    Joined:
    Dec 12, 2008
    Messages:
    6,027
    You're probably right :)
    Since I'd have to change the API (even though it's only one word), I'm going to have to update to 5.0.0.0 :p (Way too fast xD)

    edit
    Updated! :D
    I also updated the demo code to show you how you could stop players from f***ing up the game with 2 modes that shouldnt go together xD
     
  14. jim7777

    jim7777
    Joined:
    May 27, 2009
    Messages:
    481
    thanks this should be working
     
  15. Magtheridon96

    Magtheridon96
    Joined:
    Dec 12, 2008
    Messages:
    6,027
    It better ;)
    I'm already using it in an AoS =D
     
  16. jim7777

    jim7777
    Joined:
    May 27, 2009
    Messages:
    481
    i can't let it work :/ doesn't init anyways

    here's my init code
    Code (vJASS):

        private function ND takes nothing returns boolean
            set udg_EnablePvP_On = false
            set PvP_ModeAllowed = false
            call BJDebugMsg("Init ND")
            return false
        endfunction
        private function Init takes nothing returns nothing
            set nd = GameMode.create("nd",true, Condition(function ND))
            call nd.authorize(GetPlayerId(PLAYERS_HOST))
            set nd.enabled = true
        endfunction
     
     
  17. Magtheridon96

    Magtheridon96
    Joined:
    Dec 12, 2008
    Messages:
    6,027
    You shouldn't touch the boolean enabled unless you want to disable the system.
    Plus, it's static. Using it would disable/enable the entire system.
     
  18. jim7777

    jim7777
    Joined:
    May 27, 2009
    Messages:
    481
    ohh but also without the enabled/authorize thing, it doesn't work for me D:
     
  19. Magtheridon96

    Magtheridon96
    Joined:
    Dec 12, 2008
    Messages:
    6,027
    The authorize thing is needed...
     
  20. jim7777

    jim7777
    Joined:
    May 27, 2009
    Messages:
    481
    ohh even though i used it
    since players_host is player 1(blue)
    still nothing happens.. D: dunno whyyyy

    this is really awesome