add luaApi_RunClientCommand
This commit is contained in:
@@ -714,6 +714,16 @@ auto luaApi_RunServerCommand(lua_State* luaVm) -> int {
|
|||||||
lua_pop(luaVm, 1);
|
lua_pop(luaVm, 1);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
auto luaApi_RunClientCommand(lua_State* luaVm) -> int {
|
||||||
|
const auto playerIndex = lua_tointeger(luaVm, 1);
|
||||||
|
const auto command = lua_tostring(luaVm, 2);
|
||||||
|
|
||||||
|
ExcutePlayerAction(playerIndex, [&](CCSPlayerController* playerController) {
|
||||||
|
Offset::InterFaces::IVEngineServer->ClientCommand(EntityIndex_to_PlayerSlot(playerIndex), command);
|
||||||
|
});
|
||||||
|
lua_pop(luaVm, 2);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
auto luaApi_GetPlayerSteamId(lua_State* luaVm) -> int {
|
auto luaApi_GetPlayerSteamId(lua_State* luaVm) -> int {
|
||||||
const auto playerIndex = lua_tointeger(luaVm, 1);
|
const auto playerIndex = lua_tointeger(luaVm, 1);
|
||||||
std::string steamid;
|
std::string steamid;
|
||||||
@@ -874,15 +884,20 @@ auto luaApi_HttpAsyncGet(lua_State* luaVm) -> int {
|
|||||||
}
|
}
|
||||||
auto luaApi_GetConVarString(lua_State* luaVm) -> int {
|
auto luaApi_GetConVarString(lua_State* luaVm) -> int {
|
||||||
// param: convarObject:int
|
// param: convarObject:int
|
||||||
ConVarHandle theConvarHandle{};
|
const auto inputData = lua_tointeger(luaVm, 1);
|
||||||
theConvarHandle.Set(lua_tointeger(luaVm, 1));
|
|
||||||
std::string value;
|
std::string value;
|
||||||
if (theConvarHandle.IsValid()) {
|
if (inputData != NULL) {
|
||||||
const auto convarData =
|
ConVarHandle theConvarHandle{};
|
||||||
Offset::InterFaces::IVEngineCvar->GetConVar(theConvarHandle);
|
theConvarHandle.Set(inputData);
|
||||||
const auto address = convarData->values;
|
if (theConvarHandle.IsValid()) {
|
||||||
const auto valueData = reinterpret_cast<char*>(address);
|
const auto convarData =
|
||||||
value = convarData ? std::string(valueData) : "";
|
Offset::InterFaces::IVEngineCvar->GetConVar(theConvarHandle);
|
||||||
|
if (convarData) {
|
||||||
|
const auto address = convarData->values;
|
||||||
|
const auto valueData = reinterpret_cast<char*>(address);
|
||||||
|
value = valueData ? std::string(valueData) : "";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
lua_pop(luaVm, 1);
|
lua_pop(luaVm, 1);
|
||||||
lua_pushstring(luaVm, value.c_str());
|
lua_pushstring(luaVm, value.c_str());
|
||||||
@@ -891,16 +906,20 @@ auto luaApi_GetConVarString(lua_State* luaVm) -> int {
|
|||||||
}
|
}
|
||||||
auto luaApi_GetConVarInt(lua_State* luaVm) -> int {
|
auto luaApi_GetConVarInt(lua_State* luaVm) -> int {
|
||||||
// param: convarObject:int
|
// param: convarObject:int
|
||||||
ConVarHandle theConvarHandle{};
|
const auto inputData = lua_tointeger(luaVm, 1);
|
||||||
theConvarHandle.Set(lua_tointeger(luaVm, 1));
|
if (inputData)
|
||||||
int value = -1;
|
{
|
||||||
if (theConvarHandle.IsValid()) {
|
ConVarHandle theConvarHandle{};
|
||||||
const auto convarData =
|
theConvarHandle.Set(inputData);
|
||||||
Offset::InterFaces::IVEngineCvar->GetConVar(theConvarHandle);
|
int value = -1;
|
||||||
value = reinterpret_cast<int>(convarData->values);
|
if (theConvarHandle.IsValid()) {
|
||||||
|
const auto convarData =
|
||||||
|
Offset::InterFaces::IVEngineCvar->GetConVar(theConvarHandle);
|
||||||
|
value = convarData ? reinterpret_cast<int>(convarData->values) : -1;
|
||||||
|
}
|
||||||
|
lua_pop(luaVm, 1);
|
||||||
|
lua_pushinteger(luaVm, value);
|
||||||
}
|
}
|
||||||
lua_pop(luaVm, 1);
|
|
||||||
lua_pushinteger(luaVm, value);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
auto luaApi_GetConVarObject(lua_State* luaVm) -> int {
|
auto luaApi_GetConVarObject(lua_State* luaVm) -> int {
|
||||||
@@ -964,6 +983,8 @@ auto initFunciton(lua_State* luaVm) -> void {
|
|||||||
lua_register(luaVm, "luaApi_GetConVarString", luaApi_GetConVarString);
|
lua_register(luaVm, "luaApi_GetConVarString", luaApi_GetConVarString);
|
||||||
lua_register(luaVm, "luaApi_GetConVarInt", luaApi_GetConVarInt);
|
lua_register(luaVm, "luaApi_GetConVarInt", luaApi_GetConVarInt);
|
||||||
lua_register(luaVm, "luaApi_GetPlayerSteamId", luaApi_GetPlayerSteamId);
|
lua_register(luaVm, "luaApi_GetPlayerSteamId", luaApi_GetPlayerSteamId);
|
||||||
|
lua_register(luaVm, "luaApi_GetPlayerSteamId", luaApi_GetPlayerSteamId);
|
||||||
|
lua_register(luaVm, "luaApi_RunClientCommand", luaApi_RunClientCommand);
|
||||||
|
|
||||||
// lua_register(luaVm, "luaApi_TeleportPlayer", luaApi_TeleportPlayer);
|
// lua_register(luaVm, "luaApi_TeleportPlayer", luaApi_TeleportPlayer);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user