1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. We have recently started the 16th edition of the Mini Mapping Contest. The theme is mini RPG. Do check it out and have fun.
    Dismiss Notice
  4. Choose your ride to damnation in the 5th Special Effect Contest Poll.
    Dismiss Notice
  5. The winners of the 13th Techtree Contest have been announced!
    Dismiss Notice
  6. The 13th Music Contest Poll has begun! Vote for the best tracks in this symphony of frost and flame.
    Dismiss Notice
  7. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Income trigger not working.

Discussion in 'Triggers & Scripts' started by Airandius, Jul 10, 2010.

  1. Airandius

    Airandius

    Joined:
    Jun 12, 2007
    Messages:
    1,238
    Resources:
    3
    Icons:
    1
    Maps:
    1
    Tutorials:
    1
    Resources:
    3
    So yes, this trigger does not work. Nobody receives a message not get´s income even though the conditions are met.

    • Income
      • Events
        • Time - Every 10.00 seconds of game time
      • Conditions
      • Actions
        • Set GoldOnePercentage[1] = ((Player 11 (Dark Green) Current gold) / Kills_UnitTotal[1])
        • Set GoldOnePercentage[2] = ((Player 12 (Brown) Current gold) / Kills_UnitTotal[2])
        • For each (Integer A) from 1 to 5, do (Actions)
          • Loop - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • ((Player((Integer A))) slot status) Equal to Is playing
                • Kills_Unit[(Integer A)] Greater than 0
                • Kills_UnitTotal[1] Greater than 0
              • Then - Actions
                • Player - Add (GoldOnePercentage[1] / Kills_Unit[(Integer A)]) to (Player((Integer A))) Current gold
                • Game - Display to (Player group((Player((Integer A))))) the text: (The Nation of Light gives you + (String((GoldOnePercentage[1] x Kills_Unit[(Integer A)]))))
              • Else - Actions
     
  2. Rui

    Rui

    Joined:
    Jan 7, 2005
    Messages:
    8,502
    Resources:
    8
    Maps:
    8
    Resources:
    8
    Have you tried displaying a message for all players before and after «Then - Actions»? If both don't display, your function met with a null argument (I'll explain what this is if you ask). If only the second doesn't display, the conditions are definitely not being met.
    Also, be careful with dividing for Kills_UnitTotal. If that is the number of enemies killed, it might (or not, depending on how your map is played) cause a division by zero, which results in a fatal error.
    Or, at least, should; it happens in JASS. I don't know whether Blizzard coded some smart function to avoid it.
     
  3. Airandius

    Airandius

    Joined:
    Jun 12, 2007
    Messages:
    1,238
    Resources:
    3
    Icons:
    1
    Maps:
    1
    Tutorials:
    1
    Resources:
    3
    You were right about the dividing by 0 it seems, I moved a few things around and it now runs (And will show both the win and the how much gold you gain message.)
    Thanks a lot, and yes I guess it does have some failsave.

    At first it would not run either the then or else.

    EDIT: For those interested here is the fixed version:

    • Events
      • Income
        • Events
          • Time - Every 120.00 seconds of game time
        • Conditions
        • Actions
          • For each (Integer A) from 1 to 5, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Player((Integer A))) slot status) Equal to Is playing
                  • Kills_Unit[(Integer A)] Greater than 0
                  • Kills_UnitTotal[1] Greater than 0
                • Then - Actions
                  • Set GoldOnePercentage[1] = ((Player 11 (Dark Green) Current gold) / Kills_UnitTotal[1])
                  • Player - Add (GoldOnePercentage[1] x Kills_Unit[(Integer A)]) to (Player((Integer A))) Current gold
                  • Game - Display to (Player group((Player((Integer A))))) the text: (The Nation of Light gives you + (String((GoldOnePercentage[1] x Kills_Unit[(Integer A)]))))
                  • Player - Set Player 11 (Dark Green) Current gold to 0
                • Else - Actions