• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

Basics - Variable Array

Status
Not open for further replies.

NEL

NEL

Level 6
Joined
Mar 6, 2017
Messages
113
Part 1

Create a (JASS) trigger that runs when a player presses the 'Esc' button (Skip Cinematic).
The trigger's goal is to count how often a player has hit the 'Esc' button, and to print the correct value on screen.
The trigger must be MPI (tip: always search for things you don't know Elemental Coder Guide).

Part 2

If you don't already have done so, do now the "Part 2" without using any "if statement".
Tip: Each player has a unique player number.

vJASS:
//! zinc
library VariableArray {
    private {
        integer Counter[];
  
        function onInit() {
            trigger trgEsc = CreateTrigger();
            integer Index = 0;
          
            while( Index < bj_MAX_PLAYERS ) {
                TriggerRegisterPlayerEvent( trgEsc, Player( Index ), EVENT_PLAYER_END_CINEMATIC );
                Index = Index + 1;
            }
          
            TriggerAddAction( trgEsc, function() {
                player pl = GetTriggerPlayer();
                integer id = GetPlayerId( pl );
                Counter[id] = Counter[id] + 1;
              
                DisplayTextToPlayer( pl, 0, 0, GetPlayerName( pl ) + ": " + I2S( Counter[id] ) );
                  
                pl = null;
            });
          
            trgEsc = null;
        }
    }
}
//! endzinc
 

Attachments

  • [Crash Course] Basics - Variable Array.w3m
    23.8 KB · Views: 69
Status
Not open for further replies.
Top