@@ -1247,10 +1247,31 @@ int CLuaPedDefs::GetPedClothes(lua_State* luaVM)
1247
1247
return 1 ;
1248
1248
}
1249
1249
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)
1251
1251
{
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
+ }
1253
1272
1273
+ bool state;
1274
+
1254
1275
if (!CStaticFunctionDefinitions::GetPedControlState (*ped, control, state))
1255
1276
return false ;
1256
1277
@@ -1803,8 +1824,38 @@ int CLuaPedDefs::RemovePedClothes(lua_State* luaVM)
1803
1824
return 1 ;
1804
1825
}
1805
1826
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)
1807
1828
{
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
+
1808
1859
return CStaticFunctionDefinitions::SetPedControlState (*ped, control, state);
1809
1860
}
1810
1861
0 commit comments