View Single Post
Author Message
ABCDEFGH23
Junior Member
Join Date: Jun 2020
Location: HEEELP!!!
Old 06-14-2020 , 00:07   tf_wearable problems
Reply With Quote #1

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... (

Last edited by ABCDEFGH23; 06-14-2020 at 00:14. Reason: more info
ABCDEFGH23 is offline