Backed out changeset 30dc174bd406

This commit is contained in:
David Anderson 2010-06-23 23:37:48 -07:00
parent bb0fcea5a4
commit 2f6af1cdff
3 changed files with 50 additions and 0 deletions

View File

@ -76,6 +76,11 @@ bool CStrike::SDK_OnLoad(char *error, size_t maxlength, bool late)
sharesys->AddNatives(myself, g_CSNatives); sharesys->AddNatives(myself, g_CSNatives);
sharesys->RegisterLibrary(myself, "cstrike"); sharesys->RegisterLibrary(myself, "cstrike");
if ((g_msgHintText = usermsgs->GetMessageIndex("HintText")) != -1)
{
sharesys->OverrideNatives(myself, g_CS_PrintHintText);
}
playerhelpers->RegisterCommandTargetProcessor(this); playerhelpers->RegisterCommandTargetProcessor(this);
return true; return true;

View File

@ -130,5 +130,6 @@ public:
extern IBinTools *g_pBinTools; extern IBinTools *g_pBinTools;
extern IGameConfig *g_pGameConf; extern IGameConfig *g_pGameConf;
extern int g_msgHintText; extern int g_msgHintText;
extern sp_nativeinfo_t g_CS_PrintHintText[];
#endif // _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_ #endif // _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_

View File

@ -71,6 +71,45 @@ inline CBaseEntity *GetCBaseEntity(int num, bool isplayer)
return pUnk->GetBaseEntity(); 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->GetLastNativeError() != SP_ERROR_NONE)
{
return 0;
}
bf_write *pBitBuf = usermsgs->StartMessage(g_msgHintText, &params[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 cell_t CS_RespawnPlayer(IPluginContext *pContext, const cell_t *params)
{ {
static ICallWrapper *pWrapper = NULL; static ICallWrapper *pWrapper = NULL;
@ -127,3 +166,8 @@ sp_nativeinfo_t g_CSNatives[] =
{NULL, NULL} {NULL, NULL}
}; };
sp_nativeinfo_t g_CS_PrintHintText[] =
{
{"PrintHintText", CS_PrintHintText},
{NULL, NULL},
};