Raised This Month: $32 Target: $400
 8% 

[TF2] No ammo from dispenser?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Kolaxie
Member
Join Date: Aug 2021
Location: I live inside internet
Old 08-22-2022 , 12:47   [TF2] No ammo from dispenser?
Reply With Quote #1

Hi everyone, i was wondering if it was possible to disable ammo gain from dispenser with a plugin for TF2? that include all ammo (bullet, grenade, rocket, metal etc...)
__________________
Owner of Team Fortress 2 Gemara Servers: https://discord.gg/AgsZvfQSut

"Don't worry, it will obviously work first try. Trust me" -Famous Last Words

(Suck at Source SP smh)
Kolaxie is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 08-22-2022 , 20:12   Re: [TF2] No ammo from dispenser?
Reply With Quote #2

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::DispenseAmmoCTFPlayer *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(offsetHookType_EntityReturnType_BoolThisPointer_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[] namebool 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_PreentityDispenseAmmo);
    }
}


public 
MRESReturn DispenseAmmo(int pThisDHookReturn hReturnDHookParam hParams)
{
    if(!
hParams.Get(0) || hParams.IsNull(1))
        return 
MRES_Ignored;

    
int client hParams.Get(1);

    if(
client <= || 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;

__________________
Do not Private Message @me

Last edited by Bacardi; 08-23-2022 at 05:01. Reason: fixed offsets
Bacardi is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:55.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode