ZombieCooKie 10 Posted November 18, 2018 I want to send message to players with survivor in name. I need the correct syntax for the if section. if (player.GetIdentity().GetName() contains? "Survivor") { ... } Share this post Link to post Share on other sites
lbmaster 21 Posted November 18, 2018 Should work. Would be if (player.GetIdentity().GetName().Contains("Survivor")) { } Share this post Link to post Share on other sites
Dancing.Russian.Man 1631 Posted November 18, 2018 (edited) If you want to send a message to players whose name is exactly "Survivor" (case-sensitive) and nothing else, you would just.. if( player.GetIdentity().GetName() == "Survivor" ) I don't know if the Contains function is case-sensitive, but it would return true as long as they had "Survivor" as any part of their name. Edited November 18, 2018 by Dancing.Russian.Man Share this post Link to post Share on other sites
ZombieCooKie 10 Posted November 18, 2018 1 hour ago, lbmaster said: Should work. Would be if (player.GetIdentity().GetName().Contains("Survivor")) { } This works. Thank you :) Share this post Link to post Share on other sites
IMT 3190 Posted November 18, 2018 (edited) 2 hours ago, Dancing.Russian.Man said: If you want to send a message to players whose name is exactly "Survivor" (case-sensitive) and nothing else, you would just.. if( player.GetIdentity().GetName() == "Survivor" ) I don't know if the Contains function is case-sensitive, but it would return true as long as they had "Survivor" as any part of their name. I'm not sure how it works in Enscript but in Java calling == on Strings it compares object references. In order to compare the values, one would use the equals method. So this might or might not work, depends on Enscript I guess. Edited November 18, 2018 by IMT Share this post Link to post Share on other sites
Dancing.Russian.Man 1631 Posted November 18, 2018 (edited) 4 minutes ago, IMT said: I'm not sure how it works in Enscript but in Java calling == on Strings it compares object references. In order to compare the values, one would use the equals method. Enscript is very heavily C-based language, to the point of using ".c" as the file extension for scripts. I know Java handles comparisons differently, but I assure you, this is how it works in C/C++/C#. In C++, if you wanted to compare the objects themselves, you would compare the memory address of those objects. In C#, if you wanted to compare the objects themselves, you would use System.Object.ReferenceEquals(object, object) Edited November 18, 2018 by Dancing.Russian.Man 1 Share this post Link to post Share on other sites
lbmaster 21 Posted November 18, 2018 5 hours ago, Dancing.Russian.Man said: Enscript is very heavily C-based language, to the point of using ".c" as the file extension for scripts. I know Java handles comparisons differently, but I assure you, this is how it works in C/C++/C#. In C++, if you wanted to compare the objects themselves, you would compare the memory address of those objects. In C#, if you wanted to compare the objects themselves, you would use System.Object.ReferenceEquals(object, object) Very good to know. I come from the Java side and allways wondered how EnforceScript handles this. Share this post Link to post Share on other sites