2
0
mirror of https://github.com/rehlds/reapi.git synced 2025-02-05 10:10:38 +03:00

Added support VTC API

This commit is contained in:
s1lentq 2016-04-25 06:06:13 +06:00
parent ea35220838
commit bf9b3f655d
30 changed files with 599 additions and 79 deletions

View File

@ -37,7 +37,7 @@ void postEvaluate(NativeBinarySpec b) {
void setupToolchain(NativeBinarySpec b) {
ToolchainConfig cfg = rootProject.createToolchainConfig(b)
cfg.projectInclude(project, '', '/src', '/include', '/include/metamod', '/include/cssdk/common', '/include/cssdk/dlls', '/include/cssdk/engine', '/include/cssdk/game_shared', '/include/cssdk/pm_shared', '/include/cssdk/public')
cfg.projectInclude(project, '', '/src', '/src/mods', '/src/natives', '/include', '/include/metamod', '/include/cssdk/common', '/include/cssdk/dlls', '/include/cssdk/engine', '/include/cssdk/game_shared', '/include/cssdk/pm_shared', '/include/cssdk/public')
if (cfg instanceof MsvcToolchainConfig) {
cfg.compilerOptions.pchConfig = new MsvcToolchainConfig.PrecompiledHeadersConfig(

View File

@ -16,6 +16,7 @@
#include <reapi_const.inc>
#include <reapi_engine.inc> // NOTE: only for ReHLDS
#include <reapi_gamedll.inc> // NOTE: only for gamedll Counter-Strike (ReGameDLL_CS)
#include <reapi_misc.inc> // NOTE: Common set of natives and forwards.
// hookchain return type
enum

View File

@ -33,7 +33,7 @@ native any:get_member_game(CSGameRules_Members:member, any:...);
*
* @return 1 on success.
*/
native set_member(index, any:member, any:...);
native set_member(const index, any:member, any:...);
/*
* Returns a value from an entity's member
@ -42,29 +42,161 @@ native set_member(index, any:member, any:...);
* @param member The specified member, look at the enum's with name *_Members
*
* @return If an integer or boolean or one byte, array or everything else is passed via 3rd argument and more, look at argument list for specified member
*
* An integer: new iTeam = get_member(id, m_iTeam);
*
* String array: new szName[32];
* get_member(id, m_szNewName, charsmax(m_szNewName));
*
* An int array: new iAmmoIndex = get_member(id, m_rgAmmo, 5); // number of the element
*
*/
native any:get_member(index, any:member, any:...);
native any:get_member(const index, any:member, any:...);
native rg_set_animation(index, PLAYER_ANIM:playerAnim);
native rg_add_account(index, amount, bool:bTrackChange = true);
native rg_give_item(index, const pszName[]);
native rg_give_default_items(index);
native rg_give_shield(index, bool:bDeploy = true);
native rg_dmg_radius(Float:vecSrc[3], inflictor, attacker, Float:flDamage, Float:flRadius, iClassIgnore, bitsDamageType);
/*
* Assign the number of the player animations.
*
* @param index Client index
* @param playerAnim Specific the number animation
*
* @noreturn
*/
native rg_set_animation(const index, PLAYER_ANIM:playerAnim);
/*
* Adds money to player's account.
*
* @param index Client index
* @param amount The amount of money
* @param bTrackChange If the bTrackChange is 1, the amount of money added will also be displayed.
*
* @noreturn
*/
native rg_add_account(const index, amount, bool:bTrackChange = true);
/*
* Gives item to player
*
* @param index Client index
* @param pszName Classname item
*
* @noreturn
*/
native rg_give_item(const index, const pszName[]);
/*
* Give the player default items
*
* @param index Client index
*
* @noreturn
*/
native rg_give_default_items(const index);
/*
* Give the player shield
*
* @param index Client index
* @param bDeploy to get shield from holster
*
* @noreturn
*/
native rg_give_shield(const index, bool:bDeploy = true);
/*
* Inflicts in a radius from the source position.
*
* @param vecSrc The source position
* @param inflictor Inflictor is the entity that caused the damage (such as a gun)
* @param attacker Attacker is the entity that tirggered the damage (such as the gun's owner).
* @param flDamage The amount of damage
* @param flRadius Radius damage
* @param iClassIgnore To specify classes that are immune to damage.
* @param bitsDamageType Damage type DMG_*
*
* @noreturn
*/
native rg_dmg_radius(Float:vecSrc[3], const inflictor, const attacker, const Float:flDamage, const Float:flRadius, const iClassIgnore, const bitsDamageType);
/*
* Resets the global multi damage accumulator
*
* @noreturn
*/
native rg_multidmg_clear();
native rg_multidmg_apply(inflictor, attacker);
native rg_multidmg_add(inflictor, victim, Float:flDamage, bitsDamageType);
native rg_fire_bullets(inflictor, attacker, shots, Float:vecSrc[3], Float:vecDirShooting[3], Float:vecSpread[3], Float:flDistance, iBulletType, iTracerFreq, iDamage);
native Float:[3] rg_fire_bullets3(inflictor, attacker, Float:vecSrc[3], Float:vecDirShooting[3], Float:vecSpread, Float:flDistance, iPenetration, iBulletType, iDamage, Float:flRangeModifier, bool:bPistol, shared_rand);
/*
* inflicts contents of global multi damage register on victim
*
* @param inflictor Inflictor is the entity that caused the damage (such as a gun)
* @param attacker Attacker is the entity that tirggered the damage (such as the gun's owner).
*
* @noreturn
*/
native rg_multidmg_apply(const inflictor, const attacker);
native rg_round_end(Float:tmDelay, WinStatus:st, ScenarionEventEndRound:event = ROUND_NONE, const message[] = "default", const sentence[] = "default");
native rg_update_teamscores(iCtsWins = 0, iTsWins = 0, bool:bAdd = true);
/*
* Adds damage the accumulator
*
* @param inflictor Inflictor is the entity that caused the damage (such as a gun)
* @param victim A victim that takes damage
* @param flDamage The amount of damage
* @param bitsDamageType Damage type DMG_*
*
* @noreturn
*/
native rg_multidmg_add(const inflictor, const victim, const Float:flDamage, const bitsDamageType);
/*
* Fire bullets from entity
*
* @param inflictor Inflictor is the entity that caused the damage (such as a gun)
* @param attacker Attacker is the entity that tirggered the damage (such as the gun's owner).
* @param shots The number of shots
* @param vecSrc The source position of the barrel
* @param vecDirShooting Direction shooting
* @param vecSpread Spread
* @param flDistance Max shot distance
* @param iBulletType Bullet type
* @param iTracerFreq Tracer frequancy
* @param iDamage Damage amount
*
* @noreturn
*/
native rg_fire_bullets(const inflictor, const attacker, const shots, Float:vecSrc[3], Float:vecDirShooting[3], Float:vecSpread[3], const Float:flDistance, const iBulletType, const iTracerFreq, const iDamage);
/*
* Fire bullets from player's weapon
*
* @param inflictor Inflictor is the entity that caused the damage (such as a gun)
* @param attacker Attacker is the entity that tirggered the damage (such as the gun's owner).
* @param vecSrc The source position of the barrel
* @param vecDirShooting Direction shooting
* @param vecSpread Spread
* @param flDistance Max shot distance
* @param iPenetration The number of penetration
* @param iBulletType Bullet type
* @param iDamage Damage amount
* @param flRangeModifier Damage range modifier
* @param bPistol Pistol shot
* @param shared_rand Use player's random seed, get circular gaussian spread
*
* @return Float:[3] The result spread
*/
native Float:[3] rg_fire_bullets3(const inflictor, const attacker, Float:vecSrc[3], Float:vecDirShooting[3], const Float:vecSpread, const Float:flDistance, const iPenetration, const iBulletType, const iDamage, const Float:flRangeModifier, const bool:bPistol, const shared_rand);
/*
* Complete the round
*
* @param tmDelay Delay before the onset of a new round.
* @param st Which team won
* @param event The event is the end of the round
* @param message The message on round end
* @param sentence The sound at the end of the round
*
* @noreturn
*/
native rg_round_end(const Float:tmDelay, const WinStatus:st, const ScenarionEventEndRound:event = ROUND_NONE, const message[] = "default", const sentence[] = "default");
/*
* Update current scores
*
* @param iCtsWins The amount of wins to won
* @param iTsWins The amount of wins to won
* @param bAdd Adds the score to the current amount wins.
*
* @noreturn
*/
native rg_update_teamscores(const iCtsWins = 0, const iTsWins = 0, const bool:bAdd = true);

View File

@ -0,0 +1,45 @@
#if defined _reapi_misc_included
#endinput
#endif
#define _reapi_misc_included
/*
* Checks whether the player is talking at this moment
*
* @param index Client index
* @return 1 if client is speaking, 0 otherwise
*
*/
native VTC_IsClientSpeaking(index);
/*
* Mutes this player
*
* @param index Client index
* @noreturn
*/
native VTC_MuteClient(index);
/*
* Unmutes this player
*
* @param index Client index
* @noreturn
*/
native VTC_UnmuteClient(index);
/*
* Called when player started talking
*
* @param index Client index
* @noreturn
*/
forward VTC_OnClientStartSpeak(index);
/*
* Called when player stopped talking
*
* @param index Client index
* @noreturn
*/
forward VTC_OnClientStopSpeak(index);

View File

@ -199,4 +199,4 @@
// DLLEXPORT is defined, for convenience.
#define C_DLLEXPORT extern "C" DLLEXPORT
#define EXT_FUNC /*FORCE_STACK_ALIGN*/
#define EXT_FUNC FORCE_STACK_ALIGN

34
reapi/include/vtc_api.h Normal file
View File

@ -0,0 +1,34 @@
#pragma once
#define VOICETRANSCODER_API_VERSION_MAJOR 1
#define VOICETRANSCODER_API_VERSION_MINOR 0
template <typename ...t_args>
class IVoidCallbackRegistry {
public:
virtual ~IVoidCallbackRegistry() {}
typedef void (*callback_t)(t_args...);
virtual void registerCallback(callback_t func) = 0;
virtual void unregisterCallback(callback_t func) = 0;
};
typedef IVoidCallbackRegistry<size_t> ICallbackRegistry_ClientStartSpeak;
typedef IVoidCallbackRegistry<size_t> ICallbackRegistry_ClientStopSpeak;
class IVoiceTranscoderAPI {
public:
virtual ~IVoiceTranscoderAPI() {}
virtual size_t GetMajorVersion() = 0;
virtual size_t GetMinorVersion() = 0;
virtual bool IsClientSpeaking(size_t clientIndex) = 0;
virtual ICallbackRegistry_ClientStartSpeak *ClientStartSpeak() = 0;
virtual ICallbackRegistry_ClientStopSpeak *ClientStopSpeak() = 0;
virtual void MuteClient(size_t clientIndex) = 0;
virtual void UnmuteClient(size_t clientIndex) = 0;
};

View File

@ -194,17 +194,20 @@
<ClInclude Include="..\include\metamod\plinfo.h" />
<ClInclude Include="..\include\metamod\sdk_util.h" />
<ClInclude Include="..\include\metamod\types_meta.h" />
<ClInclude Include="..\include\vtc_api.h" />
<ClInclude Include="..\src\amxxmodule.h" />
<ClInclude Include="..\src\api_config.h" />
<ClInclude Include="..\src\hook_manager.h" />
<ClInclude Include="..\src\hook_callback.h" />
<ClInclude Include="..\src\hook_list.h" />
<ClInclude Include="..\src\member_list.h" />
<ClInclude Include="..\src\mod_regamedll_api.h" />
<ClInclude Include="..\src\mod_rehlds_api.h" />
<ClInclude Include="..\src\natives_misc.h" />
<ClInclude Include="..\src\natives_hookchains.h" />
<ClInclude Include="..\src\natives_members.h" />
<ClInclude Include="..\src\mods\mod_regamedll_api.h" />
<ClInclude Include="..\src\mods\mod_rehlds_api.h" />
<ClInclude Include="..\src\mods\mod_vtc_api.h" />
<ClInclude Include="..\src\natives\natives_hookchains.h" />
<ClInclude Include="..\src\natives\natives_members.h" />
<ClInclude Include="..\src\natives\natives_misc.h" />
<ClInclude Include="..\src\natives\natives_vtc.h" />
<ClInclude Include="..\src\precompiled.h" />
<ClInclude Include="..\src\reapi_utils.h" />
</ItemGroup>
@ -234,13 +237,15 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\src\mod_regamedll_api.cpp" />
<ClCompile Include="..\src\main.cpp" />
<ClCompile Include="..\src\meta_api.cpp" />
<ClCompile Include="..\src\mod_rehlds_api.cpp" />
<ClCompile Include="..\src\natives_misc.cpp" />
<ClCompile Include="..\src\natives_hookchains.cpp" />
<ClCompile Include="..\src\natives_members.cpp" />
<ClCompile Include="..\src\mods\mod_regamedll_api.cpp" />
<ClCompile Include="..\src\mods\mod_rehlds_api.cpp" />
<ClCompile Include="..\src\mods\mod_vtc_api.cpp" />
<ClCompile Include="..\src\natives\natives_hookchains.cpp" />
<ClCompile Include="..\src\natives\natives_members.cpp" />
<ClCompile Include="..\src\natives\natives_misc.cpp" />
<ClCompile Include="..\src\natives\natives_vtc.cpp" />
<ClCompile Include="..\src\precompiled.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
@ -257,6 +262,7 @@
<None Include="..\extra\amxmodx\scripting\include\reapi_engine.inc" />
<None Include="..\extra\amxmodx\scripting\include\reapi_gamedll.inc" />
<None Include="..\extra\amxmodx\scripting\include\reapi_gamedll_const.inc" />
<None Include="..\extra\amxmodx\scripting\include\reapi_misc.inc" />
<None Include="..\extra\amxmodx\scripting\reapi_test.sma" />
<None Include="..\src\reapi_const.inc" />
<None Include="reapi.def" />
@ -307,7 +313,7 @@
<SDLCheck>true</SDLCheck>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeaderFile>precompiled.h</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>$(ProjectDir)\..\src;$(ProjectDir)\..\version;$(ProjectDir)\..\include;$(ProjectDir)\..\include\metamod;$(ProjectDir)\..\include\cssdk\common;$(ProjectDir)\..\include\cssdk\dlls;$(ProjectDir)\..\include\cssdk\engine;$(ProjectDir)\..\include\cssdk\game_shared;$(ProjectDir)\..\include\cssdk\pm_shared;$(ProjectDir)\..\include\cssdk\public;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(ProjectDir)\..\src;$(ProjectDir)\..\src\mods;$(ProjectDir)\..\src\natives;$(ProjectDir)\..\version;$(ProjectDir)\..\include;$(ProjectDir)\..\include\metamod;$(ProjectDir)\..\include\cssdk\common;$(ProjectDir)\..\include\cssdk\dlls;$(ProjectDir)\..\include\cssdk\engine;$(ProjectDir)\..\include\cssdk\game_shared;$(ProjectDir)\..\include\cssdk\pm_shared;$(ProjectDir)\..\include\cssdk\public;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<IntrinsicFunctions>true</IntrinsicFunctions>
<MinimalRebuild>false</MinimalRebuild>
@ -356,7 +362,7 @@
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>
</SDLCheck>
<AdditionalIncludeDirectories>$(ProjectDir)\..\src;$(ProjectDir)\..\version;$(ProjectDir)\..\include;$(ProjectDir)\..\include\metamod;$(ProjectDir)\..\include\cssdk\common;$(ProjectDir)\..\include\cssdk\dlls;$(ProjectDir)\..\include\cssdk\engine;$(ProjectDir)\..\include\cssdk\game_shared;$(ProjectDir)\..\include\cssdk\pm_shared;$(ProjectDir)\..\include\cssdk\public;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(ProjectDir)\..\src;$(ProjectDir)\..\src\mods;$(ProjectDir)\..\src\natives;$(ProjectDir)\..\version;$(ProjectDir)\..\include;$(ProjectDir)\..\include\metamod;$(ProjectDir)\..\include\cssdk\common;$(ProjectDir)\..\include\cssdk\dlls;$(ProjectDir)\..\include\cssdk\engine;$(ProjectDir)\..\include\cssdk\game_shared;$(ProjectDir)\..\include\cssdk\pm_shared;$(ProjectDir)\..\include\cssdk\public;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<PrecompiledHeaderFile>precompiled.h</PrecompiledHeaderFile>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>

View File

@ -52,6 +52,9 @@
<Filter Include="src\natives">
<UniqueIdentifier>{1e41b4f5-768c-437f-af6d-51432194e332}</UniqueIdentifier>
</Filter>
<Filter Include="src\mods">
<UniqueIdentifier>{669b4426-091f-4cac-9281-f5585a2922fb}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\include\metamod\dllapi.h">
@ -597,12 +600,6 @@
<ClInclude Include="..\src\precompiled.h">
<Filter>src</Filter>
</ClInclude>
<ClInclude Include="..\src\mod_regamedll_api.h">
<Filter>src</Filter>
</ClInclude>
<ClInclude Include="..\src\mod_rehlds_api.h">
<Filter>src</Filter>
</ClInclude>
<ClInclude Include="..\src\api_config.h">
<Filter>src</Filter>
</ClInclude>
@ -621,15 +618,30 @@
<ClInclude Include="..\src\hook_manager.h">
<Filter>src</Filter>
</ClInclude>
<ClInclude Include="..\src\natives_hookchains.h">
<ClInclude Include="..\src\mods\mod_regamedll_api.h">
<Filter>src\mods</Filter>
</ClInclude>
<ClInclude Include="..\src\mods\mod_rehlds_api.h">
<Filter>src\mods</Filter>
</ClInclude>
<ClInclude Include="..\src\mods\mod_vtc_api.h">
<Filter>src\mods</Filter>
</ClInclude>
<ClInclude Include="..\src\natives\natives_hookchains.h">
<Filter>src\natives</Filter>
</ClInclude>
<ClInclude Include="..\src\natives_members.h">
<ClInclude Include="..\src\natives\natives_members.h">
<Filter>src\natives</Filter>
</ClInclude>
<ClInclude Include="..\src\natives_misc.h">
<ClInclude Include="..\src\natives\natives_misc.h">
<Filter>src\natives</Filter>
</ClInclude>
<ClInclude Include="..\src\natives\natives_vtc.h">
<Filter>src\natives</Filter>
</ClInclude>
<ClInclude Include="..\include\vtc_api.h">
<Filter>include</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\include\cssdk\common\parsemsg.cpp">
@ -659,12 +671,6 @@
<ClCompile Include="..\src\sdk_util.cpp">
<Filter>src</Filter>
</ClCompile>
<ClCompile Include="..\src\mod_regamedll_api.cpp">
<Filter>src</Filter>
</ClCompile>
<ClCompile Include="..\src\mod_rehlds_api.cpp">
<Filter>src</Filter>
</ClCompile>
<ClCompile Include="..\src\api_config.cpp">
<Filter>src</Filter>
</ClCompile>
@ -689,18 +695,30 @@
<ClCompile Include="..\src\h_export.cpp">
<Filter>src</Filter>
</ClCompile>
<ClCompile Include="..\src\natives_hookchains.cpp">
<Filter>src\natives</Filter>
</ClCompile>
<ClCompile Include="..\src\natives_members.cpp">
<Filter>src\natives</Filter>
</ClCompile>
<ClCompile Include="..\src\natives_misc.cpp">
<Filter>src\natives</Filter>
</ClCompile>
<ClCompile Include="..\src\reapi_utils.cpp">
<Filter>src</Filter>
</ClCompile>
<ClCompile Include="..\src\mods\mod_regamedll_api.cpp">
<Filter>src\mods</Filter>
</ClCompile>
<ClCompile Include="..\src\mods\mod_rehlds_api.cpp">
<Filter>src\mods</Filter>
</ClCompile>
<ClCompile Include="..\src\mods\mod_vtc_api.cpp">
<Filter>src\mods</Filter>
</ClCompile>
<ClCompile Include="..\src\natives\natives_hookchains.cpp">
<Filter>src\natives</Filter>
</ClCompile>
<ClCompile Include="..\src\natives\natives_members.cpp">
<Filter>src\natives</Filter>
</ClCompile>
<ClCompile Include="..\src\natives\natives_misc.cpp">
<Filter>src\natives</Filter>
</ClCompile>
<ClCompile Include="..\src\natives\natives_vtc.cpp">
<Filter>src\natives</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="..\extra\amxmodx\scripting\include\reapi.inc">
@ -725,6 +743,9 @@
<None Include="..\extra\amxmodx\scripting\include\reapi_gamedll_const.inc">
<Filter>amxmodx\scripting\include</Filter>
</None>
<None Include="..\extra\amxmodx\scripting\include\reapi_misc.inc">
<Filter>amxmodx\scripting\include</Filter>
</None>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="reapi.rc" />

View File

@ -162,6 +162,7 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
RegisterNatives_HookChains();
RegisterNatives_Members();
RegisterNatives_Misc();
RegisterNatives_Vtc();
return AMXX_OK;
}
@ -176,6 +177,12 @@ C_DLLEXPORT int AMXX_PluginsLoaded()
int iFwd = g_amxxapi.RegisterForward("__reapi_version_check", ET_IGNORE, FP_CELL, FP_CELL, FP_DONE);
g_amxxapi.ExecuteForward(iFwd, REAPI_VERISON_MAJOR, REAPI_VERISON_MINOR);
if (api_cfg.hasVTC()) {
g_iClientStartSpeak = g_amxxapi.RegisterForward("VTC_OnClientStartSpeak", ET_IGNORE, FP_CELL, FP_DONE);
g_iClientStopSpeak = g_amxxapi.RegisterForward("VTC_OnClientStopSpeak", ET_IGNORE, FP_CELL, FP_DONE);
}
return AMXX_OK;
}

View File

@ -55,7 +55,7 @@ struct amxx_module_info_s
/* calling convention for native functions */
#if !defined AMX_NATIVE_CALL
#define AMX_NATIVE_CALL FORCE_STACK_ALIGN
#define AMX_NATIVE_CALL EXT_FUNC
#endif
/* calling convention for all interface functions and callback functions */
#if !defined AMXAPI

View File

@ -2,7 +2,7 @@
CAPI_Config api_cfg;
CAPI_Config::CAPI_Config() : m_api_rehlds(false), m_api_regame(false)
CAPI_Config::CAPI_Config() : m_api_rehlds(false), m_api_regame(false), m_api_vtc(false)
{
}
@ -11,6 +11,7 @@ bool CAPI_Config::Init()
{
m_api_rehlds = RehldsApi_Init();
m_api_regame = RegamedllApi_Init();
m_api_vtc = VTC_Api_Init();
return true;
}

View File

@ -10,6 +10,7 @@ public:
bool hasReHLDS() const { return m_api_rehlds; }
bool hasReGameDLL() const { return m_api_regame; }
bool hasVTC() const { return m_api_vtc; }
void ServerActivate() const;
void ServerDeactivate() const;
@ -20,7 +21,7 @@ private:
bool m_api_regame; // some useful functions #2
// future plans?
//bool m_api_vtc; // for gag
bool m_api_vtc; // for gag
//bool m_api_revoice; // for gag #2
//bool m_api_reunion; // for information about authorization client
//bool m_api_rechecker; // for detection when checking and adding few files

View File

@ -383,3 +383,15 @@ bool RoundEnd(IReGameHook_RoundEnd *chain, int winStatus, ScenarionEventEndRound
return callForward<bool>(RG_RoundEnd, original, winStatus, event, tmDelay);
}
int g_iClientStartSpeak, g_iClientStopSpeak;
void ClientStartSpeak(size_t clientIndex)
{
g_amxxapi.ExecuteForward(g_iClientStartSpeak, clientIndex);
}
void ClientStopSpeak(size_t clientIndex)
{
g_amxxapi.ExecuteForward(g_iClientStopSpeak, clientIndex);
}

View File

@ -234,3 +234,9 @@ void CBasePlayer_AddAccount(IReGameHook_CBasePlayer_AddAccount *chain, CBasePlay
void CBasePlayer_GiveShield(IReGameHook_CBasePlayer_GiveShield *chain, CBasePlayer *pthis, bool bDeploy);
void CBaseAnimating_ResetSequenceInfo(IReGameHook_CBaseAnimating_ResetSequenceInfo *chain, CBaseAnimating *pthis);
extern int g_iClientStartSpeak;
extern int g_iClientStopSpeak;
void ClientStartSpeak(size_t clientIndex);
void ClientStopSpeak(size_t clientIndex);

View File

@ -15,6 +15,11 @@ void OnMetaDetach()
{
// clear all hooks?
g_hookManager.clearHandlers();
if (api_cfg.hasVTC()) {
g_pVoiceTranscoderApi->ClientStartSpeak()->unregisterCallback(&ClientStartSpeak);
g_pVoiceTranscoderApi->ClientStopSpeak()->unregisterCallback(&ClientStopSpeak);
}
}
void ServerActivate(edict_t *pEdictList, int edictCount, int clientMax)

View File

@ -0,0 +1,33 @@
#include "precompiled.h"
IVoiceTranscoderAPI *g_pVoiceTranscoderApi;
bool VTC_Api_Init()
{
if (g_RehldsApi == nullptr)
return false;
g_pVoiceTranscoderApi = (IVoiceTranscoderAPI *)g_RehldsApi->GetFuncs()->GetPluginApi("VoiceTranscoder");
if (g_pVoiceTranscoderApi == nullptr) {
return false;
}
int majorVersion = g_pVoiceTranscoderApi->GetMajorVersion();
int minorVersion = g_pVoiceTranscoderApi->GetMinorVersion();
if (majorVersion != VOICETRANSCODER_API_VERSION_MAJOR) {
UTIL_LogPrintf("[%s]: VTC Api major version mismatch; expected %d, real %d\n", Plugin_info.logtag, VOICETRANSCODER_API_VERSION_MAJOR, majorVersion);
return false;
}
if (minorVersion < VOICETRANSCODER_API_VERSION_MINOR) {
UTIL_LogPrintf("[%s]: VTC Api minor version mismatch; expected at least %d, real %d\n", Plugin_info.logtag, VOICETRANSCODER_API_VERSION_MINOR, minorVersion);
return false;
}
g_pVoiceTranscoderApi->ClientStartSpeak()->registerCallback(&ClientStartSpeak);
g_pVoiceTranscoderApi->ClientStopSpeak()->registerCallback(&ClientStopSpeak);
return true;
}

View File

@ -0,0 +1,5 @@
#pragma once
extern IVoiceTranscoderAPI *g_pVoiceTranscoderApi;
extern bool VTC_Api_Init();

View File

@ -1,6 +1,15 @@
#include "precompiled.h"
// native rg_set_animation(index, PLAYER_ANIM:playerAnim);
/*
* Assign the number of the player animations.
*
* @param index Client index
* @param playerAnim Specific the number animation
*
* @noreturn
*
* native rg_set_animation(index, PLAYER_ANIM:playerAnim);
*/
static cell AMX_NATIVE_CALL rg_set_animation(AMX *amx, cell *params)
{
enum args_e { arg_count, arg_index, arg_anim };
@ -14,7 +23,17 @@ static cell AMX_NATIVE_CALL rg_set_animation(AMX *amx, cell *params)
return TRUE;
}
// native rg_add_account(index, amount, bool:bTrackChange = true);
/*
* Adds money to player's account.
*
* @param index Client index
* @param amount The amount of money
* @param bTrackChange If the bTrackChange is 1, the amount of money added will also be displayed.
*
* @noreturn
*
* native rg_add_account(index, amount, bool:bTrackChange = true);
*/
static cell AMX_NATIVE_CALL rg_add_account(AMX *amx, cell *params)
{
enum args_e { arg_count, arg_index, arg_amount, arg_track_change };
@ -28,7 +47,16 @@ static cell AMX_NATIVE_CALL rg_add_account(AMX *amx, cell *params)
return TRUE;
}
// native rg_give_item(index, const pszName[]);
/*
* Gives item to player
*
* @param index Client index
* @param pszName Classname item
*
* @noreturn
*
* native rg_give_item(index, const pszName[]);
*/
static cell AMX_NATIVE_CALL rg_give_item(AMX *amx, cell *params)
{
enum args_e { arg_count, arg_index, arg_item };
@ -44,7 +72,15 @@ static cell AMX_NATIVE_CALL rg_give_item(AMX *amx, cell *params)
return TRUE;
}
// native rg_give_default_items(index);
/*
* Give the player default items
*
* @param index Client index
*
* @noreturn
*
* native rg_give_default_items(index);
*/
static cell AMX_NATIVE_CALL rg_give_default_items(AMX *amx, cell *params)
{
enum args_e { arg_count, arg_index };
@ -58,7 +94,16 @@ static cell AMX_NATIVE_CALL rg_give_default_items(AMX *amx, cell *params)
return TRUE;
}
// native rg_give_shield(index, bool:bDeploy = true);
/*
* Give the player shield
*
* @param index Client index
* @param bDeploy to get shield from holster
*
* @noreturn
*
* native rg_give_shield(index, bool:bDeploy = true);
*/
static cell AMX_NATIVE_CALL rg_give_shield(AMX *amx, cell *params)
{
enum args_e { arg_count, arg_index, arg_deploy };
@ -72,7 +117,21 @@ static cell AMX_NATIVE_CALL rg_give_shield(AMX *amx, cell *params)
return TRUE;
}
// native rg_dmg_radius(Float:vecSrc[3], inflictor, attacker, Float:flDamage, Float:flRadius, iClassIgnore, bitsDamageType);
/*
* Inflicts in a radius from the source position.
*
* @param vecSrc The source position
* @param inflictor Inflictor is the entity that caused the damage (such as a gun)
* @param attacker Attacker is the entity that tirggered the damage (such as the gun's owner).
* @param flDamage The amount of damage
* @param flRadius Radius damage
* @param iClassIgnore To specify classes that are immune to damage.
* @param bitsDamageType Damage type DMG_*
*
* @noreturn
*
* native rg_dmg_radius(Float:vecSrc[3], inflictor, attacker, Float:flDamage, Float:flRadius, iClassIgnore, bitsDamageType);
*/
static cell AMX_NATIVE_CALL rg_dmg_radius(AMX *amx, cell *params)
{
enum args_e { arg_count, arg_vec, arg_inflictor, arg_attacker, arg_damage, arg_radius, arg_ignore_class, arg_dmg_type };
@ -87,14 +146,29 @@ static cell AMX_NATIVE_CALL rg_dmg_radius(AMX *amx, cell *params)
return TRUE;
}
// native rg_multidmg_clear();
/*
* Resets the global multi damage accumulator
*
* @noreturn
*
* native rg_multidmg_clear();
*/
static cell AMX_NATIVE_CALL rg_multidmg_clear(AMX *amx, cell *params)
{
g_ReGameFuncs->ClearMultiDamage();
return TRUE;
}
// native rg_multidmg_apply(inflictor, attacker);
/*
* inflicts contents of global multi damage register on victim
*
* @param inflictor Inflictor is the entity that caused the damage (such as a gun)
* @param attacker Attacker is the entity that tirggered the damage (such as the gun's owner).
*
* @noreturn
*
* native rg_multidmg_apply(inflictor, attacker);
*/
static cell AMX_NATIVE_CALL rg_multidmg_apply(AMX *amx, cell *params)
{
enum args_e { arg_count, arg_inflictor, arg_attacker };
@ -106,7 +180,18 @@ static cell AMX_NATIVE_CALL rg_multidmg_apply(AMX *amx, cell *params)
return TRUE;
}
// native rg_multidmg_add(inflictor, victim, Float:flDamage, bitsDamageType);
/*
* Adds damage the accumulator
*
* @param inflictor Inflictor is the entity that caused the damage (such as a gun)
* @param victim A victim that takes damage
* @param flDamage The amount of damage
* @param bitsDamageType Damage type DMG_*
*
* @noreturn
*
* native rg_multidmg_add(inflictor, victim, Float:flDamage, bitsDamageType);
*/
static cell AMX_NATIVE_CALL rg_multidmg_add(AMX *amx, cell *params)
{
enum args_e { arg_count, arg_inflictor, arg_victim, arg_damage, arg_dmg_type };
@ -122,7 +207,24 @@ static cell AMX_NATIVE_CALL rg_multidmg_add(AMX *amx, cell *params)
return TRUE;
}
// native rg_fire_bullets(inflictor, attacker, shots, Float:vecSrc[3], Float:vecDirShooting[3], Float::vecSpread[3], Float:flDistance, iBulletType, iTracerFreq, iDamage);
/*
* Fire bullets from entity
*
* @param inflictor Inflictor is the entity that caused the damage (such as a gun)
* @param attacker Attacker is the entity that tirggered the damage (such as the gun's owner).
* @param shots The number of shots
* @param vecSrc The source position of the barrel
* @param vecDirShooting Direction shooting
* @param vecSpread Spread
* @param flDistance Max shot distance
* @param iBulletType Bullet type
* @param iTracerFreq Tracer frequancy
* @param iDamage Damage amount
*
* @noreturn
*
* native rg_fire_bullets(inflictor, attacker, shots, Float:vecSrc[3], Float:vecDirShooting[3], Float::vecSpread[3], Float:flDistance, iBulletType, iTracerFreq, iDamage);
*/
static cell AMX_NATIVE_CALL rg_fire_bullets(AMX *amx, cell *params)
{
enum args_e { arg_count, arg_inflictor, arg_attacker, arg_shots, arg_vecSrc, arg_dir, arg_spread, arg_dist, arg_bullet_type, arg_tracefrq, arg_dmg };
@ -143,7 +245,26 @@ static cell AMX_NATIVE_CALL rg_fire_bullets(AMX *amx, cell *params)
return TRUE;
}
// native Float:[3] rg_fire_bullets3(inflictor, attacker, Float:vecSrc[3], Float:vecDirShooting[3], Float:vecSpread, Float:flDistance, iPenetration, iBulletType, iDamage, Float:flRangeModifier, bool:bPistol, shared_rand);
/*
* Fire bullets from player's weapon
*
* @param inflictor Inflictor is the entity that caused the damage (such as a gun)
* @param attacker Attacker is the entity that tirggered the damage (such as the gun's owner).
* @param vecSrc The source position of the barrel
* @param vecDirShooting Direction shooting
* @param vecSpread Spread
* @param flDistance Max shot distance
* @param iPenetration The number of penetration
* @param iBulletType Bullet type
* @param iDamage Damage amount
* @param flRangeModifier Damage range modifier
* @param bPistol Pistol shot
* @param shared_rand Use player's random seed, get circular gaussian spread
*
* @return Float:[3] The result spread
*
* native Float:[3] rg_fire_bullets3(inflictor, attacker, Float:vecSrc[3], Float:vecDirShooting[3], Float:vecSpread, Float:flDistance, iPenetration, iBulletType, iDamage, Float:flRangeModifier, bool:bPistol, shared_rand);
*/
static cell AMX_NATIVE_CALL rg_fire_bullets3(AMX *amx, cell *params)
{
enum args_e { arg_count, arg_inflictor, arg_attacker, arg_vecSrc, arg_dir, arg_spread, arg_dist, arg_penetration, arg_bullet_type, arg_dmg, arg_range_mod, arg_pistol, arg_rand, arg_out };
@ -188,7 +309,19 @@ struct {
{ "#Game_Commencing", "", WINSTATUS_DRAW }, // ROUND_GAME_COMMENCE
};
// native rg_round_end(Float:tmDelay, WinStatus:st, ScenarionEventEndRound:event = ROUND_NONE, const message[] = "default", const sentence[] = "default");
/*
* Complete the round
*
* @param tmDelay Delay before the onset of a new round.
* @param st Which team won
* @param event The event is the end of the round
* @param message The message on round end
* @param sentence The sound at the end of the round
*
* @noreturn
*
* native rg_round_end(Float:tmDelay, WinStatus:st, ScenarionEventEndRound:event = ROUND_NONE, const message[] = "default", const sentence[] = "default");
*/
static cell AMX_NATIVE_CALL rg_round_end(AMX *amx, cell *params)
{
enum args_e { arg_count, arg_delay, arg_win, arg_event, arg_message, arg_sentence, arg_silent };
@ -223,7 +356,17 @@ static cell AMX_NATIVE_CALL rg_round_end(AMX *amx, cell *params)
return TRUE;
}
// native rg_update_teamscores(iCtsWins = 0, iTsWins = 0, bool:bAdd = true);
/*
* Update current scores
*
* @param iCtsWins The amount of wins to won
* @param iTsWins The amount of wins to won
* @param bAdd Adds the score to the current amount wins.
*
* @noreturn
*
* native rg_update_teamscores(iCtsWins = 0, iTsWins = 0, bool:bAdd = true);
*/
static cell AMX_NATIVE_CALL rg_update_teamscores(AMX *amx, cell *params)
{
enum args_e { arg_count, arg_cts, arg_ts, arg_add };

View File

@ -0,0 +1,61 @@
#include "precompiled.h"
/*
* Checks whether the player is talking at this moment
*
* @param index Client index
* @return 1 if client is speaking, 0 otherwise
*
* native VTC_IsClientSpeaking(index);
*/
static cell AMX_NATIVE_CALL VTC_IsClientSpeaking(AMX *amx, cell *params)
{
enum args_e { arg_count, arg_index };
return g_pVoiceTranscoderApi->IsClientSpeaking((size_t)params[arg_index]);
}
/*
* Mutes this player
*
* @param index Client index
* @noreturn
*
* native VTC_MuteClient(index);
*/
static cell AMX_NATIVE_CALL VTC_MuteClient(AMX *amx, cell *params)
{
enum args_e { arg_count, arg_index };
g_pVoiceTranscoderApi->MuteClient((size_t)params[arg_index]);
return FALSE;
}
/*
* Unmutes this player
*
* @param index Client index
* @noreturn
*
* native VTC_UnmuteClient(index);
*/
static cell AMX_NATIVE_CALL VTC_UnmuteClient(AMX *amx, cell *params)
{
enum args_e { arg_count, arg_index };
g_pVoiceTranscoderApi->UnmuteClient((size_t)params[arg_index]);
return FALSE;
}
AMX_NATIVE_INFO Vtc_Natives[] =
{
{ "VTC_IsClientSpeaking", VTC_IsClientSpeaking },
{ "VTC_MuteClient", VTC_MuteClient },
{ "VTC_UnmuteClient", VTC_UnmuteClient },
{ nullptr, nullptr }
};
void RegisterNatives_Vtc()
{
g_amxxapi.AddNatives(Vtc_Natives);
}

View File

@ -0,0 +1,3 @@
#pragma once
void RegisterNatives_Vtc();

View File

@ -21,10 +21,8 @@
#include "amxxmodule.h"
#include "osconfig.h"
// gamedll
#include "gamerules.h"
// regamedll API
#include "gamerules.h"
#include "regamedll_api.h"
#include "mod_regamedll_api.h"
@ -32,13 +30,19 @@
#include "rehlds_api.h"
#include "mod_rehlds_api.h"
// VTC API
#include "vtc_api.h"
#include "mod_vtc_api.h"
#include "api_config.h"
#include "hook_manager.h"
#include "hook_callback.h"
#include "member_list.h"
#include "natives_hookchains.h"
#include "natives_members.h"
#include "natives_misc.h"
#include "natives_vtc.h"
#undef DLLEXPORT
#ifdef _WIN32