[РЕШЕНО] Ошибка "Could not send a usermessage"

Nova

Simple Project
Сообщения
262
Реакции
28
Когда в чате появляется сообщение some_text, нужно отправить сообщение игроку, id которого записано в переменной g_iClient. Но при выполнении функции MyFunction(client) происходит ошибка. В чём проблема и как её решить?

PHP:
#pragma semicolon 1

new g_iClient;

public OnPluginStart()
{
    HookUserMessage(GetUserMessageId("TextMsg"), HookUserMessage_TextMsg, true);
}

public Action:HookUserMessage_TextMsg(UserMsg:msg_id, Handle:msg, const players[], playersNum, bool:reliable, bool:init)
{
    BfReadByte(msg);
    BfReadByte(msg);
 
    decl String:sBuffer[256];
    BfReadString(msg, sBuffer, sizeof(sBuffer));
 
    if (StrContains(sBuffer, "some_text", false) != -1)
    {
        MyFunction(g_iClient);
    }
 
    return Plugin_Continue;
}

public MyFunction(client)
{
    PrintToChat(client, "[SM] Success!");
}
L 02/16/2019 - 22:55:24: [SM] Native "PrintToChat" reported: Could not send a usermessage
L 02/16/2019 - 22:55:24: [SM] Displaying call stack trace for plugin "plugin.smx":
L 02/16/2019 - 22:55:24: [SM] [0] Line 49, С:\...\cstrike\addons\sourcemod\scripting\doc.sp::MyFunction()
L 02/16/2019 - 22:55:24: [SM] [1] Line 41, С:\...\cstrike\addons\sourcemod\scripting\doc.sp::HookUserMessage_TextMsg()
 

Черная вдова

Участник
Сообщения
2,795
Реакции
670
Когда в чате появляется сообщение some_text, нужно отправить сообщение игроку, id которого записано в переменной g_iClient. Но при выполнении функции MyFunction(client) происходит ошибка. В чём проблема и как её решить?

PHP:
#pragma semicolon 1

new g_iClient;

public OnPluginStart()
{
    HookUserMessage(GetUserMessageId("TextMsg"), HookUserMessage_TextMsg, true);
}

public Action:HookUserMessage_TextMsg(UserMsg:msg_id, Handle:msg, const players[], playersNum, bool:reliable, bool:init)
{
    BfReadByte(msg);
    BfReadByte(msg);
  
    decl String:sBuffer[256];
    BfReadString(msg, sBuffer, sizeof(sBuffer));
  
    if (StrContains(sBuffer, "some_text", false) != -1)
    {
        MyFunction(g_iClient);
    }
  
    return Plugin_Continue;
}

public MyFunction(client)
{
    PrintToChat(client, "[SM] Success!");
}

L 02/16/2019 - 22:55:24: [SM] Native "PrintToChat" reported: Could not send a usermessage
L 02/16/2019 - 22:55:24: [SM] Displaying call stack trace for plugin "plugin.smx":
L 02/16/2019 - 22:55:24: [SM] [0] Line 49, С:\...\cstrike\addons\sourcemod\scripting\doc.sp::MyFunction()
L 02/16/2019 - 22:55:24: [SM] [1] Line 41, DС:\...\cstrike\addons\sourcemod\scripting\doc.sp::HookUserMessage_TextMsg()
нельзя отправлять сообщение во время отправки другого
 

Rabb1t

Амбассадор
Сообщения
2,968
Реакции
1,429
  • Команда форума
  • #4
@Nova, юзани таймер, например.
 
Сверху Снизу