- Added natives: PrintToChat() and PrintCenterText()

- Bit of reorganization with moving some natives from sourcemod.inc to halflife.inc

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40879
This commit is contained in:
Scott Ehlert
2007-06-01 06:33:54 +00:00
parent 1ab452c897
commit 6c17b9f37b
11 changed files with 322 additions and 212 deletions
+52 -2
View File
@@ -15,8 +15,10 @@
#include "sm_globals.h"
#include "sourcemod.h"
#include "sourcemm_api.h"
#include "PlayerManager.h"
#include "HandleSys.h"
#include "PlayerManager.h"
#include "HalfLife2.h"
#include <shareddefs.h>
IServerPluginCallbacks *g_VSP = NULL;
@@ -244,7 +246,7 @@ static cell_t FakeClientCommand(IPluginContext *pContext, const cell_t *params)
}
char buffer[256];
g_SourceMod.FormatString(buffer, sizeof(buffer)-1, pContext, params, 2);
g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 2);
serverpluginhelpers->ClientCommand(pPlayer->GetEdict(), buffer);
@@ -279,6 +281,52 @@ static cell_t smn_CreateDialog(IPluginContext *pContext, const cell_t *params)
return 1;
}
static cell_t PrintToChat(IPluginContext *pContext, const cell_t *params)
{
int client = params[1];
CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
if (!pPlayer)
{
return pContext->ThrowNativeError("Player %d is not a valid player", params[1]);
}
if (!pPlayer->IsConnected())
{
return pContext->ThrowNativeError("Player %d is not connected", params[1]);
}
char buffer[256];
g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 2);
g_HL2.TextMsg(client, HUD_PRINTTALK, buffer);
return 1;
}
static cell_t PrintCenterText(IPluginContext *pContext, const cell_t *params)
{
int client = params[1];
CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
if (!pPlayer)
{
return pContext->ThrowNativeError("Player %d is not a valid player", params[1]);
}
if (!pPlayer->IsConnected())
{
return pContext->ThrowNativeError("Player %d is not connected", params[1]);
}
char buffer[256];
g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 2);
g_HL2.TextMsg(client, HUD_PRINTCENTER, buffer);
return 1;
}
static HalfLifeNatives s_HalfLifeNatives;
REGISTER_NATIVES(halflifeNatives)
@@ -306,5 +354,7 @@ REGISTER_NATIVES(halflifeNatives)
{"IsSoundPrecached", IsSoundPrecached},
{"FakeClientCommand", FakeClientCommand},
{"CreateDialog", smn_CreateDialog},
{"PrintToChat", PrintToChat},
{"PrintCenterText", PrintCenterText},
{NULL, NULL},
};