• 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.
  • Vote for the theme of Hive's HD Modeling Contest #7! Click here to vote! - Please only vote if you plan on participating❗️

[Trigger] Player-specific variables without using arrays?

Status
Not open for further replies.
Level 5
Joined
Feb 1, 2009
Messages
107
When you "Set Variable" by using a trigger, that variable is set for all players, right? That unless you create your variable with an array and use that array to specify the player.

But I want to use the array for another thing, but i still need the variable to apply only to a specific player. Is there a way to do this?
 
You could use what we call "2d arrays". It's something like this:

Array[ (player-1)*10 + n ]

Pay attention:

For Player 1: Array[ 0 + n ]
For Player 2: Array[ 10 + n]
For Player 3: Array[ 20 + n]

So, for Player 1, you can use any value for n from 0 to 9, as well for Player 2 and so on.
You can increase/decrease the maximum size of each "player-array" (in this case I used 10) according to your needs :p

If you use a value for n higher that the "player-array" size, you'll be using other player's array. Look:

(With size = 10, 'n' can be any value from 0 to 9)
For Player 2, n = 0: Array[10 + 0] = Array[10]
For Player 1, n = 10: Array[0 + 10] = Array[10] Player 2 index!!

With this you could do, for example:
Kills: n = 0
Deaths: n = 1

To get Player 4 deaths: Array[ 3*10 + 1 ]
To get Player 9 kills: Array[ 8*10 + 0 ]
 
Status
Not open for further replies.
Top