There maybe is that kind plugin, but I did not find.
I quickly peek TF2 server.dll libary (...and source)
I found these, I'm not 100% sure these are correct.
PHP Code:
Windows
407 DispenseAmmo_sub_10469720
Linux
420 CObjectDispenser::DispenseAmmo(CTFPlayer *)
bool CObjectDispenser::DispenseAmmo( CTFPlayer *pPlayer )
Then try with DHooks to hook "obj_dispenser", block that callback.
*edit
There maybe are better methods than this one.
*edit
Here plugin for Windows OS. I have not tested Linux offset
PHP Code:
#include <dhooks>
DynamicHook DHook;
int offset = 407; // Windows 407, Linux 420 ?
public void OnPluginStart()
{
// bool CObjectDispenser::DispenseAmmo( CTFPlayer *pPlayer )
DHook = new DynamicHook(offset, HookType_Entity, ReturnType_Bool, ThisPointer_CBaseEntity);
if(DHook == INVALID_HANDLE)
{
SetFailState("DynamicHook failed to create with offset %i", offset);
}
DHook.AddParam(HookParamType_CBaseEntity, _, DHookPass_ByVal);
HookEventEx("player_builtobject", player_builtobject);
}
public void player_builtobject(Event event, const char[] name, bool dontBroadcast)
{
/*
Server event "player_builtobject", Tick 3871:
- "userid" = "2"
- "object" = "0"
- "index" = "231"
*/
//if(StrEqual(classname, "obj_dispenser"), true)
if(event.GetInt("object") == 0)
{
int client = GetClientOfUserId(event.GetInt("userid"));
if(!client || CheckCommandAccess(client, "DispenseAmmo_Access", ADMFLAG_RCON))
return;
int entity = event.GetInt("index");
// fake event executed ?
if(entity <= MaxClients || !IsValidEntity(entity))
return;
DHook.HookEntity(Hook_Pre, entity, DispenseAmmo);
}
}
public MRESReturn DispenseAmmo(int pThis, DHookReturn hReturn, DHookParam hParams)
{
if(!hParams.Get(0) || hParams.IsNull(1))
return MRES_Ignored;
int client = hParams.Get(1);
if(client <= 0 || client > MaxClients)
return MRES_Ignored;
if(CheckCommandAccess(client, "DispenseAmmo_Access", ADMFLAG_RCON))
return MRES_Ignored;
//PrintToServer("DispenseAmmo NOPE %N", client);
hReturn.Value = false;
return MRES_Supercede;
}
__________________