// BeamMP, the BeamNG.drive multiplayer mod. // Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors. // // BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com. // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program 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 Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . #pragma once #include #include #include #include namespace LuaAPI { namespace MP { std::string GetOSName(); std::tuple GetServerVersion(); std::pair TriggerClientEvent(int PlayerID, const std::string& EventName, const sol::object& Data); std::pair TriggerClientEventJson(int PlayerID, const std::string& EventName, const sol::table& Data); size_t GetPlayerCount(); std::pair DropPlayer(int ID, std::optional MaybeReason); std::pair SendChatMessage(int ID, const std::string& Message); std::pair RemoveVehicle(int PlayerID, int VehicleID); void Set(int ConfigID, sol::object NewValue); bool IsPlayerGuest(int ID); bool IsPlayerConnected(int ID); /// Returns the current time in millisecond accuracy. size_t GetTimeMS(); /// Returns the current time in seconds, with millisecond accuracy (w/ decimal point). double GetTimeS(); } namespace Util { std::string JsonEncode(const sol::object& object); sol::table JsonDecode(sol::this_state s, const std::string& string); std::string JsonDiff(const std::string& a, const std::string& b); std::string JsonDiffApply(const std::string& data, const std::string& patch); std::string JsonPrettify(const std::string& json); std::string JsonMinify(const std::string& json); std::string JsonFlatten(const std::string& json); std::string JsonUnflatten(const std::string& json); } namespace FS { std::pair CreateDirectory(const std::string& Path); std::pair Remove(const std::string& Path); std::pair Rename(const std::string& Path, const std::string& NewPath); std::pair Copy(const std::string& Path, const std::string& NewPath); std::string GetFilename(const std::string& Path); std::string GetExtension(const std::string& Path); std::string GetParentFolder(const std::string& Path); bool Exists(const std::string& Path); bool IsDirectory(const std::string& Path); bool IsFile(const std::string& Path); std::string ConcatPaths(sol::variadic_args Args); sol::table ListFiles(sol::this_state s, const std::string& path); sol::table ListDirectories(sol::this_state s, const std::string& path); } }