Skip to content

Commit

Permalink
HasGameText and GetGameText natives.
Browse files Browse the repository at this point in the history
  • Loading branch information
Y_Less committed Nov 22, 2022
1 parent a7e851e commit cc62484
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Server/Components/Pawn/Scripting/Player/Natives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
19 changes: 19 additions & 0 deletions Server/Source/player_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1502,6 +1502,25 @@ struct Player final : public IPlayer, public PoolIDProvider, public NoCopy
}
}

bool hasGameText(int style) override
{
if (IPlayerFixesData* data = queryExtension<IPlayerFixesData>(*this))
{
return data->hasGameText(style);
}
return false;
}

bool getGameText(int style, Impl::String& message, Milliseconds& time, Milliseconds& remaining) override
{
if (IPlayerFixesData* data = queryExtension<IPlayerFixesData>(*this))
{
data->getGameText(style, message, time, remaining);
return true;
}
return false;
}

int getVirtualWorld() const override
{
return virtualWorld_;
Expand Down

0 comments on commit cc62484

Please sign in to comment.