AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   TF2Items (https://forums.alliedmods.net/forumdisplay.php?f=146)
-   -   What am I doing wrong? (Crash, code snippet included) (https://forums.alliedmods.net/showthread.php?t=307713)

StrikerMan780 05-22-2018 00:18

What am I doing wrong? (Crash, code snippet included)
 
For some reason, at some point, this code started crashing TF2 (on the TF2Items_GiveNamedItem calls), but not always. Any ideas?

These functions are called at player spawn.
PHP Code:

public CreateQuakeRailgun(client)
{
    
TF2_RemoveWeaponSlot(client1);
                
    new 
Handle:hWeapon TF2Items_CreateItem(OVERRIDE_ALL);
    
    
TF2Items_SetClassname(hWeapon"tf_weapon_shotgun_soldier");
    
TF2Items_SetItemIndex(hWeapon10);
    
TF2Items_SetLevel(hWeapon99);
    
TF2Items_SetQuality(hWeapon9);
                
    
TF2Items_SetNumAttributes(hWeapon11);
    
TF2Items_SetAttribute(hWeapon0ATTRIB_CRIT_DISABLE0.0);
    
TF2Items_SetAttribute(hWeapon1ATTRIB_CANCEL_FALL1.0);
    
TF2Items_SetAttribute(hWeapon2ATTRIB_SPREAD_BONUS0.0);
    
TF2Items_SetAttribute(hWeapon3ATTRIB_SNIPER_PENETRATE_CHARGE1.0);
    
TF2Items_SetAttribute(hWeapon4ATTRIB_MULT_BULLETS_PER_SHOT0.1);
    
TF2Items_SetAttribute(hWeapon5ATTRIB_FIRERATE_PENALTY1.75);
    
TF2Items_SetAttribute(hWeapon6ATTRIB_CRIT_KILL_GIB1.0);
    
TF2Items_SetAttribute(hWeapon7ATTRIB_SHOT_PENETRATE_ALL1.0);
    
TF2Items_SetAttribute(hWeapon8ATTRIB_PROJECTILE_PENETRATION1.0);
    
TF2Items_SetAttribute(hWeapon9ATTRIB_SNIPER_FIRES_TRACER1.0);
    
TF2Items_SetAttribute(hWeapon10ATTRIB_DECREASE_DEPLOYTIME0.32);
    
    new 
SecondaryWeapon TF2Items_GiveNamedItem(clienthWeapon);
    
EquipPlayerWeapon(clientSecondaryWeapon);
    
CloseHandle(hWeapon);


This didn't cause a crash in 2013 or so. Now it does. I'm using the latest linux build of TF2Items. Server's running on Ubuntu.

StrikerMan780 05-22-2018 01:31

Re: What am I doing wrong? (Crash, code snippet included)
 
Ok, I've narrowed it down to the railgun code specifically. Removed the block that's fine from the first post.

I've tried to make tweaks to the railgun code, but this is what I end up with:

PHP Code:

L 05/22/2018 01:39:01: [SMCall stack trace:
L 05/22/2018 01:39:01: [SM]   [0TF2Items_GiveNamedItem
L 05
/22/2018 01:39:01: [SM]   [1Line 3275C:\Users\Striker\OneDrive\SourcePawn\Code\StrikerMod.sp::CreateQuakeRailgun
L 05
/22/2018 01:39:01: [SM]   [2Line 1654C:\Users\Striker\OneDrive\SourcePawn\Code\StrikerMod.sp::Event_PostInventoryApplication
L 05
/22/2018 01:39:01: [SM]   [4TF2_RespawnPlayer
L 05
/22/2018 01:39:01: [SM]   [5Line 2472C:\Users\Striker\OneDrive\SourcePawn\Code\StrikerMod.sp::RespawnPlayer
L 05
/22/2018 01:39:01: [TF2ITEMS] ---------------------------------------
L 05/22/2018 01:39:01: [TF2ITEMS] >>> szClassname tf_weapon_shotgun
L 05
/22/2018 01:39:01: [TF2ITEMS] >>> iItemDefinitionIndex 415
L 05
/22/2018 01:39:01: [TF2ITEMS] >>> iEntityQuality 9
L 05
/22/2018 01:39:01: [TF2ITEMS] >>> iEntityLevel 99
L 05
/22/2018 01:39:01: [TF2ITEMS] ---------------------------------------
L 05/22/2018 01:39:01: [TF2ITEMS] >>> iAttributeDefinitionIndex 15
L 05
/22/2018 01:39:01: [TF2ITEMS] >>> flValue 0.000000
L 05
/22/2018 01:39:01: [TF2ITEMS] ---------------------------------------
L 05/22/2018 01:39:01: [TF2ITEMS] >>> iAttributeDefinitionIndex 275
L 05
/22/2018 01:39:01: [TF2ITEMS] >>> flValue 1.000000
L 05
/22/2018 01:39:01: [TF2ITEMS] ---------------------------------------
L 05/22/2018 01:39:01: [TF2ITEMS] >>> iAttributeDefinitionIndex 106
L 05
/22/2018 01:39:01: [TF2ITEMS] >>> flValue 0.000000
L 05
/22/2018 01:39:01: [TF2ITEMS] ---------------------------------------
L 05/22/2018 01:39:01: [TF2ITEMS] >>> iAttributeDefinitionIndex 308
L 05
/22/2018 01:39:01: [TF2ITEMS] >>> flValue 1.000000
L 05
/22/2018 01:39:01: [TF2ITEMS] ---------------------------------------
L 05/22/2018 01:39:01: [TF2ITEMS] >>> iAttributeDefinitionIndex 45
L 05
/22/2018 01:39:01: [TF2ITEMS] >>> flValue 0.100000
L 05
/22/2018 01:39:01: [TF2ITEMS] ---------------------------------------
L 05/22/2018 01:39:01: [TF2ITEMS] >>> iAttributeDefinitionIndex 5
L 05
/22/2018 01:39:01: [TF2ITEMS] >>> flValue 1.750000
L 05
/22/2018 01:39:01: [TF2ITEMS] ---------------------------------------
L 05/22/2018 01:39:01: [TF2ITEMS] >>> iAttributeDefinitionIndex 309
L 05
/22/2018 01:39:01: [TF2ITEMS] >>> flValue 1.000000
L 05
/22/2018 01:39:01: [TF2ITEMS] ---------------------------------------
L 05/22/2018 01:39:01: [TF2ITEMS] >>> iAttributeDefinitionIndex 389
L 05
/22/2018 01:39:01: [TF2ITEMS] >>> flValue 1.000000
L 05
/22/2018 01:39:01: [TF2ITEMS] ---------------------------------------
L 05/22/2018 01:39:01: [TF2ITEMS] >>> iAttributeDefinitionIndex 266
L 05
/22/2018 01:39:01: [TF2ITEMS] >>> flValue 1.000000
L 05
/22/2018 01:39:01: [TF2ITEMS] ---------------------------------------
L 05/22/2018 01:39:01: [TF2ITEMS] >>> iAttributeDefinitionIndex 305
L 05
/22/2018 01:39:01: [TF2ITEMS] >>> flValue 1.000000
L 05
/22/2018 01:39:01: [TF2ITEMS] ---------------------------------------
L 05/22/2018 01:39:01: [TF2ITEMS] >>> iAttributeDefinitionIndex 178
L 05
/22/2018 01:39:01: [TF2ITEMS] >>> flValue 0.320000
L 05
/22/2018 01:39:01: [TF2ITEMS] ---------------------------------------
L 05/22/2018 01:39:01: [SMException reportedItem is NULLFile a bug report if you are sure you set all the data correctly. (Try the FORCE_GENERATION flag.) 


asherkin 05-22-2018 04:40

Re: What am I doing wrong? (Crash, code snippet included)
 
Did you try the FORCE_GENERATION flag? It exists for the cases where the classname is class-specific (like "tf_weapon_shotgun_soldier").

Code:

TF2Items_CreateItem(OVERRIDE_ALL|FORCE_GENERATION);

StrikerMan780 05-22-2018 05:29

Re: What am I doing wrong? (Crash, code snippet included)
 
I've got it figured out a short while ago, but thanks. That was it.


All times are GMT -4. The time now is 10:21.

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