This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

Plugin Help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Blinx
Senior Member
Join Date: Oct 2013
Old 04-14-2016 , 19:45   Plugin Help
Reply With Quote #1

Hey, hoping someone can help resolve this error:

"Native "ReadPackCell" reported: DataPack operation is out of bounds."

PHP Code:
#pragma semicolon 1

#include <sourcemod>
#include <tf2items>
#include <tf2_stocks>
#include <freak_fortress_2>
#include <freak_fortress_2_subplugin>

public Plugin:myinfo = {
   
name "Freak Fortress 2: Temp Melee Weapon",
   
author "Blinx",
};

new 
String:weaponAttribs[64];
new 
String:weaponClass[64];
new 
thisWeaponIndex;

new 
String:reWeaponAttribs[64];
new 
String:reWeaponClass[64];
new 
reWeaponIndex;

public 
OnPluginStart2()
{
}

public 
Action:FF2_OnAbility2(index,const String:plugin_name[],const String:ability_name[],action)
{
   if (!
strcmp(ability_name,"rage_tempMelee"))
      
rage_tempMelee(ability_nameindex);
}

stock SpawnWeapon(client,String:name[],index,level,qual,String:att[])
{
   new 
Handle:hWeapon TF2Items_CreateItem(OVERRIDE_ALL|FORCE_GENERATION);
   
TF2Items_SetClassname(hWeaponname);
   
TF2Items_SetItemIndex(hWeaponindex);
   
TF2Items_SetLevel(hWeaponlevel);
   
TF2Items_SetQuality(hWeaponqual);
   new 
String:atts[32][32];
   new 
count ExplodeString(att" ; "atts3232);
   if (
count 0)
   {
      
TF2Items_SetNumAttributes(hWeaponcount/2);
      new 
i2 0;
      for (new 
0counti+=2)
      {
         
TF2Items_SetAttribute(hWeaponi2StringToInt(atts[i]), StringToFloat(atts[i+1]));
         
i2++;
      }
   }
   else
      
TF2Items_SetNumAttributes(hWeapon0);
   if (
hWeapon==INVALID_HANDLE)
      return -
1;
   new 
entity TF2Items_GiveNamedItem(clienthWeapon);
   
CloseHandle(hWeapon);
   
EquipPlayerWeapon(cliententity);
   return 
entity;
}

rage_tempMelee(const String:ability_name[], index)
{
   new 
Handle:pack CreateDataPack();
   new 
Boss=GetClientOfUserId(FF2_GetBossUserId(index));
   
FF2_GetAbilityArgumentString(indexthis_plugin_nameability_name1weaponAttribssizeof(weaponAttribs));
   
FF2_GetAbilityArgumentString(indexthis_plugin_nameability_name2weaponClasssizeof(weaponClass));
   
thisWeaponIndex FF2_GetAbilityArgument(indexthis_plugin_nameability_name3);
   new 
Float:duration=FF2_GetAbilityArgumentFloat(indexthis_plugin_nameability_name4);
   
   
WritePackCell(packindex);
   
WritePackCell(packBoss);
   
   
TF2_RemoveWeaponSlot(BossTFWeaponSlot_Melee);
   
SetEntPropEnt(BossProp_Send"m_hActiveWeapon"SpawnWeapon(BossweaponClassthisWeaponIndex1008weaponAttribs));
   
CreateDataTimer(durationnormalMeleepackTIMER_DATA_HNDL_CLOSE);
}

public 
Action:normalMelee(Handle:timerHandle:pack)
{
    
ResetPack(pack);
    new 
index=ReadPackCell(pack); //This is where the error happens
    
new Boss=ReadPackCell(pack);

    
FF2_GetAbilityArgumentString(indexthis_plugin_name"rage_tempMelee"5reWeaponAttribssizeof(reWeaponAttribs));
    
FF2_GetAbilityArgumentString(indexthis_plugin_name"rage_tempMelee"6reWeaponClasssizeof(reWeaponClass));
    
reWeaponIndex FF2_GetAbilityArgument(indexthis_plugin_name"rage_tempMelee"7);
    
    
TF2_RemoveWeaponSlot(BossTFWeaponSlot_Melee);
    
SetEntPropEnt(BossProp_Send"m_hActiveWeapon"SpawnWeapon(BossreWeaponClassreWeaponIndex15reWeaponAttribs));

Thanks in advance.

Last edited by Blinx; 04-14-2016 at 19:47.
Blinx is offline
Darthmule
AlliedModders Donor
Join Date: May 2012
Location: Netherlands
Old 04-15-2016 , 02:08   Re: Plugin Help
Reply With Quote #2

datapack timers should have their "pack" type send as DataPack, not as a handle.

PHP Code:
public Action normalMelee(Handle timerDataPack pack

Last edited by Darthmule; 04-15-2016 at 02:09. Reason: forgot a )
Darthmule is offline
Blinx
Senior Member
Join Date: Oct 2013
Old 04-15-2016 , 08:41   Re: Plugin Help
Reply With Quote #3

Thanks for the reply Darth but that wasn't the problem as it turns out, it was because of the order I was creating the pack, creating the timer and then writing stuff to the pack:

PHP Code:
rage_tempMelee(const String:ability_name[], index)
{
   new 
Boss=GetClientOfUserId(FF2_GetBossUserId(index));
   
FF2_GetAbilityArgumentString(indexthis_plugin_nameability_name1weaponAttribssizeof(weaponAttribs));
   
FF2_GetAbilityArgumentString(indexthis_plugin_nameability_name2weaponClasssizeof(weaponClass));
   
thisWeaponIndex FF2_GetAbilityArgument(indexthis_plugin_nameability_name3);
   new 
Float:duration=FF2_GetAbilityArgumentFloat(indexthis_plugin_nameability_name4);
   
   
TF2_RemoveWeaponSlot(BossTFWeaponSlot_Melee);
   
SetEntPropEnt(BossProp_Send"m_hActiveWeapon"SpawnWeapon(BossweaponClassthisWeaponIndex1008weaponAttribs));
   
   new 
Handle:pack;
   
CreateDataTimer(durationnormalMeleepackTIMER_DATA_HNDL_CLOSE);
   
   
WritePackCell(packindex);
   
WritePackCell(packBoss);

I don't really know why this made a difference to it but it did, it's all working fine and dandy now.
Blinx is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 04-15-2016 , 16:37   Re: Plugin Help
Reply With Quote #4

The correct way to use CreateDataTimer(using new syntax):
PHP Code:
Datapack pack;
CreateDataTimer(<params to pass here>);
<
write data to pack here
Why the above snippet is valid is because CreateDataTimer creates a new datapack for you.

Last edited by WildCard65; 04-15-2016 at 16:37.
WildCard65 is offline
Blinx
Senior Member
Join Date: Oct 2013
Old 04-15-2016 , 16:47   Re: Plugin Help
Reply With Quote #5

Oh for reals? Well thanks for clearing that up, when looking for a solution to this, I found about 5 different ways people used to create timed data packs.
Blinx is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 04-15-2016 , 19:40   Re: Plugin Help
Reply With Quote #6

Source of CreateDataTimer: https://github.com/alliedmodders/sou...imers.inc#L206
WildCard65 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 13:05.


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