core/smn_player.cpp
changeset 456 b181fc6f59c7
parent 449 e24772d5d9eb
child 458 77520125ee67
     1.1 --- a/core/smn_player.cpp	Thu Feb 08 04:56:08 2007 +0000
     1.2 +++ b/core/smn_player.cpp	Thu Feb 08 20:37:24 2007 +0000
     1.3 @@ -175,6 +175,32 @@
     1.4  	return 1;
     1.5  }
     1.6  
     1.7 +static cell_t sm_GetClientInfo(IPluginContext *pContext, const cell_t *params)
     1.8 +{
     1.9 +	int client = params[1];
    1.10 +	CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
    1.11 +	if (!pPlayer)
    1.12 +	{
    1.13 +		return pContext->ThrowNativeError("Invalid client index %d.", client);
    1.14 +	}
    1.15 +	if (!pPlayer->IsConnected())
    1.16 +	{
    1.17 +		return pContext->ThrowNativeError("Client %d is not connected.", client);
    1.18 +	}
    1.19 +
    1.20 +	char *key;
    1.21 +	pContext->LocalToString(params[2], &key);
    1.22 +
    1.23 +	const char *val = engine->GetClientConVarValue(client, key);
    1.24 +	if (!val)
    1.25 +	{
    1.26 +		return false;
    1.27 +	}
    1.28 +
    1.29 +	pContext->StringToLocalUTF8(params[3], params[4], val, NULL);
    1.30 +	return 1;
    1.31 +}
    1.32 +
    1.33  static cell_t sm_PrintToConsole(IPluginContext *pCtx, const cell_t *params)
    1.34  {
    1.35  	int index = params[1];
    1.36 @@ -217,6 +243,7 @@
    1.37  	{"IsPlayerFakeClient",		sm_IsPlayerFakeClient},
    1.38  	{"PrintToServer",			sm_PrintToServer},
    1.39  	{"PrintToConsole",			sm_PrintToConsole},
    1.40 +	{"GetClientInfo",			sm_GetClientInfo},
    1.41  	{NULL,						NULL}
    1.42  };
    1.43