extensions/cstrike/natives.cpp
changeset 1692 dc5dcaaeb744
parent 1441 21cddc2e7246
child 1857 a9f06e014a7b
     1.1 --- a/extensions/cstrike/natives.cpp	Sat Nov 17 05:40:58 2007 +0000
     1.2 +++ b/extensions/cstrike/natives.cpp	Sat Nov 17 05:41:47 2007 +0000
     1.3 @@ -69,6 +69,45 @@
     1.4  	return pUnk->GetBaseEntity();
     1.5  }
     1.6  
     1.7 +static cell_t CS_PrintHintText(IPluginContext *pContext, const cell_t *params)
     1.8 +{
     1.9 +	int client = params[1];
    1.10 +	IGamePlayer *pPlayer = playerhelpers->GetGamePlayer(params[1]);
    1.11 +
    1.12 +	if (!pPlayer)
    1.13 +	{
    1.14 +		return pContext->ThrowNativeError("Client index %d is invalid", client);
    1.15 +	}
    1.16 +
    1.17 +	if (!pPlayer->IsInGame())
    1.18 +	{
    1.19 +		return pContext->ThrowNativeError("Client %d is not in game", client);
    1.20 +	}
    1.21 +
    1.22 +	g_pSM->SetGlobalTarget(client);
    1.23 +
    1.24 +	char buffer[192];
    1.25 +	g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 2);
    1.26 +
    1.27 +	/* Check for an error before printing to the client */
    1.28 +	if (pContext->GetContext()->n_err != SP_ERROR_NONE)
    1.29 +	{
    1.30 +		return 0;
    1.31 +	}
    1.32 +
    1.33 +	bf_write *pBitBuf = usermsgs->StartMessage(g_msgHintText, &params[1], 1, USERMSG_RELIABLE);
    1.34 +	if (pBitBuf == NULL)
    1.35 +	{
    1.36 +		return pContext->ThrowNativeError("Could not send a usermessage");
    1.37 +	}
    1.38 +	pBitBuf->WriteByte(1);
    1.39 +	pBitBuf->WriteString(buffer);
    1.40 +	usermsgs->EndMessage();
    1.41 +
    1.42 +	return 1;
    1.43 +}
    1.44 +
    1.45 +
    1.46  static cell_t CS_RespawnPlayer(IPluginContext *pContext, const cell_t *params)
    1.47  {
    1.48  	static ICallWrapper *pWrapper = NULL;
    1.49 @@ -124,3 +163,9 @@
    1.50  	{"CS_SwitchTeam",				CS_SwitchTeam}, 
    1.51  	{NULL,							NULL}
    1.52  };
    1.53 +
    1.54 +sp_nativeinfo_t g_CS_PrintHintText[] = 
    1.55 +{
    1.56 +	{"PrintHintText",				CS_PrintHintText},
    1.57 +	{NULL,							NULL},
    1.58 +};