Message Display/Prevent Leak Problem

CrackUps

New Member
Reaction score
7
Ok i have a system in my map so that a integer keeps track of how much exp a hero has earned and a player can type -exp to check how much that is. Anyway i made the trigger so it wouldnt leak by adding the triggering player to a player group then displaying the message to the group but when i type -exp in game it wont display the message this is the trigger:

Code:
ExpCheck
    Events
        Player - Player 1 (Red) types a chat message containing -exp as An exact match
    Conditions
    Actions
        Player Group - Add (Triggering player) to TempPlayerGroup
        Set TempUnitGroup = (Units owned by (Triggering player))
        Unit Group - Pick every unit in TempUnitGroup and do (Actions)
            Loop - Actions
                Game - Display to TempPlayerGroup the text: ((PlayerColour[(Player number of (Triggering player))] + (Name of (Picked unit))) + ('s|r total experience gained is  + (String(TotalExpGained[(Player number of (Triggering player))]))))
        Custom script:   call DestroyGroup(udg_TempUnitGroup)
        Player Group - Remove all players from TempPlayerGroup

and yet it will display the message when i make the trigger like this:

Code:
ExpCheck
    Events
        Player - Player 1 (Red) types a chat message containing -exp as An exact match
    Conditions
    Actions
        Set TempUnitGroup = (Units owned by (Triggering player))
        Unit Group - Pick every unit in TempUnitGroup and do (Actions)
            Loop - Actions
                Game - Display to (Player group((Triggering player))) the text: ((PlayerColour[(Player number of (Triggering player))] + (Name of (Picked unit))) + ('s|r total experience gained is  + (String(TotalExpGained[(Player number of (Triggering player))]))))
        Custom script:   call DestroyGroup(udg_TempUnitGroup)

What am i doing wrong?
 

vypur85

Hibernate
Reaction score
803
Code:
ExpCheck
    Events
        Player - Player 1 (Red) types a chat message containing -exp as An exact match
    Conditions
    Actions
        [B]Set TempForce = (Player group((Triggering player)))[/B] <-- Player variable
        Set TempUnitGroup = (Units owned by (Triggering player))
        Unit Group - Pick every unit in TempUnitGroup and do (Actions)
            Loop - Actions
                Game - Display to [B]TempForce[/B] the text: ((PlayerColour[(Player number of (Triggering player))] + (Name of (Picked unit))) + ('s|r total experience gained is  + (String(TotalExpGained[(Player number of (Triggering player))]))))
        Custom script:   call DestroyGroup(udg_TempUnitGroup)
        [B]Custom script:   call DestroyForce(udg_TempForce)[/B]

Try adding the bolded stuff above. This should be leakless.


Wonder why Ace didn't answer the question...

Edit:
For post below: Never thought you'd reply :p. -smiles-
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
> Wonder why Ace didn't answer the question...

Probably because he's not seeing the problem.

> Custom script: call DestroyForce(udg_TempForce)

Actually, my guess on his original plan was to not have to create / destroy that force every time you use it.

Then again, if you need it often enough, why not simply create an array of "player groups with one single player", indexed by player number, and simply use that one without ever creating / destroying anything?

Would also be insanely faster (about 1 second on 1e7 runs).
But, certainly easier if needed in several triggers.


On a related note, you can simply ask Heroes to tell you the current experience they have...
 

CrackUps

New Member
Reaction score
7
I could refer to the actual hero's exp bar to see how much exp it has but this trigger was more for me to test if the integer was storing the correct value and basically functioning as i desired

ExpCheck
Events
Player - Player 1 (Red) types a chat message containing -exp as An exact match
Conditions
Actions
Set TempForce = (Player group((Triggering player))) <-- Player variable
Set TempUnitGroup = (Units owned by (Triggering player))
Unit Group - Pick every unit in TempUnitGroup and do (Actions)
Loop - Actions
Game - Display to TempForce the text: ((PlayerColour[(Player number of (Triggering player))] + (Name of (Picked unit))) + ('s|r total experience gained is + (String(TotalExpGained[(Player number of (Triggering player))]))))
Custom script: call DestroyGroup(udg_TempUnitGroup)
Custom script: call DestroyForce(udg_TempForce)


Try adding the bolded stuff above. This should be leakless.

*sigh* dunno why i didn't realise i could have done that, it worked perfectly i feel stupid now:banghead: oh well thanks
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top