A
A
Alexey2020-09-13 01:17:51
C++ / C#
Alexey, 2020-09-13 01:17:51

How to pass value by C# API?

Unable to pass boolean value from variable "bool PeremenayaA = true;" in API "private object ApiFunction()" . An error occurs - The name `PeremenayaA' does not exist in the current context.

[ChatCommand("block")]
        public void cmdChatDrawBlock(BasePlayer player)
        {
            player.SetFlag(BaseEntity.Flags.Reserved3, true);
            DrawBlockGUI(player);
      if (player != null)
      {
        bool PeremenayaA = true;
      }
        }
  private object АпиФункция()
        {
            var Переменная_с_Данными_Отправки = PeremenayaA;
            return Переменная_с_Данными_Отправки; //отправляем данные.
        }

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman, 2020-09-13
@yarosroman

Make it a class field

M
mbjuggernaut, 2020-09-16
@mbjuggernaut

Roman is absolutely right.
Now you are creating a variable, but it remains in the place where you created it.
Or you must have a class field, in which case it would be player.PeremenayaA= true;
Either the function must take a value, such as private object ApiFunction(PeremenayaA) and be called in the same place where you create the variable.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question