add kickplayer

This commit is contained in:
Huoji's
2023-10-09 01:13:16 +08:00
parent 04b99a12f0
commit 337bf4b5c6
2 changed files with 34 additions and 3 deletions

View File

@@ -258,6 +258,9 @@ auto initVmtHook() -> bool {
return original_OnClientConnected && original_OnClientDisconnect && return original_OnClientConnected && original_OnClientDisconnect &&
origin_StartServer && origin_GameFrame; origin_StartServer && origin_GameFrame;
} }
auto initConVarHooks() -> void {
// Offset::InterFaces::IVEngineCvar->RegisterConVar
}
auto init() -> bool { auto init() -> bool {
bool isSuccess = initMinHook() && initVmtHook(); bool isSuccess = initMinHook() && initVmtHook();
// bool isSuccess = initVmtHook(); // bool isSuccess = initVmtHook();

View File

@@ -672,10 +672,20 @@ auto luaApi_SetPlayerGlowEnable(lua_State* luaVm) -> int {
const auto playerIndex = lua_tointeger(luaVm, 1); const auto playerIndex = lua_tointeger(luaVm, 1);
const auto isEnable = lua_toboolean(luaVm, 2); const auto isEnable = lua_toboolean(luaVm, 2);
ExcutePlayerAction(playerIndex, [&](CCSPlayerController* playerController) { ExcutePlayerAction(playerIndex, [&](CCSPlayerController* playerController) {
LOG("glow set %d to %d \n", playerController->m_hPawn().Get<CBaseModelEntity>()->m_Glow().m_bGlowing(), isEnable); LOG("glow set %d to %d \n",
playerController->m_hPawn().Get<CBaseModelEntity>()->m_Glow().m_bGlowing( playerController->m_hPawn()
.Get<CBaseModelEntity>()
->m_Glow()
.m_bGlowing(),
isEnable); isEnable);
playerController->m_hPawn().Get<CBaseModelEntity>()->m_Glow().m_iGlowType(3); playerController->m_hPawn()
.Get<CBaseModelEntity>()
->m_Glow()
.m_bGlowing(isEnable);
playerController->m_hPawn()
.Get<CBaseModelEntity>()
->m_Glow()
.m_iGlowType(3);
playerController->m_hPawn() playerController->m_hPawn()
.Get<CBaseModelEntity>() .Get<CBaseModelEntity>()
->m_Glow() ->m_Glow()
@@ -690,6 +700,23 @@ auto luaApi_RunServerCommand(lua_State* luaVm) -> int {
lua_pop(luaVm, 1); lua_pop(luaVm, 1);
return 0; return 0;
} }
auto luaApi_KickPlayer(lua_State* luaVm) -> int {
const auto playerIndex = lua_tointeger(luaVm, 1);
const auto reason = lua_tostring(luaVm, 2);
ExcutePlayerAction(playerIndex, [&](CCSPlayerController* playerController) {
auto playerSlot = EntityIndex_to_PlayerSlot(playerIndex);
if (playerSlot == -1) {
return;
}
const auto theReason =
"You have kicked by server , reason: " + std::string(reason);
Offset::InterFaces::IVEngineServer->DisconnectClient(playerSlot, 39);
SdkTools::SentChatToClient(playerController, _HubType::kTalk,
theReason.c_str());
});
lua_pop(luaVm, 2);
return 0;
}
auto luaApi_GetAllPlayerIndex(lua_State* luaVm) -> int { auto luaApi_GetAllPlayerIndex(lua_State* luaVm) -> int {
// param: playerIndex:int, style:int // param: playerIndex:int, style:int
lua_newtable(luaVm); lua_newtable(luaVm);
@@ -757,6 +784,7 @@ auto initFunciton(lua_State* luaVm) -> void {
lua_register(luaVm, "luaApi_SetPlayerGlowColor", luaApi_SetPlayerGlowColor); lua_register(luaVm, "luaApi_SetPlayerGlowColor", luaApi_SetPlayerGlowColor);
lua_register(luaVm, "luaApi_GetAllPlayerIndex", luaApi_GetAllPlayerIndex); lua_register(luaVm, "luaApi_GetAllPlayerIndex", luaApi_GetAllPlayerIndex);
lua_register(luaVm, "luaApi_RunServerCommand", luaApi_RunServerCommand); lua_register(luaVm, "luaApi_RunServerCommand", luaApi_RunServerCommand);
lua_register(luaVm, "luaApi_KickPlayer", luaApi_KickPlayer);
luabridge::getGlobalNamespace(luaVm) luabridge::getGlobalNamespace(luaVm)
.beginClass<_luaApi_WeaponInfo>("WeaponInfo") .beginClass<_luaApi_WeaponInfo>("WeaponInfo")