diff --git a/libraries/hl2sdk-cs2 b/libraries/hl2sdk-cs2 index f7ed6a008..36dd2db72 160000 --- a/libraries/hl2sdk-cs2 +++ b/libraries/hl2sdk-cs2 @@ -1 +1 @@ -Subproject commit f7ed6a0086f24f23098afaaf840dc5ae27afef1a +Subproject commit 36dd2db72155a78a9b90727e3a9714c9fbb9f64a diff --git a/src/core/managers/chat_manager.cpp b/src/core/managers/chat_manager.cpp index 96210aee3..79b0adea0 100644 --- a/src/core/managers/chat_manager.cpp +++ b/src/core/managers/chat_manager.cpp @@ -15,21 +15,19 @@ */ #include "core/managers/chat_manager.h" -#include "core/managers/con_command_manager.h" -#include "scripting/callback_manager.h" -#include "characterset.h" +#include #include -#include #include -#include "core/memory.h" -#include "core/log.h" + +#include "characterset.h" #include "core/coreconfig.h" #include "core/gameconfig.h" - -#include - +#include "core/log.h" +#include "core/managers/con_command_manager.h" +#include "core/memory.h" #include "core/memory_module.h" +#include "scripting/callback_manager.h" namespace counterstrikesharp { @@ -39,10 +37,10 @@ ChatManager::~ChatManager() {} void ChatManager::OnAllInitialized() { - m_pHostSay = reinterpret_cast( - modules::server->FindSignature(globals::gameConfig->GetSignature("Host_Say"))); + m_pHostSay = reinterpret_cast(modules::server->FindSignature(globals::gameConfig->GetSignature("Host_Say"))); - if (m_pHostSay == nullptr) { + if (m_pHostSay == nullptr) + { CSSHARP_CORE_ERROR("Failed to find signature for \'Host_Say\'"); return; } @@ -54,12 +52,13 @@ void ChatManager::OnAllInitialized() void ChatManager::OnShutdown() {} -void DetourHostSay(CBaseEntity* pController, CCommand& args, bool teamonly, int unk1, - const char* unk2) +void DetourHostSay(CEntityInstance* pController, CCommand& args, bool teamonly, int unk1, const char* unk2) { - if (pController) { + if (pController) + { auto pEvent = globals::gameEventManager->CreateEvent("player_chat", true); - if (pEvent) { + if (pEvent) + { pEvent->SetBool("teamonly", teamonly); pEvent->SetInt("userid", pController->GetEntityIndex().Get() - 1); pEvent->SetString("text", args[1]); @@ -72,17 +71,17 @@ void DetourHostSay(CBaseEntity* pController, CCommand& args, bool teamonly, int bool bSilent = globals::coreConfig->IsSilentChatTrigger(args[1], prefix); bool bCommand = globals::coreConfig->IsPublicChatTrigger(args[1], prefix) || bSilent; - if (!bSilent) { + if (!bSilent) + { m_pHostSay(pController, args, teamonly, unk1, unk2); } if (bCommand) { - char *pszMessage = (char *)(args.ArgS() + prefix.length() + 1); + char* pszMessage = (char*)(args.ArgS() + prefix.length() + 1); // Trailing slashes are only removed if Host_Say has been called. - if (bSilent) - pszMessage[V_strlen(pszMessage) - 1] = 0; + if (bSilent) pszMessage[V_strlen(pszMessage) - 1] = 0; CCommand args; args.Tokenize(pszMessage); @@ -90,7 +89,8 @@ void DetourHostSay(CBaseEntity* pController, CCommand& args, bool teamonly, int auto prefixedPhrase = std::string("css_") + args.Arg(0); auto bValidWithPrefix = globals::conCommandManager.IsValidValveCommand(prefixedPhrase.c_str()); - if (bValidWithPrefix) { + if (bValidWithPrefix) + { // Re-tokenize with a `css_` prefix if we have found that its a valid command. args.Tokenize(("css_" + std::string(pszMessage)).c_str()); } @@ -99,30 +99,29 @@ void DetourHostSay(CBaseEntity* pController, CCommand& args, bool teamonly, int } } -bool ChatManager::OnSayCommandPre(CBaseEntity* pController, CCommand& command) { return false; } +bool ChatManager::OnSayCommandPre(CEntityInstance* pController, CCommand& command) { return false; } -void ChatManager::OnSayCommandPost(CBaseEntity* pController, CCommand& command) +void ChatManager::OnSayCommandPost(CEntityInstance* pController, CCommand& command) { auto commandStr = command.Arg(0); return InternalDispatch(pController, commandStr, command); } -void ChatManager::InternalDispatch(CBaseEntity* pPlayerController, const char* szTriggerPhase, - CCommand& fullCommand) +void ChatManager::InternalDispatch(CEntityInstance* pPlayerController, const char* szTriggerPhase, CCommand& fullCommand) { - if (pPlayerController == nullptr) { - globals::conCommandManager.ExecuteCommandCallbacks( - fullCommand.Arg(0), CCommandContext(CommandTarget_t::CT_NO_TARGET, CPlayerSlot(-1)), - fullCommand, HookMode::Pre, CommandCallingContext::Chat); + if (pPlayerController == nullptr) + { + globals::conCommandManager.ExecuteCommandCallbacks(fullCommand.Arg(0), + CCommandContext(CommandTarget_t::CT_NO_TARGET, CPlayerSlot(-1)), fullCommand, + HookMode::Pre, CommandCallingContext::Chat); return; } auto index = pPlayerController->GetEntityIndex().Get(); auto slot = CPlayerSlot(index - 1); - globals::conCommandManager.ExecuteCommandCallbacks( - fullCommand.Arg(0), CCommandContext(CommandTarget_t::CT_NO_TARGET, slot), fullCommand, - HookMode::Pre, CommandCallingContext::Chat); + globals::conCommandManager.ExecuteCommandCallbacks(fullCommand.Arg(0), CCommandContext(CommandTarget_t::CT_NO_TARGET, slot), + fullCommand, HookMode::Pre, CommandCallingContext::Chat); } -} // namespace counterstrikesharp \ No newline at end of file +} // namespace counterstrikesharp diff --git a/src/core/managers/chat_manager.h b/src/core/managers/chat_manager.h index 584dab342..12cb79706 100644 --- a/src/core/managers/chat_manager.h +++ b/src/core/managers/chat_manager.h @@ -19,14 +19,14 @@ #include #include -#include "core/globals.h" #include "core/global_listener.h" +#include "core/globals.h" #include "scripting/script_engine.h" namespace counterstrikesharp { class ScriptCallback; -typedef void (*HostSay)(CBaseEntity*, CCommand&, bool, int, const char*); +typedef void (*HostSay)(CEntityInstance*, CCommand&, bool, int, const char*); class ChatCommandInfo { @@ -52,18 +52,17 @@ class ChatManager : public GlobalClass void OnAllInitialized() override; void OnShutdown() override; - bool OnSayCommandPre(CBaseEntity* pController, CCommand& args); - void OnSayCommandPost(CBaseEntity* pController, CCommand& args); + bool OnSayCommandPre(CEntityInstance* pController, CCommand& args); + void OnSayCommandPost(CEntityInstance* pController, CCommand& args); + private: - void InternalDispatch(CBaseEntity* pPlayerController, const char* szTriggerPhrase, - CCommand& pFullCommand); + void InternalDispatch(CEntityInstance* pPlayerController, const char* szTriggerPhrase, CCommand& pFullCommand); std::vector m_cmd_list; std::map m_cmd_lookup; }; -static void DetourHostSay(CBaseEntity* pController, CCommand& args, bool teamonly, int unk1, - const char* unk2); +static void DetourHostSay(CEntityInstance* pController, CCommand& args, bool teamonly, int unk1, const char* unk2); static HostSay m_pHostSay = nullptr; -} // namespace counterstrikesharp \ No newline at end of file +} // namespace counterstrikesharp diff --git a/src/core/managers/voice_manager.cpp b/src/core/managers/voice_manager.cpp index 3b7b06453..e488edef1 100644 --- a/src/core/managers/voice_manager.cpp +++ b/src/core/managers/voice_manager.cpp @@ -15,15 +15,15 @@ */ #include "core/managers/voice_manager.h" -#include "core/managers/player_manager.h" +#include #include -#include "scripting/callback_manager.h" #include -#include -SH_DECL_HOOK3(IVEngineServer2, SetClientListening, SH_NOATTRIB, 0, bool, CPlayerSlot, CPlayerSlot, - bool); +#include "core/managers/player_manager.h" +#include "scripting/callback_manager.h" + +SH_DECL_HOOK3(IVEngineServer2, SetClientListening, SH_NOATTRIB, 0, bool, CPlayerSlot, CPlayerSlot, bool); namespace counterstrikesharp { @@ -33,14 +33,12 @@ VoiceManager::~VoiceManager() {} void VoiceManager::OnAllInitialized() { - SH_ADD_HOOK(IVEngineServer2, SetClientListening, globals::engine, - SH_MEMBER(this, &VoiceManager::SetClientListening), false); + SH_ADD_HOOK(IVEngineServer2, SetClientListening, globals::engine, SH_MEMBER(this, &VoiceManager::SetClientListening), false); } void VoiceManager::OnShutdown() { - SH_REMOVE_HOOK(IVEngineServer2, SetClientListening, globals::engine, - SH_MEMBER(this, &VoiceManager::SetClientListening), false); + SH_REMOVE_HOOK(IVEngineServer2, SetClientListening, globals::engine, SH_MEMBER(this, &VoiceManager::SetClientListening), false); } bool VoiceManager::SetClientListening(CPlayerSlot iReceiver, CPlayerSlot iSender, bool bListen) @@ -56,49 +54,44 @@ bool VoiceManager::SetClientListening(CPlayerSlot iReceiver, CPlayerSlot iSender if (pReceiver->m_selfMutes->Get(iSender.Get())) { - RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, bListen, &IVEngineServer2::SetClientListening, - (iReceiver, iSender, false)); + RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, bListen, &IVEngineServer2::SetClientListening, (iReceiver, iSender, false)); } if (senderFlags & Speak_Muted) { - RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, bListen, &IVEngineServer2::SetClientListening, - (iReceiver, iSender, false)); + RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, bListen, &IVEngineServer2::SetClientListening, (iReceiver, iSender, false)); } - + if (listenOverride == Listen_Mute) { - RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, bListen, &IVEngineServer2::SetClientListening, - (iReceiver, iSender, false)); - } else if (listenOverride == Listen_Hear) { - RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, bListen, &IVEngineServer2::SetClientListening, - (iReceiver, iSender, true)); + RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, bListen, &IVEngineServer2::SetClientListening, (iReceiver, iSender, false)); + } + else if (listenOverride == Listen_Hear) + { + RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, bListen, &IVEngineServer2::SetClientListening, (iReceiver, iSender, true)); } - if ((senderFlags & Speak_All) || (receiverFlags & Speak_ListenAll)) { - RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, bListen, &IVEngineServer2::SetClientListening, - (iReceiver, iSender, true)); + if ((senderFlags & Speak_All) || (receiverFlags & Speak_ListenAll)) + { + RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, bListen, &IVEngineServer2::SetClientListening, (iReceiver, iSender, true)); } - + if ((senderFlags & Speak_Team) || (receiverFlags & Speak_ListenTeam)) { static auto classKey = hash_32_fnv1a_const("CBaseEntity"); static auto memberKey = hash_32_fnv1a_const("m_iTeamNum"); const static auto m_key = schema::GetOffset("CBaseEntity", classKey, "m_iTeamNum", memberKey); - auto receiverController = globals::entitySystem->GetBaseEntity(CEntityIndex(iReceiver.Get() + 1)); - auto senderController = globals::entitySystem->GetBaseEntity(CEntityIndex(iSender.Get() + 1)); + auto receiverController = globals::entitySystem->GetEntityInstance(CEntityIndex(iReceiver.Get() + 1)); + auto senderController = globals::entitySystem->GetEntityInstance(CEntityIndex(iSender.Get() + 1)); if (receiverController && senderController) { - auto receiverTeam = *reinterpret_cast>( - (uintptr_t)(receiverController) + m_key.offset); + auto receiverTeam = *reinterpret_cast>((uintptr_t)(receiverController) + m_key.offset); - auto senderTeam = *reinterpret_cast>( - (uintptr_t)(senderController) + m_key.offset); + auto senderTeam = *reinterpret_cast>((uintptr_t)(senderController) + m_key.offset); - RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, bListen, - &IVEngineServer2::SetClientListening, + RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, bListen, &IVEngineServer2::SetClientListening, (iReceiver, iSender, receiverTeam == senderTeam)); } } @@ -111,19 +104,18 @@ void VoiceManager::OnClientCommand(CPlayerSlot slot, const CCommand& args) { auto pPlayer = globals::playerManager.GetPlayerBySlot(slot.Get()); - if (!pPlayer) - return; + if (!pPlayer) return; if (args.ArgC() > 1 && stricmp(args.Arg(0), "vban") == 0) { // clients just refuse to send vban for indexes over 32 and all 4 fields are just the same number, so we only get the first one - //for (int i = 1; (i < args.ArgC()) && (i < 3); i++) { - unsigned int mask = 0; - sscanf(args.Arg(1), "%x", &mask); + // for (int i = 1; (i < args.ArgC()) && (i < 3); i++) { + unsigned int mask = 0; + sscanf(args.Arg(1), "%x", &mask); - pPlayer->m_selfMutes->SetDWord(0, mask); + pPlayer->m_selfMutes->SetDWord(0, mask); //} } } -} // namespace counterstrikesharp \ No newline at end of file +} // namespace counterstrikesharp diff --git a/src/scripting/natives/natives_entities.cpp b/src/scripting/natives/natives_entities.cpp index b2502155e..b01ae74ce 100644 --- a/src/scripting/natives/natives_entities.cpp +++ b/src/scripting/natives/natives_entities.cpp @@ -14,21 +14,22 @@ * along with CounterStrikeSharp. If not, see . * */ +#include + #include #include -#include "scripting/autonative.h" -#include "scripting/script_engine.h" -#include "core/memory.h" #include "core/log.h" -#include "core/managers/player_manager.h" #include "core/managers/entity_manager.h" - -#include +#include "core/managers/player_manager.h" +#include "core/memory.h" +#include "scripting/autonative.h" +#include "scripting/script_engine.h" namespace counterstrikesharp { -CBaseEntity* GetEntityFromIndex(ScriptContext& script_context) { +CEntityInstance* GetEntityFromIndex(ScriptContext& script_context) +{ if (!globals::entitySystem) { script_context.ThrowNativeError("Entity system is not yet initialized"); @@ -37,55 +38,64 @@ CBaseEntity* GetEntityFromIndex(ScriptContext& script_context) { auto entityIndex = script_context.GetArgument(0); - return globals::entitySystem->GetBaseEntity(CEntityIndex(entityIndex)); + return globals::entitySystem->GetEntityInstance(CEntityIndex(entityIndex)); } -int GetUserIdFromIndex(ScriptContext& scriptContext) { +int GetUserIdFromIndex(ScriptContext& scriptContext) +{ auto entityIndex = scriptContext.GetArgument(0); // CPlayerSlot is 1 less than index return globals::engine->GetPlayerUserId(CPlayerSlot(entityIndex - 1)).Get(); } -const char* GetDesignerName(ScriptContext& scriptContext) { - auto entity = scriptContext.GetArgument(0); +const char* GetDesignerName(ScriptContext& scriptContext) +{ + auto entity = scriptContext.GetArgument(0); return entity->GetClassname(); } -void* GetEntityPointerFromHandle(ScriptContext& scriptContext) { - if (!globals::entitySystem) { +void* GetEntityPointerFromHandle(ScriptContext& scriptContext) +{ + if (!globals::entitySystem) + { scriptContext.ThrowNativeError("Entity system is not yet initialized"); return nullptr; } auto handle = scriptContext.GetArgument(0); - if (!handle->IsValid()) { + if (!handle->IsValid()) + { return nullptr; } - return globals::entitySystem->GetBaseEntity(*handle); + return globals::entitySystem->GetEntityInstance(*handle); } -void* GetEntityPointerFromRef(ScriptContext& scriptContext) { - if (!globals::entitySystem) { +void* GetEntityPointerFromRef(ScriptContext& scriptContext) +{ + if (!globals::entitySystem) + { scriptContext.ThrowNativeError("Entity system yet is not initialized"); return nullptr; } auto ref = scriptContext.GetArgument(0); - if (ref == INVALID_EHANDLE_INDEX) { + if (ref == INVALID_EHANDLE_INDEX) + { return nullptr; } CBaseHandle hndl(ref); - return globals::entitySystem->GetBaseEntity(hndl); + return globals::entitySystem->GetEntityInstance(hndl); } -unsigned int GetRefFromEntityPointer(ScriptContext& scriptContext) { - auto* pEntity = scriptContext.GetArgument(0); +unsigned int GetRefFromEntityPointer(ScriptContext& scriptContext) +{ + auto* pEntity = scriptContext.GetArgument(0); if (pEntity == nullptr) { @@ -102,36 +112,43 @@ unsigned int GetRefFromEntityPointer(ScriptContext& scriptContext) { return hndl.ToInt(); } -bool IsRefValidEntity(ScriptContext& scriptContext) { - if (!globals::entitySystem) { +bool IsRefValidEntity(ScriptContext& scriptContext) +{ + if (!globals::entitySystem) + { scriptContext.ThrowNativeError("Entity system yet is not initialized"); return false; } auto ref = scriptContext.GetArgument(0); - if (ref == INVALID_EHANDLE_INDEX) { + if (ref == INVALID_EHANDLE_INDEX) + { return false; } CBaseHandle hndl(ref); - if (!hndl.IsValid()) { + if (!hndl.IsValid()) + { return false; } - return globals::entitySystem->GetBaseEntity(hndl) != nullptr; + return globals::entitySystem->GetEntityInstance(hndl) != nullptr; } -void PrintToConsole(ScriptContext& scriptContext) { +void PrintToConsole(ScriptContext& scriptContext) +{ auto index = scriptContext.GetArgument(0); auto message = scriptContext.GetArgument(1); - globals::engine->ClientPrintf(CPlayerSlot{index - 1}, message); + globals::engine->ClientPrintf(CPlayerSlot{ index - 1 }, message); } -CEntityIdentity* GetFirstActiveEntity(ScriptContext& script_context) { - if (!globals::entitySystem) { +CEntityIdentity* GetFirstActiveEntity(ScriptContext& script_context) +{ + if (!globals::entitySystem) + { script_context.ThrowNativeError("Entity system yet is not initialized"); return nullptr; } @@ -139,8 +156,10 @@ CEntityIdentity* GetFirstActiveEntity(ScriptContext& script_context) { return globals::entitySystem->m_EntityList.m_pFirstActiveEntity; } -void* GetConcreteEntityListPointer(ScriptContext& script_context) { - if (!globals::entitySystem) { +void* GetConcreteEntityListPointer(ScriptContext& script_context) +{ + if (!globals::entitySystem) + { script_context.ThrowNativeError("Entity system yet is not initialized"); return nullptr; } @@ -148,27 +167,32 @@ void* GetConcreteEntityListPointer(ScriptContext& script_context) { return &globals::entitySystem->m_EntityList; } -unsigned long GetPlayerAuthorizedSteamID(ScriptContext& script_context) { +unsigned long GetPlayerAuthorizedSteamID(ScriptContext& script_context) +{ auto iSlot = script_context.GetArgument(0); auto pPlayer = globals::playerManager.GetPlayerBySlot(iSlot); - if (pPlayer == nullptr || !pPlayer->m_is_authorized) { + if (pPlayer == nullptr || !pPlayer->m_is_authorized) + { return -1; } auto pSteamId = pPlayer->GetSteamId(); - if (pSteamId == nullptr) { + if (pSteamId == nullptr) + { return -1; } return pSteamId->ConvertToUint64(); } -const char* GetPlayerIpAddress(ScriptContext& script_context) { +const char* GetPlayerIpAddress(ScriptContext& script_context) +{ auto iSlot = script_context.GetArgument(0); auto pPlayer = globals::playerManager.GetPlayerBySlot(iSlot); - if (pPlayer == nullptr) { + if (pPlayer == nullptr) + { return nullptr; } @@ -236,8 +260,7 @@ REGISTER_NATIVES(entities, { ScriptEngine::RegisterNativeHandler("GET_ENTITY_FROM_INDEX", GetEntityFromIndex); ScriptEngine::RegisterNativeHandler("GET_USERID_FROM_INDEX", GetUserIdFromIndex); ScriptEngine::RegisterNativeHandler("GET_DESIGNER_NAME", GetDesignerName); - ScriptEngine::RegisterNativeHandler("GET_ENTITY_POINTER_FROM_HANDLE", - GetEntityPointerFromHandle); + ScriptEngine::RegisterNativeHandler("GET_ENTITY_POINTER_FROM_HANDLE", GetEntityPointerFromHandle); ScriptEngine::RegisterNativeHandler("GET_ENTITY_POINTER_FROM_REF", GetEntityPointerFromRef); ScriptEngine::RegisterNativeHandler("GET_REF_FROM_ENTITY_POINTER", GetRefFromEntityPointer); ScriptEngine::RegisterNativeHandler("GET_CONCRETE_ENTITY_LIST_POINTER", GetConcreteEntityListPointer); @@ -251,4 +274,4 @@ REGISTER_NATIVES(entities, { ScriptEngine::RegisterNativeHandler("ACCEPT_INPUT", AcceptInput); ScriptEngine::RegisterNativeHandler("ADD_ENTITY_IO_EVENT", AddEntityIOEvent); }) -} // namespace counterstrikesharp +} // namespace counterstrikesharp diff --git a/src/scripting/natives/natives_voice.cpp b/src/scripting/natives/natives_voice.cpp index 692157913..9c8a3e00f 100644 --- a/src/scripting/natives/natives_voice.cpp +++ b/src/scripting/natives/natives_voice.cpp @@ -14,38 +14,40 @@ * along with CounterStrikeSharp. If not, see . * */ -#include "scripting/autonative.h" -#include "scripting/script_engine.h" -#include "core/managers/player_manager.h" #include +#include "core/managers/player_manager.h" +#include "scripting/autonative.h" +#include "scripting/script_engine.h" namespace counterstrikesharp { void SetClientListening(ScriptContext& scriptContext) { - auto receiver = scriptContext.GetArgument(0); - auto sender = scriptContext.GetArgument(1); + auto receiver = scriptContext.GetArgument(0); + auto sender = scriptContext.GetArgument(1); auto listen = scriptContext.GetArgument(2); - if (!receiver) { + if (!receiver) + { scriptContext.ThrowNativeError("Receiver is a null pointer"); return; } - if (!sender) { + if (!sender) + { scriptContext.ThrowNativeError("Sender is a null pointer"); return; } auto iSenderSlot = sender->GetEntityIndex().Get() - 1; - if (iSenderSlot < 0 || iSenderSlot >= globals::getGlobalVars()->maxClients) - scriptContext.ThrowNativeError("Invalid sender"); + if (iSenderSlot < 0 || iSenderSlot >= globals::getGlobalVars()->maxClients) scriptContext.ThrowNativeError("Invalid sender"); auto pPlayer = globals::playerManager.GetPlayerBySlot(receiver->GetEntityIndex().Get() - 1); - if (pPlayer == nullptr) { + if (pPlayer == nullptr) + { scriptContext.ThrowNativeError("Invalid receiver"); return; } @@ -55,27 +57,29 @@ void SetClientListening(ScriptContext& scriptContext) ListenOverride GetClientListening(ScriptContext& scriptContext) { - auto receiver = scriptContext.GetArgument(0); - auto sender = scriptContext.GetArgument(1); + auto receiver = scriptContext.GetArgument(0); + auto sender = scriptContext.GetArgument(1); - if (!receiver) { + if (!receiver) + { scriptContext.ThrowNativeError("Receiver is a null pointer"); return Listen_Default; } - if (!sender) { + if (!sender) + { scriptContext.ThrowNativeError("Sender is a null pointer"); return Listen_Default; } auto iSenderSlot = sender->GetEntityIndex().Get() - 1; - if (iSenderSlot < 0 || iSenderSlot >= globals::getGlobalVars()->maxClients) - scriptContext.ThrowNativeError("Invalid sender"); + if (iSenderSlot < 0 || iSenderSlot >= globals::getGlobalVars()->maxClients) scriptContext.ThrowNativeError("Invalid sender"); auto pPlayer = globals::playerManager.GetPlayerBySlot(receiver->GetEntityIndex().Get() - 1); - if (pPlayer == nullptr) { + if (pPlayer == nullptr) + { scriptContext.ThrowNativeError("Invalid receiver"); return Listen_Default; } @@ -85,16 +89,18 @@ ListenOverride GetClientListening(ScriptContext& scriptContext) void SetClientVoiceFlags(ScriptContext& scriptContext) { - auto client = scriptContext.GetArgument(0); + auto client = scriptContext.GetArgument(0); auto flags = scriptContext.GetArgument(1); - if (!client) { + if (!client) + { scriptContext.ThrowNativeError("Receiver is a null pointer"); return; } auto pPlayer = globals::playerManager.GetPlayerBySlot(client->GetEntityIndex().Get() - 1); - if (pPlayer == nullptr) { + if (pPlayer == nullptr) + { scriptContext.ThrowNativeError("Invalid receiver"); return; } @@ -104,16 +110,18 @@ void SetClientVoiceFlags(ScriptContext& scriptContext) VoiceFlag_t GetClientVoiceFlags(ScriptContext& scriptContext) { - auto client = scriptContext.GetArgument(0); + auto client = scriptContext.GetArgument(0); - if (!client) { + if (!client) + { scriptContext.ThrowNativeError("Receiver is a null pointer"); return VoiceFlag_t{}; } auto pPlayer = globals::playerManager.GetPlayerBySlot(client->GetEntityIndex().Get() - 1); - if (pPlayer == nullptr) { + if (pPlayer == nullptr) + { scriptContext.ThrowNativeError("Invalid receiver"); } @@ -126,4 +134,4 @@ REGISTER_NATIVES(voice, { ScriptEngine::RegisterNativeHandler("SET_CLIENT_VOICE_FLAGS", SetClientVoiceFlags); ScriptEngine::RegisterNativeHandler("GET_CLIENT_VOICE_FLAGS", GetClientVoiceFlags); }) -} // namespace counterstrikesharp \ No newline at end of file +} // namespace counterstrikesharp