• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

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
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
  • 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?
 
Level 1
Joined
Apr 19, 2010
Messages
4
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".
 
Level 10
Joined
Apr 3, 2006
Messages
535
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
 
Level 3
Joined
Apr 20, 2010
Messages
46
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.
Top