From cc62484deb9c3f39d24a078cb1c8c1e71c8156a6 Mon Sep 17 00:00:00 2001 From: Y_Less Date: Fri, 7 Oct 2022 14:06:28 +0100 Subject: [PATCH] `HasGameText` and `GetGameText` natives. --- .../Pawn/Scripting/Player/Natives.cpp | 20 +++++++++++++++++++ Server/Source/player_impl.hpp | 19 ++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/Server/Components/Pawn/Scripting/Player/Natives.cpp b/Server/Components/Pawn/Scripting/Player/Natives.cpp index a190fabbb..86cf54df1 100644 --- a/Server/Components/Pawn/Scripting/Player/Natives.cpp +++ b/Server/Components/Pawn/Scripting/Player/Natives.cpp @@ -1011,6 +1011,26 @@ SCRIPT_API(HideGameTextForPlayer, bool(IPlayer& player, int style)) return true; } +SCRIPT_API(HasGameText, bool(IPlayer& player, int style)) +{ + return player.hasGameText(style); +} + +SCRIPT_API(GetGameText, bool(IPlayer& player, int style, OutputOnlyString& message, int time, int remaining)) +{ + Milliseconds mt; + Milliseconds mr; + String ms; + if (player.getGameText(style, ms, mt, mr)) + { + message = ms; + time = (int)mt.count(); + remaining = (int)mr.count(); + return true; + } + return false; +} + SCRIPT_API(GameTextForPlayerf, bool(IPlayer& player, int time, int style, cell const* format)) { auto string = svprintf(format, GetAMX(), GetParams(), 4); diff --git a/Server/Source/player_impl.hpp b/Server/Source/player_impl.hpp index 748087d83..74fbb3edf 100644 --- a/Server/Source/player_impl.hpp +++ b/Server/Source/player_impl.hpp @@ -1502,6 +1502,25 @@ struct Player final : public IPlayer, public PoolIDProvider, public NoCopy } } + bool hasGameText(int style) override + { + if (IPlayerFixesData* data = queryExtension(*this)) + { + return data->hasGameText(style); + } + return false; + } + + bool getGameText(int style, Impl::String& message, Milliseconds& time, Milliseconds& remaining) override + { + if (IPlayerFixesData* data = queryExtension(*this)) + { + data->getGameText(style, message, time, remaining); + return true; + } + return false; + } + int getVirtualWorld() const override { return virtualWorld_;