From 7db280a6662bcf113414b6fe0b016df87b94d3f3 Mon Sep 17 00:00:00 2001 From: FlaminSarge Date: Mon, 12 Aug 2013 02:08:34 +0100 Subject: [PATCH] Add GetPlayerJingleFile native. (bug 5690, r=asherkin) --- extensions/sdktools/vnatives.cpp | 27 ++++++++++++++++++++++++++ plugins/include/sdktools_functions.inc | 13 ++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/extensions/sdktools/vnatives.cpp b/extensions/sdktools/vnatives.cpp index af1a4752..c00b354f 100644 --- a/extensions/sdktools/vnatives.cpp +++ b/extensions/sdktools/vnatives.cpp @@ -1073,6 +1073,32 @@ static cell_t GetPlayerDecalFile(IPluginContext *pContext, const cell_t *params) return 1; } +static cell_t GetPlayerJingleFile(IPluginContext *pContext, const cell_t *params) +{ + IGamePlayer *player = playerhelpers->GetGamePlayer(params[1]); + if (player == NULL) + { + return pContext->ThrowNativeError("Invalid client index %d", params[1]); + } + if (!player->IsInGame()) + { + return pContext->ThrowNativeError("Client %d is not in game", params[1]); + } + + player_info_t info; + char *buffer; + + if (!GetPlayerInfo(params[1], &info) || !info.customFiles[1]) + { + return 0; + } + + pContext->LocalToString(params[2], &buffer); + Q_binarytohex((byte *)&info.customFiles[1], sizeof(info.customFiles[1]), buffer, params[3]); + + return 1; +} + static cell_t GetServerNetStats(IPluginContext *pContext, const cell_t *params) { if (iserver == NULL) @@ -1256,6 +1282,7 @@ sp_nativeinfo_t g_Natives[] = {"GetClientAimTarget", sm_GetClientAimTarget}, {"SetEntityModel", sm_SetEntityModel}, {"GetPlayerDecalFile", GetPlayerDecalFile}, + {"GetPlayerJingleFile", GetPlayerJingleFile}, {"GetServerNetStats", GetServerNetStats}, {"EquipPlayerWeapon", WeaponEquip}, {"ActivateEntity", ActivateEntity}, diff --git a/plugins/include/sdktools_functions.inc b/plugins/include/sdktools_functions.inc index a11cce90..45298493 100644 --- a/plugins/include/sdktools_functions.inc +++ b/plugins/include/sdktools_functions.inc @@ -270,7 +270,7 @@ native GetTeamClientCount(index); native SetEntityModel(entity, const String:model[]); /** - * Retrieves the decal file name associated to a given client. + * Retrieves the decal file name associated with a given client. * * @param client Player's index. * @param hex Buffer to store the logo filename. @@ -280,6 +280,17 @@ native SetEntityModel(entity, const String:model[]); */ native bool:GetPlayerDecalFile(client, String:hex[], maxlength); +/** + * Retrieves the jingle file name associated with a given client. + * + * @param client Player's index. + * @param hex Buffer to store the jingle filename. + * @param maxlength Maximum length of string buffer. + * @return True on success, otherwise false. + * @error Invalid client or client not in game. + */ +native bool:GetPlayerJingleFile(client, String:hex[], maxlength); + /** * Returns the average server network traffic in bytes/sec. *