core/smn_console.cpp
changeset 532 fe6bb91d79b1
parent 522 d46331ee2046
child 562 cfce5c6faef6
     1.1 --- a/core/smn_console.cpp	Mon Feb 26 04:36:15 2007 +0000
     1.2 +++ b/core/smn_console.cpp	Mon Feb 26 05:26:54 2007 +0000
     1.3 @@ -512,6 +512,28 @@
     1.4  	return 1;
     1.5  }
     1.6  
     1.7 +static cell_t sm_ClientCommand(IPluginContext *pContext, const cell_t *params)
     1.8 +{
     1.9 +	CPlayer *pPlayer = g_Players.GetPlayerByIndex(params[1]);
    1.10 +
    1.11 +	if (!pPlayer)
    1.12 +	{
    1.13 +		return pContext->ThrowNativeError("Player %d is not a valid player", params[1]);
    1.14 +	}
    1.15 +
    1.16 +	if (!pPlayer->IsConnected())
    1.17 +	{
    1.18 +		return pContext->ThrowNativeError("Player %d is not connected", params[1]);
    1.19 +	}
    1.20 +
    1.21 +	char buffer[256];
    1.22 +	g_SourceMod.FormatString(buffer, sizeof(buffer)-1, pContext, params, 2);
    1.23 +
    1.24 +	engine->ClientCommand(pPlayer->GetEdict(), "%s", buffer);
    1.25 +
    1.26 +	return 1;
    1.27 +}
    1.28 +
    1.29  REGISTER_NATIVES(consoleNatives)
    1.30  {
    1.31  	{"CreateConVar",		sm_CreateConVar},
    1.32 @@ -543,5 +565,6 @@
    1.33  	{"ServerCommand",		sm_ServerCommand},
    1.34  	{"InsertServerCommand",	sm_InsertServerCommand},
    1.35  	{"ServerExecute",		sm_ServerExecute},
    1.36 +	{"ClientCommand",		sm_ClientCommand},
    1.37  	{NULL,					NULL}
    1.38  };