• Check out the results of the Techtree Contest #19!
  • 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.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

temp save gold/lumber

Status
Not open for further replies.
Level 10
Joined
Apr 3, 2006
Messages
535
Is it possible to save the gold/lumber of a player when they enter an area, save this number set the gold/lumber to zero, and then once they leave the area they load back their old gold/lumber??

Enter area
Save current gold/lumber
Set gold/lumber to 0
Leave are get your old gold/lumber value
 
  • Untitled Trigger 002
    • Events
      • Unit - A unit enters Region 000 <gen>
    • Conditions
    • Actions
      • Set Temp_Integer_1 = (Player number of (Triggering player))
      • Set Temp_Player_1 = (Owner of (Triggering unit))
      • Set Resource_Array[(Temp_Integer_1 - 1)] = (Temp_Player_1 Current gold)
      • Set Resource_Array[((Temp_Integer_1 - 1) + 12)] = (Temp_Player_1 Current lumber)
      • Player - Set Temp_Player_1 Current gold to 0
      • Player - Set Temp_Player_1 Current lumber to 0

  • Untitled Trigger 002 Copy
    • Events
      • Unit - A unit leaves Region 000 <gen>
    • Conditions
    • Actions
      • Set Temp_Integer_1 = (Player number of (Triggering player))
      • Set Temp_Player_1 = (Owner of (Triggering unit))
      • Player - Set Temp_Player_1 Current gold to Resource_Array[(Temp_Integer_1 - 1)]
      • Player - Set Temp_Player_1 Current lumber to Resource_Array[((Temp_Integer_1 - 1) + 12)]
Do the players have more than one unit?
 
Semi-pseudo, modifying Maker's code for errors and simplification.

  • Hero Enters
    • Events
      • Unit - A unit enters Region 000 <gen>
    • Conditions
      • Boolean - (Triggering Unit) is a Hero == True
    • Actions
      • Set xp = (Owner of (Triggering Unit))
      • Set goldStore[(Player number of xp)] = (xp Current gold)
      • Set lumberStore[(Player number of xp)] = (xp Current lumber)
      • Player - Set xp Current gold to 0
      • Player - Set xp Current lumber to 0

  • Hero Leaves
    • Events
      • Unit - A unit leaves Region 000 <gen>
    • Conditions
      • Boolean - (Triggering Unit) is a Hero == True
    • Actions
      • Set xp = (Owner of (Triggering Unit))
      • Set xi = (Player Number of xp)
      • Player - Add goldStore[xi] to xp's Current Gold
      • Player - Add lumberStore[xi] to xp's Current Lumber
      • Set goldStore[xi] = 0;
      • Set lumberStore[xi] = 0;
Local variables are traditionally one letter, like a b x y. You can't use locals in GUI, thus I use this system...

xp, xp2 = Player
xi, xi2, xi3 = Integer
xl = Point / Location
xf = Force / Player Group
xg = Group / Unit Group

Therefore you can quickly access your 'locals' by hitting x on the variable list. Idk why people use Temp_This Temp_That, at least just name it "Integer1".
 
what type of variable is Set Resource_Array, also would it be possible to put this is in sample map :D. Thanks again for your help
 
I'd gather that Maker had it in that format to make it easier for corley to understand.

His code was perfectly fine.
 
Status
Not open for further replies.
Back
Top