mirror of
https://github.com/SantaSpeen/BeamMP-Server.git
synced 2026-10-27 09:59:57 +00:00
Modify LUA
This commit is contained in:
1 parent
fb52f01295
commit
842d142a0e
3 files changed
+30
No files matched your search
@@ -36,4 +36,8 @@ namespace LuaAPI {
|
|||||||
bool IsFile(const std::string& Path);
|
bool IsFile(const std::string& Path);
|
||||||
std::string ConcatPaths(sol::variadic_args Args);
|
std::string ConcatPaths(sol::variadic_args Args);
|
||||||
}
|
}
|
||||||
|
namespace CL {
|
||||||
|
void SendPacket(int ID, const std::string& Packet);
|
||||||
|
void SendNotify(int ID, const std::string& Notify);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -352,3 +352,24 @@ std::string LuaAPI::FS::ConcatPaths(sol::variadic_args Args) {
|
|||||||
auto Result = Path.lexically_normal().string();
|
auto Result = Path.lexically_normal().string();
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LuaAPI::CL::SendPacket(int ID, const std::string& Packet) {
|
||||||
|
if (ID == -1) {
|
||||||
|
LuaAPI::MP::Engine->Network().SendToAll(nullptr, Packet, true, true);
|
||||||
|
} else {
|
||||||
|
auto MaybeClient = GetClient(LuaAPI::MP::Engine->Server(), ID);
|
||||||
|
if (MaybeClient && !MaybeClient.value().expired()) {
|
||||||
|
auto c = MaybeClient.value().lock();
|
||||||
|
if (!c->IsSynced())
|
||||||
|
return;
|
||||||
|
beammp_info("[LUA] Send packet to <" + c->GetName() + ">: " + Packet);
|
||||||
|
LuaAPI::MP::Engine->Network().Respond(*c, Packet, true);
|
||||||
|
} else {
|
||||||
|
beammp_lua_error("SendChatMessage invalid argument [1] invalid ID");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LuaAPI::CL::SendNotify(int ID, const std::string& Notify) {
|
||||||
|
SendPacket(ID, "L:Server: " + Notify);
|
||||||
|
}
|
||||||
@@ -568,6 +568,11 @@ TLuaEngine::StateThreadData::StateThreadData(const std::string& Name, std::atomi
|
|||||||
FSTable.set_function("IsDirectory", &LuaAPI::FS::IsDirectory);
|
FSTable.set_function("IsDirectory", &LuaAPI::FS::IsDirectory);
|
||||||
FSTable.set_function("IsFile", &LuaAPI::FS::IsFile);
|
FSTable.set_function("IsFile", &LuaAPI::FS::IsFile);
|
||||||
FSTable.set_function("ConcatPaths", &LuaAPI::FS::ConcatPaths);
|
FSTable.set_function("ConcatPaths", &LuaAPI::FS::ConcatPaths);
|
||||||
|
|
||||||
|
auto CLTable = StateView.create_named_table("CL");
|
||||||
|
CLTable.set_function("SendPacket", &LuaAPI::CL::SendPacket);
|
||||||
|
CLTable.set_function("SendNotify", &LuaAPI::CL::SendNotify);
|
||||||
|
|
||||||
Start();
|
Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user