@@ -1247,10 +1247,31 @@ int CLuaPedDefs::GetPedClothes(lua_State* luaVM)
12471247 return 1 ;
12481248}
12491249
1250- bool CLuaPedDefs::GetPedControlState (CClientPed* const ped, const std::string control) noexcept
1250+ bool CLuaPedDefs::GetPedControlState (std::variant< CClientPed*, std::string> first, std::optional<std:: string> maybeControl)
12511251{
1252- bool state;
1252+ CClientPed* ped{};
1253+ std::string control{};
1254+
1255+ if (std::holds_alternative<CClientPed*>(first))
1256+ {
1257+ if (!maybeControl.has_value ())
1258+ throw std::invalid_argument (" Expected control name at argument 2" );
1259+
1260+ ped = std::get<CClientPed*>(first);
1261+ control = maybeControl.value ();
1262+ }
1263+ else if (std::holds_alternative<std::string>(first))
1264+ {
1265+ ped = CStaticFunctionDefinitions::GetLocalPlayer ();
1266+ control = std::get<std::string>(first);
1267+ }
1268+ else
1269+ {
1270+ throw std::invalid_argument (" Expected ped or control name at argument 1" );
1271+ }
12531272
1273+ bool state;
1274+
12541275 if (!CStaticFunctionDefinitions::GetPedControlState (*ped, control, state))
12551276 return false ;
12561277
@@ -1803,8 +1824,38 @@ int CLuaPedDefs::RemovePedClothes(lua_State* luaVM)
18031824 return 1 ;
18041825}
18051826
1806- bool CLuaPedDefs::SetPedControlState (CClientPed* const ped, const std::string control, const bool state) noexcept
1827+ bool CLuaPedDefs::SetPedControlState (std::variant< CClientPed*, std::string> first, std::variant<std:: string, bool > second, std::optional< bool > maybeState)
18071828{
1829+ CClientPed* ped{};
1830+ std::string control{};
1831+ bool state{};
1832+
1833+ if (std::holds_alternative<CClientPed*>(first))
1834+ {
1835+ if (!std::holds_alternative<std::string>(second))
1836+ throw std::invalid_argument (" Expected control name at argument 2" );
1837+
1838+ if (!maybeState.has_value ())
1839+ throw std::invalid_argument (" Expected state boolean at argument 3" );
1840+
1841+ ped = std::get<CClientPed*>(first);
1842+ control = std::get<std::string>(second);
1843+ state = maybeState.value ();
1844+ }
1845+ else if (std::holds_alternative<std::string>(first))
1846+ {
1847+ if (!std::holds_alternative<bool >(second))
1848+ throw std::invalid_argument (" Expected state boolean at argument 2" );
1849+
1850+ ped = CStaticFunctionDefinitions::GetLocalPlayer ();
1851+ control = std::get<std::string>(first);
1852+ state = std::get<bool >(second);
1853+ }
1854+ else
1855+ {
1856+ throw std::invalid_argument (" Expected ped or control name at argument 1" );
1857+ }
1858+
18081859 return CStaticFunctionDefinitions::SetPedControlState (*ped, control, state);
18091860}
18101861
0 commit comments