Raised This Month: $32 Target: $400
 8% 

Exception reported: Invalid data pack handle


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ktraintfc
Junior Member
Join Date: Nov 2020
Old 03-21-2021 , 11:52   Exception reported: Invalid data pack handle
Reply With Quote #1

Applies to:TF2 srcds

Problem: only one of four Mirv bomblets explodes and throws error:

Code:
L 03/21/2021 - 10:40:22: [SM] Exception reported: Invalid data pack handle 1f29034a (error 3).
L 03/21/2021 - 10:40:22: [SM] Blaming: tf2renade.smx
L 03/21/2021 - 10:40:22: [SM] Call stack trace:
L 03/21/2021 - 10:40:22: [SM]   [0] ResetPack
L 03/21/2021 - 10:40:22: [SM]   [1] Line 1910, tf2renade.sp::MirvExplode2
L 03/21/2021 - 10:40:22: [SM] Plugin "tf2renade.smx" encountered error 23: Native detected error
L 03/21/2021 - 10:40:22: [SM] Invalid data handle 1f29034a (error 3) passed during timer end with TIMER_DATA_HNDL_CLOSE
L 03/21/2021 - 10:40:22: [SM] Unable to call function "MirvExplode2" due to above error(s).
Here is the affected function, starting at line 1910:

Code:
public Action:MirvExplode2(Handle:timer, Handle:pack)
{
	ResetPack(pack);
	new client = ReadPackCell(pack);
	new team = ReadPackCell(pack);
	new min = ReadPackCell(pack);
	new ent[MIRV_PARTS-min];
	new k;
	for (k=0;k<MIRV_PARTS-min;k++)
	{
		ent[k] = ReadPackCell(pack);
	}
	new Float:radius = GetConVarFloat(cvSecondary[DEMO][3]);
	new Float:center[3];
	if(IsValidEntity(ent[0]))
	{
		GetEntPropString(ent[0], Prop_Data, "m_iName", tName, sizeof(tName));
		if (strncmp(tName,"tf2mirv",7)==0)
		{
			new damage = GetConVarInt(cvSecondary[DEMO][2]);
			GetEntPropVector(ent[0], Prop_Send, "m_vecOrigin", center);
			ShowParticle(center, "ExplosionCore_MidAir", 2.0);
			EmitSoundToAll(SND_NADE_MIRV2, 0, SNDCHAN_WEAPON, SNDLEVEL_TRAFFIC, SND_NOFLAGS, SNDVOL_NORMAL, 100, _, center, NULL_VECTOR, false, 0.0);
			new oteam;
			if (team==3) {oteam=2;} else {oteam=3;}
			FindPlayersInRange(center, radius, oteam, client, true, ent[0]);
			new maxplayers = MaxClients;
			for (new j=1;j<=maxplayers;j++)
			{
				if(PlayersInRange[j]>0.0)
				{
					new tdamage = CalculateDynamicDamage(damage, j, center, radius);
					new String:tempString[32]; GetConVarString(cvNadeIcon, tempString, sizeof(tempString));
					DealDamage(j, tdamage, center, client, DMG_CRUSH, tempString);
				}
			}
			DamageBuildings(client, center, radius, damage, ent[0], true);
			RemoveEdict(ent[0]);
			
			if(min < MIRV_PARTS)
			{		
				CreateDataTimer(0.01, MirvExplode2, pack);
				WritePackCell(pack, client);
				WritePackCell(pack, team);
				WritePackCell(pack, min+1);
				for (k=0;k<MIRV_PARTS-(min+1);k++)
				{
					WritePackCell(pack, ent[k+1]);
				}
			}
			else
			{
				CloseHandle(pack);
				return Plugin_Stop;
			}
		}
	}
	CloseHandle(pack);
	return Plugin_Continue;
}
I've searched the error and nothing fits as far as I can tell....I think I might be missing something easy here.

Any help is greatly appreciated!
ktraintfc is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 03-21-2021 , 12:50   Re: Exception reported: Invalid data pack handle
Reply With Quote #2

You shouldn't use the same "pack" parameter as argument for the new CreateDataTimer

