fix for amb1156 - CS:S Tools overrides the PrintHintText native with its own version. this is a fail-safe for CS:S being loaded, as we can have better control from an extension.
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401698
This commit is contained in:
parent
358a1e959e
commit
200fe16e1c
@ -45,6 +45,7 @@ IBinTools *g_pBinTools = NULL;
|
||||
IGameConfig *g_pGameConf = NULL;
|
||||
IGameEventManager2 *gameevents = NULL;
|
||||
bool hooked_everything = false;
|
||||
int g_msgHintText = -1;
|
||||
|
||||
SMEXT_LINK(&g_CStrike);
|
||||
|
||||
@ -67,6 +68,11 @@ bool CStrike::SDK_OnLoad(char *error, size_t maxlength, bool late)
|
||||
sharesys->AddNatives(myself, g_CSNatives);
|
||||
sharesys->RegisterLibrary(myself, "cstrike");
|
||||
|
||||
if ((g_msgHintText = usermsgs->GetMessageIndex("HintText")) != -1)
|
||||
{
|
||||
sharesys->OverrideNatives(myself, g_CS_PrintHintText);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -122,5 +122,7 @@ public:
|
||||
/* Interfaces from SourceMod */
|
||||
extern IBinTools *g_pBinTools;
|
||||
extern IGameConfig *g_pGameConf;
|
||||
extern int g_msgHintText;
|
||||
extern sp_nativeinfo_t g_CS_PrintHintText[];
|
||||
|
||||
#endif // _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
|
||||
|
@ -69,6 +69,45 @@ inline CBaseEntity *GetCBaseEntity(int num, bool isplayer)
|
||||
return pUnk->GetBaseEntity();
|
||||
}
|
||||
|
||||
static cell_t CS_PrintHintText(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
int client = params[1];
|
||||
IGamePlayer *pPlayer = playerhelpers->GetGamePlayer(params[1]);
|
||||
|
||||
if (!pPlayer)
|
||||
{
|
||||
return pContext->ThrowNativeError("Client index %d is invalid", client);
|
||||
}
|
||||
|
||||
if (!pPlayer->IsInGame())
|
||||
{
|
||||
return pContext->ThrowNativeError("Client %d is not in game", client);
|
||||
}
|
||||
|
||||
g_pSM->SetGlobalTarget(client);
|
||||
|
||||
char buffer[192];
|
||||
g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 2);
|
||||
|
||||
/* Check for an error before printing to the client */
|
||||
if (pContext->GetContext()->n_err != SP_ERROR_NONE)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bf_write *pBitBuf = usermsgs->StartMessage(g_msgHintText, ¶ms[1], 1, USERMSG_RELIABLE);
|
||||
if (pBitBuf == NULL)
|
||||
{
|
||||
return pContext->ThrowNativeError("Could not send a usermessage");
|
||||
}
|
||||
pBitBuf->WriteByte(1);
|
||||
pBitBuf->WriteString(buffer);
|
||||
usermsgs->EndMessage();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static cell_t CS_RespawnPlayer(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
static ICallWrapper *pWrapper = NULL;
|
||||
@ -124,3 +163,9 @@ sp_nativeinfo_t g_CSNatives[] =
|
||||
{"CS_SwitchTeam", CS_SwitchTeam},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
sp_nativeinfo_t g_CS_PrintHintText[] =
|
||||
{
|
||||
{"PrintHintText", CS_PrintHintText},
|
||||
{NULL, NULL},
|
||||
};
|
||||
|
@ -71,5 +71,6 @@
|
||||
#define SMEXT_ENABLE_TIMERSYS
|
||||
//#define SMEXT_ENABLE_THREADER
|
||||
//#define SMEXT_ENABLE_LIBSYS
|
||||
#define SMEXT_ENABLE_USERMSGS
|
||||
|
||||
#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
|
||||
|
@ -79,6 +79,9 @@ IThreader *threader = NULL;
|
||||
#if defined SMEXT_ENABLE_LIBSYS
|
||||
ILibrarySys *libsys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_USERMSGS
|
||||
IUserMessages *usermsgs = NULL;
|
||||
#endif
|
||||
|
||||
/** Exports the main interface */
|
||||
PLATFORM_EXTERN_C IExtensionInterface *GetSMExtAPI()
|
||||
@ -149,6 +152,9 @@ bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error,
|
||||
#if defined SMEXT_ENABLE_LIBSYS
|
||||
SM_GET_IFACE(LIBRARYSYS, libsys);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_USERMSGS
|
||||
SM_GET_IFACE(USERMSGS, usermsgs);
|
||||
#endif
|
||||
|
||||
if (SDK_OnLoad(error, maxlength, late))
|
||||
{
|
||||
|
@ -73,6 +73,9 @@
|
||||
#if defined SMEXT_ENABLE_LIBSYS
|
||||
#include <ILibrarySys.h>
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_USERMSGS
|
||||
#include <IUserMessages.h>
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_CONF_METAMOD
|
||||
#include <ISmmPlugin.h>
|
||||
@ -260,6 +263,9 @@ extern IThreader *threader;
|
||||
#if defined SMEXT_ENABLE_LIBSYS
|
||||
extern ILibrarySys *libsys;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_USERMSGS
|
||||
extern IUserMessages *usermsgs;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_CONF_METAMOD
|
||||
PLUGIN_GLOBALVARS();
|
||||
|
Loading…
Reference in New Issue
Block a user