When I want to send a proto message I get this error:
PHP Code:
L 12/12/2021 - 12:02:52: [SM] Exception reported: Unable to execute a new message, there is already one in progress
L 12/12/2021 - 12:02:52: [SM] Blaming: instructortest.smx
L 12/12/2021 - 12:02:52: [SM] Call stack trace:
L 12/12/2021 - 12:02:52: [SM] [0] StartMessageEx
L 12/12/2021 - 12:02:52: [SM] [1] Line 35, instructortest.sp::LoadStuff
I tried to change the time offset in the timer, but it appears that there is always a message which blocks mine. I tried to call EndMessage() prior to sending my message, but it only crashes the server.
How can I catch the moment when there is no processing message so I could send mine?
PHP Code:
UserMsg g_FadeUserMsgId;
public OnPluginStart()
{
HookEvent("player_spawn", SpawnEvent);
}
public Action:SpawnEvent(Handle:event,const String:name[],bool:dontBroadcast)
{
new client_id = GetEventInt(event, "userid");
new client = GetClientOfUserId(client_id);
g_FadeUserMsgId = GetUserMessageId("Train");
CreateTimer(1.0, LoadStuff, client);
}
public Action LoadStuff(Handle timer, int client)
{
int clients[2];
clients[0] = client;
Handle message = StartMessageEx(g_FadeUserMsgId, clients, 1);
if(message != INVALID_HANDLE)
{
Protobuf pb = UserMessageToProtobuf(message);
PbSetInt(pb, "hint_static", 1);
PbSetFloat(pb, "hint_timeout", 0.1);
PbSetString(pb, "hint_icon_onscreen", "use_binding");
PbSetString(pb, "hint_icon_offscreen", "use_binding");
PbSetString(pb, "hint_binding", "use");
PbSetString(pb, "hint_caption", "Hello");
}
EndMessage();
}