• 🏆 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!

How to get a random players name?

Status
Not open for further replies.
Level 8
Joined
Aug 1, 2008
Messages
420
Ok, so this is for a duel, im gonna put Floating text infront of the heroes saying "blah vs blah". But the duel is random (with random people). So how would i get the players name if i dont know whos going to be duelling?
 
Level 8
Joined
Nov 9, 2008
Messages
502
Glad to hear you're still working on this duel ^^

Anyway, it's not exactly random because at some point you will know who will be dueling and that's when you should display it. For example one way would be when the particular players are chosen you would grab their names and store each in a string variable. Then play your text trigger and call on those string variables.
 
Level 17
Joined
Nov 18, 2008
Messages
1,538
Well, you could do something like this.
  • Unit Group - Pick every unit in Heroes and do (Floating Text - Create floating text that reads ((Name of (Owner of DualUnit[1])) + (Versus + (Name of (Owner of DualUnit[2])))) above (Picked unit) with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency)
Where "Heroes" is a Unit Group variable which would contain all the heroes in the map. And "DualUnit" is an array Unit Variable which you would set to the two units dueling.
 
Level 8
Joined
Aug 1, 2008
Messages
420
Hmm... ok >.> How would i get to uhm..
I cant explain it...
How would i call on those variables in the string?


@ toofless yeah, im trying to get better and better and im trying to make the system better and better :p
also to help people with their maps ;)
 
Level 17
Joined
Nov 18, 2008
Messages
1,538
:\
Create them in the Variables section(The yellow X).There is a Unit Group(Heroes), and a Unit variable(DuelUnit[X]) used in what I showed. The Unit variable should be an array.

For the Unit Group you could do:
  • Unit Group - Pick every unit in (Units in (Playable map area) matching (((Matching unit) is A Hero) Equal to True)) and do (Unit Group - Add (Picked unit) to Heroes)
I'm not sure how you choose the two random duelists, but I'm sure there's somewhere you can set DuelUnit[1 and 2] to them.
 
Level 8
Joined
Aug 1, 2008
Messages
420
No no, i mean past that. How will i call forth the variable in the string bit? :p
(im following toofless' way)

For example one way would be when the particular players are chosen you would grab their names and store each in a string variable. Then play your text trigger and call on those string variables.
 
Last edited:
Level 6
Joined
May 7, 2009
Messages
228
Are you willing to use JASS, or does it have to be GUI?

It would help if you showed what your triggers were like currently.
 
Level 8
Joined
Nov 9, 2008
Messages
502
  • Floating Text - Create floating text that reads ((string[1] + vs. ) + string[2]) at (Center of (Playable map area)) and so on...
Something like that.

Creating and editing text is the thing that annoys me most in the GUI. All those concatenate strings and going back and forth in those windows can be frustrating when you want to add colours and such.

P.S. If you ever need someone to test the map on I'd be glad to help just shoot me a message.
 
Level 8
Joined
Aug 1, 2008
Messages
420
Okie, thanks. Will see how it turns out :D
Ugh, how will i store the names in the variable? Because if there was a way to store a persons name depending if they were in a region or not, it would be easy, but im not sure how :/
Would i need an array, and loop through the picked players somehow getting their names?
Edit: sigh, ive tried everything i know of and it isnt working >.> i tried:
  • For each (Integer A) from 1 to 2, do (Actions)
    • Loop - Actions
      • For each (Integer B) from 1 to 2, do (Actions)
        • Loop - Actions
          • Set temp_unit = (Random unit from group[(Integer A)])
          • Set PlayerNames[(Integer A)] = (Name of (Owner of temp_unit))
          • Unit - Move temp_unit instantly to battle_point[point_index], facing Default building facing degrees
          • Unit Group - Remove temp_unit from group[(Integer A)]
          • Unit Group - Add temp_unit to group[3]
          • Set point_index = (point_index + 1)
then
  • Floating Text - Create floating text that reads PlayerNames[(Integer A)] at PlayerTextPoint[1] with Z offset 0.00, using font size 10.00, color (0.00%, 100.00%, 100.00%), and 0.00% transparency
to display it, but that doesnt work, ive also tried 2 other things, i thought this was the closest to it though >.<
 
Last edited:
Level 8
Joined
Nov 9, 2008
Messages
502
I can't remember but the duel is 2v2 right? That would sort of explain why your using 2 loops (or maybe I wrote that part I don't remember xD). This would mean there is a conflict because you used Integer A to refer to the array of the PlayerNames variable (which I'm assuming has 4 entries for 4 players) as what is happening is you're only setting 1 and 2.

Man I can see why you were getting confused about Integer loops! I had to gaze at this for a while to understand it, and I wrote it!

If you have put the floating text action outside the loop that would stop it working due to the fact you can't refer to Integer A/B outside of their loops.

So, we need to correct that array reference. Seeing as your point_index will move from 1-4 this would be perfect to be used as the array reference for the string variable too. Remember to reset that integer befor you start using it!!

  • Actions
    • Set point_index = 1
    • For each (Integer A) from 1 to 2, do (Actions)
      • Loop - Actions
        • For each (Integer B) from 1 to 2, do (Actions)
          • Loop - Actions
            • Set temp_unit = (Random unit from group[(Integer A)])
            • Set PlayerNames[point_index] = (Name of (Owner of temp_unit))
            • Unit - Move (Triggering unit) instantly to battle_point[point_index], facing Default building facing degrees
            • Unit Group - Remove (Triggering unit) from group[(Integer A)]
            • Unit Group - Add temp_unit to group[3]
            • Set point_index = (point_index + 1)
So now you have 4 names in that PlayerNames variable array. Players on team 1 will be in array 1 and 2 and team 2 will be in 3 and 4.

So then you make your floating text but no need to refer to any Integer A. You would do something similar to the action I wrote in a previous post but for 4 people:
(((PlayerNames[1] + PlayerNames[2])) + vs. ) + (PlayerNames[3] + PlayerNames[4]))
I left that basic for the reason that you will want to format it to your liking.

