AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   VSH / Freak Fortress (https://forums.alliedmods.net/forumdisplay.php?f=154)
-   -   Plugin Help (https://forums.alliedmods.net/showthread.php?t=281576)

Blinx 04-14-2016 19:45

Plugin Help
 
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.

Darthmule 04-15-2016 02:08

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

PHP Code:

public Action normalMelee(Handle timerDataPack pack


Blinx 04-15-2016 08:41

Re: Plugin Help
 
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.

WildCard65 04-15-2016 16:37

Re: Plugin Help
 
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.

Blinx 04-15-2016 16:47

Re: Plugin Help
 
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.

WildCard65 04-15-2016 19:40

Re: Plugin Help
 
Source of CreateDataTimer: https://github.com/alliedmodders/sou...imers.inc#L206


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

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