Skip to content

Commit aaa5854

Browse files
committed
feat(scripting/player): PerformMenuAction
1 parent b3423c4 commit aaa5854

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

src/plugins/core/scripting.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,8 @@ class PluginPlayer
729729

730730
void QueryConvar(std::string cvar_name);
731731

732+
void PerformMenuAction(std::string action, int value);
733+
732734
bool IsValid();
733735
};
734736

src/plugins/core/scripting/player/player.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,4 +461,20 @@ bool PluginPlayer::IsValid()
461461
if (!pawn) return false;
462462

463463
return true;
464+
}
465+
466+
void PluginPlayer::PerformMenuAction(std::string action, int value)
467+
{
468+
Player* self = g_playerManager->GetPlayer(this->playerId);
469+
if (!self) return;
470+
471+
if(action == "useOption") {
472+
while(self->GetSelection() != value-1)
473+
self->MoveSelection();
474+
475+
self->PerformMenuAction(g_Config->FetchValue<std::string>("core.menu.buttons.use"));
476+
} else if(action == "scrollToOption") {
477+
while(self->GetSelection() != value-1)
478+
self->MoveSelection();
479+
}
464480
}

src/plugins/lua/scripting/player/player.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ LoadLuaScriptingComponent(
7979
.addFunction("GetConnectedTime", &PluginPlayer::GetConnectedTime)
8080
.addFunction("GetWeaponManager", &PluginPlayer::GetWeaponManager)
8181
.addFunction("QueryConvar", &PluginPlayer::QueryConvar)
82+
.addFunction("PerformMenuAction", &PluginPlayer::PerformMenuAction)
8283
.addFunction("IsValid", &PluginPlayer::IsValid)
8384
.endClass()
8485
.addFunction("GetPlayer", scripting_GetPlayer);

0 commit comments

Comments
 (0)