Raised This Month: $ Target: $400
 0% 

Changing a weapon with TF2 items.


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
FlaminSarge
Veteran Member
Join Date: Jul 2010
Old 06-28-2012 , 18:32   Re: Changing a weapon with TF2 items.
Reply With Quote #14

Code:
stock RemovePlayerTarge(client)
{
    new edict = MaxClients+1;
    while((edict = FindEntityByClassname2(edict, "tf_wearable_demoshield")) != -1)
    {
        new idx = GetEntProp(edict, Prop_Send, "m_iItemDefinitionIndex");
        if ((idx == 131 || idx == 406) && GetEntPropEnt(edict, Prop_Send, "m_hOwnerEntity") == client && !GetEntProp(edict, Prop_Send, "m_bDisguiseWearable"))
        {
            AcceptEntityInput(edict, "Kill");
        }
    }
}
stock FindPlayerTarge(client)
{
    new edict = MaxClients+1;
    while((edict = FindEntityByClassname2(edict, "tf_wearable_demoshield")) != -1)
    {
        new idx = GetEntProp(edict, Prop_Send, "m_iItemDefinitionIndex");
        if ((idx == 131 || idx == 406) && GetEntPropEnt(edict, Prop_Send, "m_hOwnerEntity") == client && !GetEntProp(edict, Prop_Send, "m_bDisguiseWearable"))
        {
            return edict;
        }
    }
    return -1;
}
stock GetPlayerWeaponSlot_Wearable(client, slot)
{
    new edict = MaxClients+1;
    if (slot == TFWeaponSlot_Secondary)
    {
        while((edict = FindEntityByClassname2(edict, "tf_wearable_demoshield")) != -1)
        {
            new idx = GetEntProp(edict, Prop_Send, "m_iItemDefinitionIndex");
            if ((idx == 131 || idx == 406) && GetEntPropEnt(edict, Prop_Send, "m_hOwnerEntity") == client && !GetEntProp(edict, Prop_Send, "m_bDisguiseWearable"))
            {
                return edict;
            }
        }
    }
    edict = MaxClients+1;
    while((edict = FindEntityByClassname2(edict, "tf_wearable")) != -1)
    {
        decl String:netclass[32];
        if (GetEntityNetClass(edict, netclass, sizeof(netclass)) && StrEqual(netclass, "CTFWearable"))
        {
            new idx = GetEntProp(edict, Prop_Send, "m_iItemDefinitionIndex");
            if (((slot == TFWeaponSlot_Primary && (idx == 405 || idx == 608)) || (slot == TFWeaponSlot_Secondary && (idx == 57 || idx == 133 || idx == 231 || idx == 444))) && GetEntPropEnt(edict, Prop_Send, "m_hOwnerEntity") == client && !GetEntProp(edict, Prop_Send, "m_bDisguiseWearable"))
            {
                return edict;
            }
        }
    }
    return -1;
}
stock FindEntityByClassname2(startEnt, const String:classname[])
{
    /* If startEnt isn't valid shifting it back to the nearest valid one */
    while (startEnt > -1 && !IsValidEntity(startEnt)) startEnt--;
    return FindEntityByClassname(startEnt, classname);
}
There's others e.g. ones tuned to non-demoshield wearable weapons, but you can figure those out easily.
__________________
Bread EOTL GunMettle Invasion Jungle Inferno 64-bit will break everything. Don't even ask.

All plugins: Randomizer/GiveWeapon, ModelManager, etc.
Post in plugin threads with questions.
Steam is for playing games.
You will be fed to javalia otherwise.
Psyduck likes replays.
FlaminSarge is offline
 


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 21:14.


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