AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   tf_wearable problems (https://forums.alliedmods.net/showthread.php?t=325246)

ABCDEFGH23 06-14-2020 00:07

tf_wearable problems
 
Code:

void GiveHat(int client, int index, int level, int quality, bool Preserve, int attributesCount, int[] attributes, float[] attributesVal)
{
        Handle hItem = TF2Items_CreateItem(OVERRIDE_ALL);
        int flags = OVERRIDE_ATTRIBUTES | OVERRIDE_ITEM_LEVEL | OVERRIDE_ITEM_QUALITY;
        if(Preserve){
      flags |= PRESERVE_ATTRIBUTES;
        }
        TF2Items_SetClassname(hItem, "tf_wearable");
        TF2Items_SetFlags(hItem, flags);
        TF2Items_SetItemIndex(hItem, index);
        TF2Items_SetFlags(hItem, flags);
        TF2Items_SetLevel(hItem, level);
        TF2Items_SetQuality(hItem, quality);
        for (int i = 0; i < attributesCount; i ++)TF2Items_SetAttribute(hItem, i, attributes[i], attributesVal[i]);
        if (attributesCount != 0)TF2Items_SetNumAttributes(hItem, attributesCount);
       
        TF2_RemoveAllWearables(client);
        TF2Items_GiveNamedItem(client, hItem);
       
        CloneHandle(hItem);

}

void TF2_RemoveAllWearables(int client)
{
    int ent = -1;
    while ((ent = FindEntityByClassname(ent , "tf_wearable")) != -1)
    {
        if (client != GetEntPropEnt(ent , Prop_Send, "m_hOwnerEntity")) continue;
        AcceptEntityInput(ent , "Kill");
    }
}


---------------------------------------------------------------


Code:

int TF2_SpawnWearable(int client, int iDef=52, int iLevel=100, int iQuality=0)
{
    int iTeam = GetClientTeam(client);
    int iItem = CreateEntityByName("tf_wearable");
   
        SetEntPropEnt(iItem, Prop_Send, "m_hOwnerEntity", client);
        SetEntProp(iItem, Prop_Send, "m_fEffects",            EF_BONEMERGE|EF_BONEMERGE_FASTCULL|EF_NOSHADOW|EF_PARENT_ANIMATES);
        SetEntProp(iItem, Prop_Send, "m_iTeamNum",            iTeam);
        SetEntProp(iItem, Prop_Send, "m_nSkin",                (iTeam-2));
        SetEntProp(iItem, Prop_Send, "m_CollisionGroup",      11);
        SetEntProp(iItem, Prop_Send, "m_iItemDefinitionIndex", iDef);
        SetEntProp(iItem, Prop_Send, "m_iEntityLevel",        iLevel);
        SetEntProp(iItem, Prop_Send, "m_iEntityQuality",      iQuality);
        DispatchSpawn(iItem);
       
    return iItem;
}

it's not work... :((

PC Gamer 06-14-2020 13:31

Re: tf_wearable problems
 
Quote:

Originally Posted by ABCDEFGH23 (Post 2705540)
it's not work...

Really? That's it? Three words to describe your problem? And... You didn't post all of your code? Why are you using one method to spawn any cosmetic, and a different method to spawn a Batter's Helmet?


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

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