Added Handle of Player trigger to query a player's Battle.net handle
I'm just assuming that it is the number at the end of a player's name, so in this test I should be expecting to get a result of "Fuglypump.835" but I don't
Here's the trigger:
Game-PlayerAnyPlayertypesachatmessagecontaining"-test",matchingExactlyLocalVariablesConditionsActionsGeneral-If(Conditions)thendo(Actions)elsedo(Actions)If(Handleofplayer(Triggeringplayer))==""ThenUI-Display"Handle of player does not exist."for(Playergroup((Triggeringplayer)))toSubtitleareaElseUI-Display(Combine("Your identity is ",(Nameofplayer(Triggeringplayer)),".",(Text((Handleofplayer(Triggeringplayer))))))for(Playergroup((Triggeringplayer)))toSubtitlearea
note: I am signed in online, I can talk to friends and everything, so my identifier should exist, and should be 835.
anyways, am I doing something wrong here? I mean, it isn't complicated at all...
I still don't understand.
Well, I understand what a player handle is, x-s2-x-etc.
But I don't understand how to discover what my handle is.
Because all I am able to display is my player name, Gryffin.
I don't understand how to display my player handle.
You can use the "handle of player" function to get a player's handle. It returns a string, which you can use for whatever purpose you need. Keep in mind that this will NOT work on local tests; you must be playing on battle net.
Display Message to (Chat): Convert String to Text (Handle of Player (1))
Rollback Post to RevisionRollBack
Feel free to Send me a PM if you have any questions/concerns!
No, you do NOT use 'user data' functions. Those are something completely different.
A function is something in programming that takes some values in, and then spits a single value out. Whether you realize it or not, you've probably already used tons of them. Here's some examples of some common functions in starcraft 2:
"Triggering Player" takes no input, but comes back with a number that represents the triggering player
"Number of Players in Player Group" requires you to give a player group, and then spits back out the number of people in the group
"Life of Unit" requires you to specify a particular unit, and it then spits back out the life of whatever unit you specificed
"Handle of Player" is also a function. You have to specify which player's handle you would like, and it spits back out their handle
You can actually create your own functions, but that's a little bit advanced, and it's defiantly not needed for this. This is an example of a trigger to store player 1's handle into a string variable.
Events: Chat Message "MyTest"
MyString (String Variable)
Set Variable (My String) = Handle of Player (Triggering Player)
That's all you need! I'll go step-by-step for making this one though, just in case :P
First, I created a new trigger with a simple chat-triggered event. I also added a local variable called "Player Handle" by right clicking 'local variables' and pressing 'new variable'. This variable must be a string variable.
Next, I make our action. I right click on "actions" and choose "new action". From the list of actions, I selected "Set Variable". I clicked the red "variable" text, and then from the list of variables, I selected by "Player Handle" Variable.
Next, I click the red "value" text. Here's where we're going to need our function. You could just set this text to a specific value, like "Hello World, this is a string". But we don't want that; we want to set this variable to whatever the player's handle is. To do this, we're going to need a function. So click on the 'functions' bubble on the top of the list. Next, type "Handle of Player" in the search box, and select the "Handle of Player" function. If for some reason you don't see the "Handle of Player" function, it's most likely because your variable is an integer, rather than a string.
That's it! This function will now store the handle of whatever player types "MyTest" into a variable. This is sort of useless on it's own though, and want to make sure that everything's working. So we'll have the trigger print your handle onto the screen. Here's what's next:
Add the action "text message". Click on the red "message" text. A player handle is a string, not text. So we're going to need to convert the handle into a string. Luckily for us, there's a function for that! Click on the 'function' bubble again and choose "Convert String to Text" from the list.
Now we've got to set what string we want converted to text. By default, it's set to display the entered chat message. We want it to display the player's handle. To change this value, we can click in either of two places, both shown in the screenshot below (the left parenthesis or the value field):
Finally, click on the variables bubble and select our string variable. That's it, you're done! There's just one small catch- this won't work in a local test. You need to publish your map to battle net and then test it in order for this to work. I attached the map you see in the screenshots below- you can take a look there if you need some additional help. If you're still having trouble, don't hesitate to send me a PM! ;)