• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

Universal - Order Tracking

Status
Not open for further replies.

NEL

NEL

Level 6
Joined
Mar 6, 2017
Messages
113
Part 1

Create a trigger that should detect any order a unit does, and print the unit's name and the issued order id on screen.

Part 2

Now it should also print the order's equivalent string or the name of issued object id being ordered (in same line). For example 851983 should also print "attack", and 'hbar' should also print "Barracks", so the user can easily see which order is behind the id.

vJASS:
//! zinc
library OrderTracking {
    private function onInit() {
        trigger trgOrder = CreateTrigger();
        integer Index = 0;
           
        while( Index < bj_MAX_PLAYERS ) {
            TriggerRegisterPlayerUnitEvent( trgOrder, Player( Index ), EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER, null );
            TriggerRegisterPlayerUnitEvent( trgOrder, Player( Index ), EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER, null );
            TriggerRegisterPlayerUnitEvent( trgOrder, Player( Index ), EVENT_PLAYER_UNIT_ISSUED_ORDER, null );
               
            Index = Index + 1;
        }
           
        TriggerAddAction( trgOrder, function(){
            unit u = GetOrderedUnit();
            integer orderId = GetIssuedOrderId();
           
            ClearTextMessages();
            DisplayTextToPlayer( GetLocalPlayer(), 0, 0, 
                "Unit Name: " + I2S( GetUnitTypeId( u ) ) + " | " + GetUnitName( u ) + "\n" +
                "OrderID: " + I2S( orderId ) + " | " + OrderId2String( orderId )
            );
               
            u = null;
        });
           
        trgOrder = null;
    }
}
//! endzinc
 

Attachments

Status
Not open for further replies.
Back
Top