@@ -241,6 +241,46 @@ std::pair<bool, std::string> LuaAPI::MP::SendNotification(int ID, const std::str
241241 return Result;
242242}
243243
244+ std::pair<bool , std::string> LuaAPI::MP::ConfirmationDialog (int ID, const std::string& Title, const std::string& Body, const sol::table& buttons, const std::string& InteractionID, const bool & warning) {
245+ std::pair<bool , std::string> Result;
246+
247+ const nlohmann::json PacketBody = {
248+ { " title" , Title },
249+ { " body" , Body },
250+ { " buttons" , nlohmann::json::parse (JsonEncode (buttons), nullptr , false ) },
251+ { " interactionID" , InteractionID },
252+ { " class" , warning ? " experimental" : " " }
253+ };
254+
255+ std::string Packet = " D" + PacketBody.dump ();
256+ if (ID == -1 ) {
257+ Engine->Network ().SendToAll (nullptr , StringToVector (Packet), true , true );
258+ Result.first = true ;
259+ } else {
260+ auto MaybeClient = GetClient (Engine->Server (), ID);
261+ if (MaybeClient) {
262+ auto c = MaybeClient.value ().lock ();
263+ if (!c->IsSynced ()) {
264+ Result.first = false ;
265+ Result.second = " Player is not synced yet" ;
266+ return Result;
267+ }
268+ if (!Engine->Network ().Respond (*c, StringToVector (Packet), true )) {
269+ beammp_errorf (" Failed to send confirmation dialog to player (id {}) - did the player disconnect?" , ID);
270+ Result.first = false ;
271+ Result.second = " Failed to send packet" ;
272+ }
273+ Result.first = true ;
274+ } else {
275+ beammp_lua_error (" ConfirmationDialog invalid argument [1] invalid ID" );
276+ Result.first = false ;
277+ Result.second = " Invalid Player ID" ;
278+ }
279+ return Result;
280+ }
281+ return Result;
282+ }
283+
244284std::pair<bool , std::string> LuaAPI::MP::RemoveVehicle (int PID, int VID) {
245285 std::pair<bool , std::string> Result;
246286 auto MaybeClient = GetClient (Engine->Server (), PID);
0 commit comments