What CreateDataTimer does is delete the pack after the timer runs out, so everytime your first timer finishes, the next one will read an invalid pack (cause is set to null on deletion)
__________________
Marttt is offline
ktraintfc
Junior Member
Join Date: Nov 2020
Old 03-26-2021 , 13:06   Re: Exception reported: Invalid data pack handle
Reply With Quote #3

Quote:
Originally Posted by Marttt View Post
You shouldn't use the same "pack" parameter as argument for the new CreateDataTimer

What CreateDataTimer does is delete the pack after the timer runs out, so everytime your first timer finishes, the next one will read an invalid pack (cause is set to null on deletion)
So is it as simple as renaming the argument "pack" in CreateDataTimer?

Can u show me a fix using the code I posted above?

Thanks again!
ktraintfc is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 03-26-2021 , 13:49   Re: Exception reported: Invalid data pack handle
Reply With Quote #4

You just need to create a new datapack and store the data you want to pass to the new timer into the new pack.
PHP Code:
public Action:MirvExplode2(Handle:timerHandle:pack)
{
    
ResetPack(pack);
    new 
client ReadPackCell(pack);
    new 
team ReadPackCell(pack);
    new 
min ReadPackCell(pack);
    new 
ent[MIRV_PARTS-min];
    new 
k;
    for (
k=0;k<MIRV_PARTS-min;k++)
    {
        
ent[k] = ReadPackCell(pack);
    }
    new 
Float:radius GetConVarFloat(cvSecondary[DEMO][3]);
    new 
Float:center[3];
    if(
IsValidEntity(ent[0]))
    {
        
GetEntPropString(ent[0], Prop_Data"m_iName"tNamesizeof(tName));
        if (
strncmp(tName,"tf2mirv",7)==0)
        {
            new 
damage GetConVarInt(cvSecondary[DEMO][2]);
            
GetEntPropVector(ent[0], Prop_Send"m_vecOrigin"center);
            
ShowParticle(center"ExplosionCore_MidAir"2.0);
            
EmitSoundToAll(SND_NADE_MIRV20SNDCHAN_WEAPONSNDLEVEL_TRAFFICSND_NOFLAGSSNDVOL_NORMAL100_centerNULL_VECTORfalse0.0);
            new 
oteam;
            if (
team==3) {oteam=2;} else {oteam=3;}
            
FindPlayersInRange(centerradiusoteamclienttrueent[0]);
            new 
maxplayers MaxClients;
            for (new 
j=1;j<=maxplayers;j++)
            {
                if(
PlayersInRange[j]>0.0)
                {
                    new 
tdamage CalculateDynamicDamage(damagejcenterradius);
                    new 
String:tempString[32]; GetConVarString(cvNadeIcontempStringsizeof(tempString));
                    
DealDamage(jtdamagecenterclientDMG_CRUSHtempString);
                }
            }
            
DamageBuildings(clientcenterradiusdamageent[0], true);
            
RemoveEdict(ent[0]);
            
            if(
min MIRV_PARTS)
            {
                new 
Handle:hPack;
                
CreateDataTimer(0.01MirvExplode2hPack);
                
WritePackCell(hPackclient);
                
WritePackCell(hPackteam);
                
WritePackCell(hPackmin+1);
                for (
k=0;k<MIRV_PARTS-(min+1);k++)
                {
                    
WritePackCell(hPackent[k+1]);
                }
            }
            else
            {
                return 
Plugin_Stop;
            }
        }
    }
    return 
Plugin_Continue;

Also, you don't need to close the datapack handle in the timer callback if you are already using CreateDataTimer. That function automatically does it for you.
PHP Code:
/**
 * Creates a timer associated with a new datapack, and returns the datapack.
 * @note The datapack is automatically freed when the timer ends.
 * @note The position of the datapack is not reset or changed for the timer function.
 *
 * @param interval      Interval from the current game time to execute the given function.
 * @param func          Function to execute once the given interval has elapsed.
 * @param datapack      The newly created datapack is passed though this by-reference
 *                      parameter to the timer callback function.
 * @param flags         Timer flags.
 * @return              Handle to the timer object.  You do not need to call CloseHandle().
 */
stock Handle CreateDataTimer(float intervalTimer funcHandle &datapackint flags=0)
{
    
datapack = new DataPack();
    
flags |= TIMER_DATA_HNDL_CLOSE;
    return 
CreateTimer(intervalfuncdatapackflags);

__________________
Psyk0tik is offline
ktraintfc
Junior Member
Join Date: Nov 2020
Old 03-29-2021 , 16:33   Re: Exception reported: Invalid data pack handle
Reply With Quote #5

Quote:
Originally Posted by Crasher_3637 View Post
Also, you don't need to close the datapack handle in the timer callback if you are already using CreateDataTimer. That function automatically does it for you.
That's what I'm talking about!

All I had to do was comment out the closehandles and it works perfectly!

Thanks and have a beer on me.

Same plugin next error coming soon lol
ktraintfc is offline
ktraintfc
Junior Member
Join Date: Nov 2020
Old 04-12-2021 , 10:02   Re: Exception reported: Invalid data pack handle
Reply With Quote #6

Problem: Plugin works fine now but throws error:

Code:
L 04/12/2021 - 08:47:43: [SM] Exception reported: Invalid convar handle 0 (error 4)
L 04/12/2021 - 08:47:43: [SM] Blaming: tf2renade.smx
L 04/12/2021 - 08:47:43: [SM] Call stack trace:
L 04/12/2021 - 08:47:43: [SM]   [0] GetConVarInt
L 04/12/2021 - 08:47:43: [SM]   [1] Line 639, tf2renade.sp::PlayerSpawn
Here is the affected function, starting at line 603:

Code:
Line 603	public Action:PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
	new client;
	client = GetClientOfUserId(GetEventInt(event, "userid"));
	new class = view_as<int>(TF2_GetPlayerClass(client));
	gHolding[client]=HOLD_NONE;

	if (!gCanRun)
	{
		if (GetGameTime() > (gMapStart + 60.0))
		{
			gCanRun = true;
		}
		else
		{
			return Plugin_Continue;
		}
	}
	
	// client info
	new String:clientname[32];
	Format(clientname, sizeof(clientname), "tf2player%d", client);
	DispatchKeyValue(client, "targetname", clientname);

	if (!IsFakeClient(client) && (client>0))
	{
	SetupNade(class, GetClientTeam(client), 1);
	
	if(GetConVarInt(cvStartNades)==1)
	{
		gRemaining[0][client] = GetConVarInt(cvPrimary[class][0]);
		gRemaining[1][client] = GetConVarInt(cvSecondary[class][0]);
		gRemaining[2][client] = GetConVarInt(cvTertiary[class][0]);
	}
	else if(GetConVarInt(cvStartNades)==2)
	{
LINE 639		gRemaining[0][client] = GetConVarInt(cvPrimary[class][1]);
		gRemaining[1][client] = GetConVarInt(cvSecondary[class][1]);
		gRemaining[2][client] = GetConVarInt(cvTertiary[class][1]);
	}
	else
	{
		gRemaining[0][client] = 0;
		gRemaining[1][client] = 0;
		gRemaining[2][client] = 0;
	}
	
	new Float:angles[3];
	GetClientEyeAngles(client, angles);
	angles[2] = 0.0;
	TeleportEntity(client, NULL_VECTOR, angles, NULL_VECTOR);
	ClientCommand(client, "r_screenoverlay none\n");

	if (g_iFirstSpawn[client])
		return Plugin_Continue;

	g_iFirstSpawn[client] = true;

	PrintToChat(client, "%s %s", "Grenades are enabled:", "to use bind +nade1,+nade2,+nade3");
	}	

	return Plugin_Continue;
}
I've searched the error and tried various fixes...
ktraintfc is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 04-12-2021 , 10:09   Re: Exception reported: Invalid data pack handle
Reply With Quote #7

Is hard to help without the full code cause we don't know how/when this cvar is being created.
__________________

Last edited by Marttt; 04-12-2021 at 10:12.
Marttt is offline
ktraintfc
Junior Member
Join Date: Nov 2020
Old 04-13-2021 , 12:12   Re: Exception reported: Invalid data pack handle
Reply With Quote #8

Quote:
Originally Posted by Marttt View Post
Is hard to help without the full code cause we don't know how/when this cvar is being created.
ok here it is, thanks for looking at it
Attached Files
File Type: sp Get Plugin or Get Source (tf2renade.sp - 107 views - 115.7 KB)
ktraintfc 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 16:15.


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