In file included from /home/fabius/plugins/metamod-source/samples/counterstrikesharp/src/scripting/natives/natives_protobufs.cpp:26:
/home/fabius/plugins/metamod-source/samples/counterstrikesharp/src/scripting/autonative.h:43:78: warning: backslash-newline at end of file
   43 | #define CREATE_SETTER_FUNCTION(type_name, get_type, name, from_type, setter) \
      |
/home/fabius/plugins/metamod-source/samples/counterstrikesharp/src/scripting/natives/natives_protobufs.cpp: In member function ‘virtual void Nativesprotobufs::OnAllInitialized()’:
/home/fabius/plugins/metamod-source/samples/counterstrikesharp/src/scripting/natives/natives_protobufs.cpp:104:5: error: ‘ScriptEngine’ has not been declared
  104 |     ScriptEngine::RegisterNativeHandler("SEND_PROTOBUF", SendProtobuf);
      |     ^~~~~~~~~~~~
/home/fabius/plugins/metamod-source/samples/counterstrikesharp/src/scripting/autonative.h:29:42: note: in definition of macro ‘REGISTER_NATIVES’
   29 |         void OnAllInitialized() override method                    \
      |                                          ^~~~~~
/home/fabius/plugins/metamod-source/samples/counterstrikesharp/src/scripting/natives/natives_protobufs.cpp:104:58: error: ‘SendProtobuf’ was not declared in this scope; did you mean ‘counterstrikesharp::SendProtobuf’?
  104 |     ScriptEngine::RegisterNativeHandler("SEND_PROTOBUF", SendProtobuf);
      |                                                          ^~~~~~~~~~~~
/home/fabius/plugins/metamod-source/samples/counterstrikesharp/src/scripting/autonative.h:29:42: note: in definition of macro ‘REGISTER_NATIVES’
   29 |         void OnAllInitialized() override method                    \
      |                                          ^~~~~~
/home/fabius/plugins/metamod-source/samples/counterstrikesharp/src/scripting/natives/natives_protobufs.cpp:42:10: note: ‘counterstrikesharp::SendProtobuf’ declared here
   42 |     void SendProtobuf(ScriptContext& script_context) {
      |          ^~~~~~~~~~~~
/home/fabius/plugins/metamod-source/samples/counterstrikesharp/src/scripting/natives/natives_protobufs.cpp: At global scope:
/home/fabius/plugins/metamod-source/samples/counterstrikesharp/src/scripting/natives/natives_protobufs.cpp:106:1: error: expected declaration before ‘}’ token
  106 | }  // namespace counterstrikesharp
      | ^
make[2]: *** [CMakeFiles/counterstrikesharp.dir/build.make:472: CMakeFiles/counterstrikesharp.dir/src/scripting/natives/natives_protobufs.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:646: CMakeFiles/counterstrikesharp.dir/all] Error 2
make: *** [Makefile:156: all] Error 2


/*
 *  This file is part of CounterStrikeSharp.
 *  CounterStrikeSharp is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  CounterStrikeSharp is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with CounterStrikeSharp.  If not, see <https://www.gnu.org/licenses/>. *
 */

#include <ios>
#include <sstream>

#include "core/log.h"
#include "protobuf/generated/cstrike15_usermessages.pb.h"
#include <igameeventsystem.h>
#include <networksystem/inetworkserializer.h>
#include <networksystem/inetworkmessages.h>
#include "scripting//callback_manager.h"
#include "scripting/autonative.h"
#include "scripting/script_engine.h"
#include "natives_protobufs.h"
#include "google/protobuf/message.h"
#include "google/protobuf/message_lite.h"
#include <google/protobuf/dynamic_message.h>
#include <google/protobuf/compiler/importer.h>


namespace counterstrikesharp {

    enum Protobuf_t {
        cstrike15_usermessages,
        netmessages,
    };

    void SendProtobuf(ScriptContext& script_context) {
        int client = script_context.GetArgument<int>(0);
        bool is_filter = script_context.GetArgument<bool>(1);
        const char* msg_type_name = script_context.GetArgument<const char*>(2);
        const char* data = script_context.GetArgument<const char*>(3);
        auto protobuf_enum = script_context.GetArgument<Protobuf_t>(4);

        //CSSHARP_CORE_INFO("{0} | {1} | {2} | {3} | {4}", client, is_filter, msg_type_name, data, protobuf_enum);

        CRecipientFilter filter;
        if (is_filter) {
            CPlayerSlot PlayerSlot(client);
            filter.AddRecipient(PlayerSlot);
        }

        std::string protobuf_file_name = protobuf_enum == cstrike15_usermessages ? "cstrike15_usermessages" : "netmessages";

        INetworkSerializable* message_type = globals::networkMessages->FindNetworkMessagePartial(msg_type_name);
        if (!message_type) {
            CSSHARP_CORE_INFO("Message type not found in registry.");
            return;
        }

        ::google::protobuf::compiler::DiskSourceTree source_tree;
        source_tree.MapPath("", "./src/protobuf/");

        ::google::protobuf::compiler::Importer importer(&source_tree, nullptr);

        std::string import_path = "src/protobuf/" + protobuf_file_name + ".proto";
        const ::google::protobuf::FileDescriptor* file_descriptor = importer.Import(import_path);
        if (!file_descriptor) {
            CSSHARP_CORE_INFO("Failed to import protobuf definition.");
            return;
        }

        const ::google::protobuf::Descriptor* descriptor = importer.pool()->FindMessageTypeByName(msg_type_name);
        if (!descriptor) {
            CSSHARP_CORE_INFO("Unknown message type.");
            return;
        }

        ::google::protobuf::DynamicMessageFactory factory;
        std::unique_ptr<::google::protobuf::Message> message(factory.GetPrototype(descriptor)->New());

        if (message->ParseFromArray(data, strlen(data)))
        {
            globals::gameEventSystem->PostEventAbstract(0, false, &filter, message_type, message.get(), 0);
            CSSHARP_CORE_INFO("Successfully parsed and sent message of type {}", msg_type_name);
        }
        else
        {
            CSSHARP_CORE_INFO("Failed to parse message of type {}", msg_type_name);
        }
    }

    REGISTER_NATIVES(protobufs, {
        ScriptEngine::RegisterNativeHandler("SEND_PROTOBUF", SendProtobuf);
    })

} // namespace counterstrikesharp

REGISTER_NATIVES(protobufs, {
    ScriptEngine::RegisterNativeHandler("SEND_PROTOBUF", SendProtobuf);
})
}  // namespace counterstrikesharp


исправь