Confusing?
 
Level 8
Joined
Aug 1, 2008
Messages
420
Yes. Very xD
Loops are so confusing, they could have made them a bit simpler, jeez.
Ill try to understand what you just said :D

Btw, when i place the floating text, I want it to be like this if possible... (had to make screenshot, for some reason wont let me post it like this)

o8gor7.jpg

Something like that. Can i place them all in 1-2 trigger with spaces between the text or am i better off doing it 5 seperate triggers? Just want a masters opinion :xxd:

And i just noticed in my trigger i had
  • Unit - Move temp_unit instantly to battle_point[point_index], facing Default building facing degrees
and you had Move (triggering unit). Did you just mean to copy my trigger and make a mistake or would i now have to change my trigger to triggering unit? Just wondering incase i get it wrong >.>
And how would i reset the integer? I dont really get what you mean >.>
 
Last edited:
Level 8
Joined
Nov 9, 2008
Messages
502
Reset as in re-set. Unless you only use it once if it's not back to default when you use it again it will not work.

Uh the triggering unit thing was a mistake on my part.

Probably the best way to do the text in that case is to have 5 different actions.
Make a new point variable array[5] and pre-set the points like you did for battle_point.
 
Level 8
Joined
Aug 1, 2008
Messages
420
Yeah i did that already 'yay'
How would i reset that integer? I dont think ive ever done that before :/
 
Level 8
Joined
Nov 9, 2008
Messages
502
Set it to 1 seeing as the array it links to goes 1,2,3,4 referring to battle_point[x] and now also PlayerNames[x].

Its a basic moving integer used to call different index inside a loop.

Yah? :wink:
 
Level 8
Joined
Aug 1, 2008
Messages
420
Didnt understand what you just said, but ok xD
edit: i do get it a bit now :p
I was just looking at the triggers, and i dont think point_index can be used. because its still used throughout the trigger. So shall i just copy the trigger and you just have a look at it again? o.0
edit 2: I just tried it, and it worked for 1 person. im gonna try it for the others, ill get back to this thread when i see if it works ;D
edit 4: IT WORKED :D Thanks so much all you guys. thanks alot toofless xD. always be ready to help me again in the future, haha.
Solved!
 
Status
Not open for further replies.
Top