AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [TF2] Property for sentry gun maximum ammo? (https://forums.alliedmods.net/showthread.php?t=324778)

Tezemi 05-26-2020 22:53

[TF2] Property for sentry gun maximum ammo?
 
I was wondering if anyone knows a property or method for setting the maximum ammo of a sentry gun. Currently, I'm setting the ammo of a sentry gun just fine using "m_iAmmoShells", but I can't find a similar property for maximum ammo. Although I've noticed "m_iMaxAmmoShells" does exist in the game's source, I get the "can't find property" exception when trying to set it.

Currently I've implemented a hacky work around where I'm constantly checking to make sure the sentry's ammo doesn't go over the max, but I'm just wondering if anyone has a better solution. Here's what it looks like:
Code:

static Action CheckApplyMiniLowAmmo(Handle timer, DataPack pack)
{
    pack.Reset();

    int client = pack.ReadCell();
    int sent = pack.ReadCell();
    int ammoAmount = pack.ReadCell();

    int state = GetEntProp(sent, Prop_Send, "m_iState");
    if (state != 0 && GetEntProp(sent, Prop_Send, "m_iAmmoShells") > ammoAmount)
    {
        if (GetEntProp(sent, Prop_Send, "m_iHealth") >= 100 && GetEntProp(sent, Prop_Send, "m_iAmmoShells") >= ammoAmount)
        {
            int currMetal = GetEntProp(client, Prop_Data, "m_iAmmo", 4, 3);
            SetEntProp(client, Prop_Data, "m_iAmmo", currMetal + 40, 4, 3);
        }

        SetEntProp(sent, Prop_Send, "m_iAmmoShells", ammoAmount);
    }

    ReduceSentryAmmo(client, sent, ammoAmount);
}


fysiks 05-26-2020 23:30

Re: [TF2] Property for sentry gun maximum ammo?
 
TF2 is a Source game so you'll need to post in the SourceMod section.


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

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