diff --git a/extensions/sdktools/vnatives.cpp b/extensions/sdktools/vnatives.cpp index fbddec86..94a91b92 100644 --- a/extensions/sdktools/vnatives.cpp +++ b/extensions/sdktools/vnatives.cpp @@ -1293,6 +1293,34 @@ static cell_t GetPlayerResourceEntity(IPluginContext *pContext, const cell_t *pa return -1; } +static cell_t GivePlayerAmmo(IPluginContext *pContext, const cell_t *params) +{ + static ValveCall *pCall = NULL; + if (!pCall) + { + ValvePassInfo pass[3]; + InitPass(pass[0], Valve_POD, PassType_Basic, PASSFLAG_BYVAL); + InitPass(pass[1], Valve_POD, PassType_Basic, PASSFLAG_BYVAL); + InitPass(pass[2], Valve_Bool, PassType_Basic, PASSFLAG_BYVAL); + if (!CreateBaseCall("GiveAmmo", ValveCall_Player, &pass[0], pass, 3, &pCall)) + { + return pContext->ThrowNativeError("\"GiveAmmo\" not supported by this mod"); + } else if (!pCall) { + return pContext->ThrowNativeError("\"GiveAmmo\" wrapper failed to initialize"); + } + } + + int ammoGiven; + START_CALL(); + DECODE_VALVE_PARAM(1, thisinfo, 0); + DECODE_VALVE_PARAM(2, vparams, 0); + DECODE_VALVE_PARAM(3, vparams, 1); + DECODE_VALVE_PARAM(4, vparams, 2); + FINISH_CALL_SIMPLE(&ammoGiven); + + return ammoGiven; +} + sp_nativeinfo_t g_Natives[] = { {"ExtinguishEntity", ExtinguishEntity}, @@ -1322,5 +1350,6 @@ sp_nativeinfo_t g_Natives[] = {"ActivateEntity", ActivateEntity}, {"SetClientInfo", SetClientInfo}, {"GetPlayerResourceEntity", GetPlayerResourceEntity}, + {"GivePlayerAmmo", GivePlayerAmmo}, {NULL, NULL}, }; diff --git a/gamedata/sdktools.games/engine.csgo.txt b/gamedata/sdktools.games/engine.csgo.txt index 1b1ae172..f00c1951 100644 --- a/gamedata/sdktools.games/engine.csgo.txt +++ b/gamedata/sdktools.games/engine.csgo.txt @@ -334,6 +334,12 @@ "linux" "464" "mac" "464" } + "GiveAmmo" + { + "windows" "272" + "linux" "273" + "mac" "273" + } } } } diff --git a/gamedata/sdktools.games/game.cstrike.txt b/gamedata/sdktools.games/game.cstrike.txt index 57c798c8..9bb6d4ac 100644 --- a/gamedata/sdktools.games/game.cstrike.txt +++ b/gamedata/sdktools.games/game.cstrike.txt @@ -110,6 +110,12 @@ "linux" "419" "mac" "419" } + "GiveAmmo" + { + "windows" "251" + "linux" "252" + "mac" "252" + } } } } diff --git a/plugins/include/sdktools_functions.inc b/plugins/include/sdktools_functions.inc index 45298493..ec16e086 100644 --- a/plugins/include/sdktools_functions.inc +++ b/plugins/include/sdktools_functions.inc @@ -331,3 +331,16 @@ native ActivateEntity(entity); * @error Invalid client index, or client not connected. */ native SetClientInfo(client, const String:key[], const String:value[]); + +/** + * Gives ammo of a certain type to a player. + * This natives obeys the maximum amount of ammo a player can carry per ammo type. + * + * @param client The client index. + * @param amount Amount of ammo to give. Is capped at ammotype's limit. + * @param ammotype Type of ammo to give to player. + * @param suppressSound If true, don't play the ammo pickup sound. + * + * @return Amount of ammo actually given. + */ +native GivePlayerAmmo(client, amount, ammotype, bool:suppressSound=false); \ No newline at end of file