Jump to content

Forums Announcement

Read-Only Mode for Announcements & Changelogs

Dear Survivors, we'd like to inform you that this forum will transition to read-only mode. From now on, it will serve exclusively as a platform for official announcements and changelogs.

For all community discussions, debates, and engagement, we encourage you to join us on our social media platforms: Discord, Twitter/X, Facebook.

Thank you for being a valued part of our community. We look forward to connecting with you on our other channels!

Stay safe out there,
Your DayZ Team

ZombieCooKie

Need short help for correct syntax

Recommended Posts

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

Should work. Would be
 

if (player.GetIdentity().GetName().Contains("Survivor")) {

}

 

Share this post


Link to post
Share on other sites

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 by Dancing.Russian.Man

Share this post


Link to post
Share on other sites
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
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 by IMT

Share this post


Link to post
Share on other sites
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 by Dancing.Russian.Man
  • Thanks 1

Share this post


Link to post
Share on other sites
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

×