Name based triggers

IDF_ALLAH

New Member
Reaction score
1
Is there a way to make a trigger where

If a player contains a name == to condition,

turn on some functions?
 

Dave312

Censored for your safe viewing
Reaction score
269
I assume you want a condition which will compare a players name with another string. Unfortunately, it seems that access to the players name is not available through the GUI (or at least I could not find it). However by using custom script you should be able to achieve what you want to do:

Code:
        PlayerName(EventPlayer()) == "Dave"

You will need to type in the first half of the line above (up to the '==' sign) as custom script. The PlayerName function returns the players name as text given the player number. The EventPlayer() function just returns the triggering player. A list of functions, their parameters and return types can be found here.
 

s3rius

Linux is only free if your time is worthless.
Reaction score
130
Unfortunately this doesn't work at all.

PlayerName() returns a text and not a string (like we know it from Warcraft 3).
The bad thing about texts are that you cannot compare them, nor turn them into strings.
So there's no way of reading a player's name.

This SUCKS but Blizzard is being ignorant about that.
There was a question during Blizzcon Q&A about this, Blizzard said it was necessary because computer players could have localized names, which can't be returned as strings.
 

IDF_ALLAH

New Member
Reaction score
1
no way to turn into strings...

Is there a way to find out which player color that person belongs to or player ##?
 

Rainther

I guess I should write something of value here...
Reaction score
61
Can you turn the string "Dave" to text otherwise? :3
 

s3rius

Linux is only free if your time is worthless.
Reaction score
130
Can you turn the string "Dave" to text otherwise? :3

Yes, you can. But you can't compare two texts.
Well, you can but it'll only tell you if they're the same object, not if their content is the same.
 

Vestras

Retired
Reaction score
249
Yes, you can. But you can't compare two texts.
Well, you can but it'll only tell you if they're the same object, not if their content is the same.

If there's a Substring function for text types, it could be done.
 

Dave312

Censored for your safe viewing
Reaction score
269
Unfortunately this doesn't work at all.

My bad. It seems very odd that something so simple cannot be done.

If there's a Substring function for text types, it could be done.
Unfortunately you can only take a substring from a String. I've looked through all the other functions and there doesn't appear to be a way to convert text to another type. I wonder whether it would be possible with custom script?
 

s3rius

Linux is only free if your time is worthless.
Reaction score
130
My bad. It seems very odd that something so simple cannot be done.


Unfortunately you can only take a substring from a String. I've looked through all the other functions and there doesn't appear to be a way to convert text to another type. I wonder whether it would be possible with custom script?

It's not possible in custom script either.

Text variables are the only variable type which is asynchronous (well, things like actors can return asynchronous values in some cases afaik). All other variable types are being kept synchronized with all other clients.
Text variables cannot be synchronized, however, because there is a chance that a client's text variables are different from others.
So you should not turn them into, say, strings because there'd be a chance to cause a server split (which is what happened in Wc3 at least).
To prevent this Blizzard didn't include TextToXXX functions.

It just sucks that you can't even get a player's name anymore, though.
 

s3rius

Linux is only free if your time is worthless.
Reaction score
130
players are not represented as player variables in Sc2 anymore. Instead they're a normal integer.

So you can use:
JASS:

    Set MyVariable[(triggering player)] = xyz


If that is what you mean. But this player number changes depending on the slot he's playing in, of course. So it can't serve as a substitute for the player name.

You can also find out the player color somehow, I think.
There are actions for it, I don't know them by heart.
 

s3rius

Linux is only free if your time is worthless.
Reaction score
130
What about getting their name in text and finding which color has that name?

You can't do ANYTHING with texts except of displaying them.

And as I said, there are functions to find out the player's color. But that color changes with every games, so you can't use it as a substitute for a name.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      • Ghan
        Administrator - Servers are fun

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top