N
N
NeoLight32020-09-26 11:44:53
C++ / C#
NeoLight3, 2020-09-26 11:44:53

How to send a message about the death of a player in the chat, only 1 time?

I have an object of class Life which has a boolean field death.
I want to work out an event where when a field changes from false (not dead) to true (dead) the
Server sends ONLY ONE TIME a message to the chat.
The problem is that the death field can be true for a while (due to the fact that the player pops up the Respawn menu, where until he respawns, his field will be true), and because of this, the script may work a few once.

public void CheckDeathPlayers()
        {
      for (int i = 0; i < UserList.users.Count; i++)
            {
        BetterNetworkUser player = UserList.users[i];
        Life plife = player.player.GetComponent<Life>();
                if (plife.bool_2)
                {
          DeathMsg(player.name, plife.string_0);
                }
            }
        }


PS I don't have access to the source code of the game, I'm just writing a plugin for this game.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2020-09-28
@NeoLight3

Make in which the names of all deceased players. When a player dies, check if this HashSet has a name. If not, make a notification and add this name, and if it already exists, just ignore this event. HashSet<string>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question