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

tf_wearable crash and oddities


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CoolJosh3k
AlliedModders Donor
Join Date: Mar 2010
Old 06-13-2013 , 22:39   tf_wearable crash and oddities
Reply With Quote #1

Might as well make a thread specifically for this issue...

When I try to force a tf_wearble weapon onto a player, the server crashes. tf_wearble is currently used for both solly and demo booties.

As well as crashing, I noticed various attempts to block that weapon, will give 2 secondary weapons. I quite often have both gunboats+shotgun(+rocket+shovel) as a result.

I presume this happens because there is an extra net prop associated with tf_wearable items, but I don't quite have the level of understanding to know.
CoolJosh3k is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 06-14-2013 , 03:10   Re: tf_wearable crash and oddities
Reply With Quote #2

Please post some code.
__________________
asherkin is offline
CoolJosh3k
AlliedModders Donor
Join Date: Mar 2010
Old 06-14-2013 , 09:36   Re: tf_wearable crash and oddities
Reply With Quote #3

Sure, will this suffice?

PHP Code:
    if (class == TFClass_DemoMan)
    {
        
slotid[0] = GetPlayerWeaponSlot(client0);
        
/*
//////////    "tf_wearable" currently crashes server.
        if (slotid[0] == -1 && (GetConVarInt(disable_flags_demo) & 1) == 0)
        {
            new Handle:item = TF2Items_CreateItem(OVERRIDE_ALL | FORCE_GENERATION);
            TF2Items_SetClassname(item, "tf_wearable");
            TF2Items_SetItemIndex(item, def_dem_pri_itemid);
            TF2Items_SetQuality(item, 6);
            TF2Items_SetLevel(item, 1);
            TF2Items_SetNumAttributes(item, 2);
            TF2Items_SetAttribute(item, 0, 246, 2.0);
            TF2Items_SetAttribute(item, 1, 26, 25.0);
            slotid[0] = TF2Items_GiveNamedItem(client, item);
            EquipPlayerWeapon(client, slotid[0]);
            CloseHandle(item);
        }
//////////
        */
        
slotid[1] = GetPlayerWeaponSlot(client1);
        if (
slotid[1] == -&& (GetConVarInt(disable_flags_demo) & 2) == 0)
        {
            new 
Handle:item TF2Items_CreateItem(OVERRIDE_ALL FORCE_GENERATION);
            
TF2Items_SetClassname(item"tf_weapon_pipebomblauncher");
            
TF2Items_SetItemIndex(itemdef_dem_sec_itemid);
            
TF2Items_SetQuality(item6);
            
TF2Items_SetLevel(item1);
            
TF2Items_SetNumAttributes(item0);
            
slotid[1] = TF2Items_GiveNamedItem(clientitem);
            
EquipPlayerWeapon(clientslotid[1]);
            
CloseHandle(item);
        }
        
slotid[2] = GetPlayerWeaponSlot(client2);
        if (
slotid[2] == -&& (GetConVarInt(disable_flags_demo) & 4) == 0)
        {
            new 
Handle:item TF2Items_CreateItem(OVERRIDE_ALL FORCE_GENERATION);
            
TF2Items_SetClassname(item"tf_weapon_sword");
            
TF2Items_SetItemIndex(itemdef_dem_mel_itemid);
            
TF2Items_SetQuality(item6);
            
TF2Items_SetLevel(item1);
            
TF2Items_SetNumAttributes(item3);
            
TF2Items_SetAttribute(item0150.0);
            
TF2Items_SetAttribute(item1125, -25.0);
            
TF2Items_SetAttribute(item22191.0);
            
slotid[2] = TF2Items_GiveNamedItem(clientitem);
            
EquipPlayerWeapon(clientslotid[2]);
            
CloseHandle(item);
        }
    } 
I just copy-pasted an old code block. I can give another example, if needed.
CoolJosh3k is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 06-14-2013 , 09:40   Re: tf_wearable crash and oddities
Reply With Quote #4

What's the value of def_dem_pri_itemid?
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
CoolJosh3k
AlliedModders Donor
Join Date: Mar 2010
Old 06-15-2013 , 05:06   Re: tf_wearable crash and oddities
Reply With Quote #5

It is 405, based on the initialization. Nothing changes it.

PHP Code:
new def_dem_pri_itemid 405def_dem_sec_itemid 207def_dem_mel_itemid 132
CoolJosh3k is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 06-16-2013 , 00:18   Re: tf_wearable crash and oddities
Reply With Quote #6

Oh wait, didn't Asherkin say there were issues with FORCE_GENERATION and tf_wearable items before? Have you tried it without FORCE_GENERATION?
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
CoolJosh3k
AlliedModders Donor
Join Date: Mar 2010
Old 06-16-2013 , 05:22   Re: tf_wearable crash and oddities
Reply With Quote #7

Ah, yes. Sorry.

In my newer code, nothing uses FORCE_GENERATION, yet it still crashes with tf_wearable weapons.
CoolJosh3k is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 06-16-2013 , 05:46   Re: tf_wearable crash and oddities
Reply With Quote #8

I took a quick look at how [TF2Items] GiveWeapon does it. Apparently it special-cases tf_wearable, tf_wearable_demoshield, and tf_powerup_bottle... it doesn't call EquipPlayerWeapon, but instead makes a call to the server-side function CBasePlayer::EquipWearable (which has an offset included in a file). So, it's probably the EquipPlayerWeapon that's causing the crashes. (Fun fact: EquipPlayerWeapon is itself a wrapper for the server-side function CBasePlayer::Weapon_Equip)

Edit: The offsets for EquipWearable and RemoveWearable are in the automated offsets dump, too, in case you don't want to have to rely on another plugin's author to get the new values after an update.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 06-16-2013 at 05:51.
Powerlord is offline
CoolJosh3k
AlliedModders Donor
Join Date: Mar 2010
Old 06-16-2013 , 12:20   Re: tf_wearable crash and oddities
Reply With Quote #9

Any chance we might see an update to the tf2items, that updates how EquipPlayerWeapon works?
CoolJosh3k is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 06-16-2013 , 14:38   Re: tf_wearable crash and oddities
Reply With Quote #10

Quote:
Originally Posted by CoolJosh3k View Post
Any chance we might see an update to the tf2items, that updates how EquipPlayerWeapon works?
TF2Items is a low-level API, you'll always have to call the correct function for what you're doing.
__________________
asherkin is offline
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 03:20.


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