Add MP.SendNotification (#373)

Adds MP.SendNotification(message, icon, category (optional) ) to the Lua
api. Uses the newly added "N" packet in the mod.
This commit is contained in:
Lion
2024-10-05 16:07:27 +02:00
committed by GitHub
3 changed files with 41 additions and 0 deletions

View File

@@ -869,6 +869,15 @@ TLuaEngine::StateThreadData::StateThreadData(const std::string& Name, TLuaStateI
return Lua_GetPositionRaw(PID, VID);
});
MPTable.set_function("SendChatMessage", &LuaAPI::MP::SendChatMessage);
MPTable.set_function("SendNotification", [&](sol::variadic_args Args) {
if (Args.size() == 3) {
LuaAPI::MP::SendNotification(Args.get<int>(0), Args.get<std::string>(1), Args.get<std::string>(2), Args.get<std::string>(1));
} else if (Args.size() == 4) {
LuaAPI::MP::SendNotification(Args.get<int>(0), Args.get<std::string>(1), Args.get<std::string>(2), Args.get<std::string>(3));
} else {
beammp_lua_error("SendNotification expects 2 or 3 arguments.");
}
});
MPTable.set_function("GetPlayers", [&]() -> sol::table {
return Lua_GetPlayers();
});