L
L
Ledington2021-10-05 07:32:34
C++ / C#
Ledington, 2021-10-05 07:32:34

How to reset the counter and repeat everything over again?

How to reset the counter and start over?
Now it turns out that when it reaches zero, it constantly repeats the message "You ask too often.".
And I would like to start all over again when it reaches zero. Those. for every third request, display the message "You ask too often.".
Tried through while, but then it just ignores the message and issues all requests.

int counter = 2;
if (counter == 0)
{
    return ("", "", "Вы спрашиваете слишком часто.");
}
counter--;
foreach (Player player in Players)
{
    if (player.Name == str)
    {
       return (number: player.Number, gametime: player.GameTime, error: "");
    }
}
return ("", "", "Не удалось найти.");

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2021-10-05
@Ledington

If I understand correctly, then yes.

int counter = 2;
if (counter == 0)
{
 counter = 2;
 return ("", "", "Вы спрашиваете слишком часто.");
}

Although there is a vinaigrette in your code, because at
int counter = 2;
if (counter == 0)

if will never be executed at all...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question