Skip to content
This repository has been archived by the owner on Oct 25, 2023. It is now read-only.

Commit

Permalink
add kickplayer
Browse files Browse the repository at this point in the history
  • Loading branch information
huoji120 committed Oct 8, 2023
1 parent 04b99a1 commit 337bf4b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
3 changes: 3 additions & 0 deletions csgo2/hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,9 @@ auto initVmtHook() -> bool {
return original_OnClientConnected && original_OnClientDisconnect &&
origin_StartServer && origin_GameFrame;
}
auto initConVarHooks() -> void {
// Offset::InterFaces::IVEngineCvar->RegisterConVar
}
auto init() -> bool {
bool isSuccess = initMinHook() && initVmtHook();
// bool isSuccess = initVmtHook();
Expand Down
34 changes: 31 additions & 3 deletions csgo2/script_apis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -672,10 +672,20 @@ auto luaApi_SetPlayerGlowEnable(lua_State* luaVm) -> int {
const auto playerIndex = lua_tointeger(luaVm, 1);
const auto isEnable = lua_toboolean(luaVm, 2);
ExcutePlayerAction(playerIndex, [&](CCSPlayerController* playerController) {
LOG("glow set %d to %d \n", playerController->m_hPawn().Get<CBaseModelEntity>()->m_Glow().m_bGlowing(), isEnable);
playerController->m_hPawn().Get<CBaseModelEntity>()->m_Glow().m_bGlowing(
LOG("glow set %d to %d \n",
playerController->m_hPawn()
.Get<CBaseModelEntity>()
->m_Glow()
.m_bGlowing(),
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()
.Get<CBaseModelEntity>()
->m_Glow()
Expand All @@ -690,6 +700,23 @@ auto luaApi_RunServerCommand(lua_State* luaVm) -> int {
lua_pop(luaVm, 1);
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 {
// param: playerIndex:int, style:int
lua_newtable(luaVm);
Expand Down Expand Up @@ -757,6 +784,7 @@ auto initFunciton(lua_State* luaVm) -> void {
lua_register(luaVm, "luaApi_SetPlayerGlowColor", luaApi_SetPlayerGlowColor);
lua_register(luaVm, "luaApi_GetAllPlayerIndex", luaApi_GetAllPlayerIndex);
lua_register(luaVm, "luaApi_RunServerCommand", luaApi_RunServerCommand);
lua_register(luaVm, "luaApi_KickPlayer", luaApi_KickPlayer);

luabridge::getGlobalNamespace(luaVm)
.beginClass<_luaApi_WeaponInfo>("WeaponInfo")
Expand Down

0 comments on commit 337bf4b

Please sign in to comment.