added a wrapper for getclientconvarvalue
fixed a bug in the player manager --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40462
This commit is contained in:
parent
1300048946
commit
471da79fa5
@ -350,7 +350,7 @@ int CPlayerManager::GetMaxClients()
|
||||
|
||||
CPlayer *CPlayerManager::GetPlayerByIndex(int client) const
|
||||
{
|
||||
if (client > m_maxClients || client < 0)
|
||||
if (client > m_maxClients || client < 1)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
@ -175,6 +175,32 @@ static cell_t sm_PrintToServer(IPluginContext *pCtx, const cell_t *params)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell_t sm_GetClientInfo(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
int client = params[1];
|
||||
CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
|
||||
if (!pPlayer)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid client index %d.", client);
|
||||
}
|
||||
if (!pPlayer->IsConnected())
|
||||
{
|
||||
return pContext->ThrowNativeError("Client %d is not connected.", client);
|
||||
}
|
||||
|
||||
char *key;
|
||||
pContext->LocalToString(params[2], &key);
|
||||
|
||||
const char *val = engine->GetClientConVarValue(client, key);
|
||||
if (!val)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
pContext->StringToLocalUTF8(params[3], params[4], val, NULL);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell_t sm_PrintToConsole(IPluginContext *pCtx, const cell_t *params)
|
||||
{
|
||||
int index = params[1];
|
||||
@ -217,6 +243,7 @@ REGISTER_NATIVES(playernatives)
|
||||
{"IsPlayerFakeClient", sm_IsPlayerFakeClient},
|
||||
{"PrintToServer", sm_PrintToServer},
|
||||
{"PrintToConsole", sm_PrintToConsole},
|
||||
{"GetClientInfo", sm_GetClientInfo},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
|
@ -226,6 +226,17 @@ native bool:IsPlayerAuthorized(client);
|
||||
*/
|
||||
native bool:IsPlayerFakeClient(client);
|
||||
|
||||
/**
|
||||
* Retrieves values from client replicated keys.
|
||||
*
|
||||
* @param client Player's index.
|
||||
* @param key Key string.
|
||||
* @param value Buffer to store value.
|
||||
* @param maxlen Maximum length of valve (UTF-8 safe).
|
||||
* @return True on success, false otherwise.
|
||||
*/
|
||||
native bool:GetClientInfo(client, const String:key[], String:value[], maxlen);
|
||||
|
||||
/**
|
||||
* Sends a message to the server console.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user