Raised This Month: $359 Target: $400
 89%   Almost there!

Datapack out of bounds


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Halt
Senior Member
Join Date: Jan 2015
Location: Black Mesa
Old 09-14-2019 , 13:06   Datapack out of bounds
Reply With Quote #1

Can anyone shed some light on this error? I think I've provided all the code needed.

Code:
L 09/14/2019 - 10:58:26: [SM] Blaming: dstrikeperks1.smx
L 09/14/2019 - 10:58:26: [SM] Call stack trace:
L 09/14/2019 - 10:58:26: [SM]   [0] DataPack.ReadFloat
L 09/14/2019 - 10:58:26: [SM]   [1] Line 157, D:\Dev\Programming\Pawn\sourcemod\scripting\dstrikeperks1.sp::Timer_ArtyDetonate
L 09/14/2019 - 10:58:26: [SM] Exception reported: DataPack operation is out of bounds.
PHP Code:
    DataPack dp_ShotPack = new DataPack();
    
    for (
int iNUM_EXPLOSIONSi++)
    {
        
CreateDataTimer(f_ShotTime+5.0Timer_ArtyDetonatedp_ShotPack);

        
dp_ShotPack.WriteFloat(f_vCoords[0]);
        
dp_ShotPack.WriteFloat(f_vCoords[1]);
        
dp_ShotPack.WriteFloat(f_vCoords[2]);
    }

public 
Action Timer_ArtyDetonate(Handle timerDataPack dp_ShotPack)
{
    
float f_vCoords[3];
    
dp_ShotPack.Reset();
    
DispatchSpawn(iAmbientLight);
    
TeleportEntity(iAmbientLightf_vCoordsNULL_VECTORNULL_VECTOR);
    
CreateTimer(0.3Timer_TurnOffLightEntIndexToEntRef(iAmbientLight));
    
f_vCoords[0] = dp_ShotPack.ReadFloat() + GetRandomFloat(-100.0100.0); //Line 157
    
f_vCoords[1] = dp_ShotPack.ReadFloat() + GetRandomFloat(-100.0100.0);
    
f_vCoords[2] = dp_ShotPack.ReadFloat(); 
Halt is offline
ShD3luxe
Member
Join Date: Aug 2019
Location: Localhost
Old 09-14-2019 , 14:18   Re: Datapack out of bounds
Reply With Quote #2

Try like this
PHP Code:
public void function()
{
    for (
int i 0NUM_EXPLOSIONSi++)
    {
        
DataPack dp_ShotPack = new DataPack();
        for(
int ind 0;ind sizeof(f_vCoords);ind++)
        {
              
dp_ShotPack.WriteFloat(f_vCoords[ind]);
        }
        
CreateDataTimer(f_ShotTime+5.0Timer_ArtyDetonatedp_ShotPack);
    }
}
public 
Action Timer_ArtyDetonate(Handle timerDataPack dp_ShotPack)
{
    
float f_vCoords[3];
    
dp_ShotPack.Reset();
    
f_vCoords[0] = dp_ShotPack.ReadFloat() + GetRandomFloat(-100.0100.0); //Line 157
    
f_vCoords[1] = dp_ShotPack.ReadFloat() + GetRandomFloat(-100.0100.0);
    
f_vCoords[2] = dp_ShotPack.ReadFloat(); 
    
DispatchSpawn(iAmbientLight);
    
// first get the coords from the data pack then teleport the entity
    
TeleportEntity(iAmbientLightf_vCoordsNULL_VECTORNULL_VECTOR); 
    
CreateTimer(0.3Timer_TurnOffLightEntIndexToEntRef(iAmbientLight));

You need to create a datapack for each timer , your way will first send an empty datapack and then it will just populate it until the loop ends.

Last edited by ShD3luxe; 09-14-2019 at 14:25.
ShD3luxe is offline
Impact123
Veteran Member
Join Date: Oct 2011
Location: Germany
Old 09-18-2019 , 01:43   Re: Datapack out of bounds
Reply With Quote #3

CreateDataTimer creates a new DataPack itself. Pass an empty DataPack variable to avoid leaks.
__________________

Last edited by Impact123; 09-18-2019 at 01:49.
Impact123 is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 09-18-2019 , 05:36   Re: Datapack out of bounds
Reply With Quote #4

PHP Code:
    
    
for (int iNUM_EXPLOSIONSi++)
    {
        
DataPack dp_ShotPack;
        
CreateDataTimer(f_ShotTime+5.0Timer_ArtyDetonatedp_ShotPack);

        
dp_ShotPack.WriteFloat(f_vCoords[0]);
        
dp_ShotPack.WriteFloat(f_vCoords[1]);
        
dp_ShotPack.WriteFloat(f_vCoords[2]);
    } 
__________________
Ilusion9 is offline
Reply


Thread Tools
Display Modes

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 22:11.


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