Raised This Month: $51 Target: $400
 12% 

[TF2] Properly creating CTFWearableItem entities?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Damizean
SourceMod Donor
Join Date: Mar 2009
Old 07-25-2009 , 06:15   [TF2] Properly creating CTFWearableItem entities?
Reply With Quote #1

Hello fellows.

I've been messing with tf_wearable_item entities as of lately, for creating a hats plugin (attaching the wearables to the player).

The thing is the system works perfectly, but it seems to give a small error if the entity is created by the normal ways (CreateEntityByName). It prompts the following error:
Quote:
Item 'tf_wearable_item' not setup correctly. Attempting to create attributes on an unitialized item.
My current code is:
PHP Code:
    // Create wearable item and equip.
    
Entity CreateEntityByName("tf_wearable_item");
    if (!
IsValidEntity(Entity)) return;
    
    
DispatchSpawn(Entity);
    
SDKCall(hEquipWearableClientEntity);
    
    
// Setup hat
    
DispatchKeyValue(Entity"targetname"StrHatName);
    
DispatchKeyValue(Entity"model"HatModel[Hat]);
    
SetEntityModel(EntityHatModel[Hat]);

    
// Spawn and turn on
    
ActivateEntity(Entity);
    
AcceptEntityInput(Entity"TurnOn"); 
The plugin works just fine, the only thing it gives that error. I was just wondering if there was any variables I needed to setup first before attaching to the player.

Also, some screenshots to prove it works, even using custom hats (and not only hats, they can be attached to any bone). I'll be releasing the plugin if I get to fix this issue:
Screenshot 1
Screenshot 2
Screenshot 3
Screenshot 4

Edit: Problem solved, after messing a little with the code I cut down some lines of the creation of the wearable and it seems to properly initialice the entity now:
PHP Code:
    // Create wearable item and equip.
    
Entity CreateEntityByName("tf_wearable_item");
    if (!
IsValidEntity(Entity)) return;

    
SDKCall(hEquipWearableClientEntity);             // Equip the client with it.
    
SetEntityModel(EntityHatModel[Hat]);               // Set the correct model
    
DispatchKeyValue(Entity"targetname"StrHatName);  // And dispatch a name for it to be identified. 
__________________
Dat annoying guy

Last edited by Damizean; 07-25-2009 at 07:30.
Damizean is offline
Send a message via AIM to Damizean Send a message via MSN to Damizean
Reply



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 19:00.


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