switch( xArray2[HUDMSG_RECEIVER][0] )
{
case EOS: target = team = 0;
case '~': { target = find_player("b", xArray2[HUDMSG_RECEIVER][1]); target = !target ? -1:target; team = 0; }
case '#': { target = find_player("k", str_to_num(xArray2[HUDMSG_RECEIVER][1])); target = !target ? -1:target; team = 0; }
case '@':
{
target = 0;
switch( xArray2[HUDMSG_RECEIVER][1] )
{
case 'C', 'c', 'G', 'g': team = 'C';
case 'T', 't', 'P', 'p': team = 'T';
case 's', 'S': team = 'S';
default: team = -1;
}
}
default:
{
team = 0;
target = find_player("a", xArray2[HUDMSG_RECEIVER]); // search for player by fullname
if(!target) target = find_player("c", xArray2[HUDMSG_RECEIVER]); // search for player by steamid
if(!target) target = find_player("d", xArray2[HUDMSG_RECEIVER]); // search for player by ip
if(!target) target = -1;
}
}
if(xArray2[HUDMSG_ID][0] != EOS) // if hudmessage has a taskid to be able to terminate it
{
if(!TrieKeyExists(Trie_Hudmessages_ids, xArray2[HUDMSG_ID]))
TrieSetCell(Trie_Hudmessages_ids, xArray2[HUDMSG_ID], (iCurTaskID=g_TaskIDs));
else
TrieGetCell(Trie_Hudmessages_ids, xArray2[HUDMSG_ID], iCurTaskID);
if((target > 0 || team > 0) && pnum > 0)
{
x = pnum;
while( pnum-- > 0 )
{
n = players[pnum];
// Removing the temporary repeat task from the run task list/trie
if(xArray2[HUDMSG_REPEAT] > 1)
{
xArray2[HUDMSG_REPEAT]--;
ArraySetArray(ArrayID, ItemID, xArray2);
// Get The Hudmsg SetTask Data Array so we can destroy it latter!
iTempArray = any:xArray2[HUDMSG_DATA_PARAMS_ARRAY];
}
ArrayDeleteItem(g_ArrayRepeatingData, x);
i = x;
z = ArraySize(g_ArrayRepeatingData);
while( i < z )
{
ArrayGetArray(g_ArrayRepeatingData, i, xArray2);
n = ArraySize(any:xArray2[HUDMSG_DATA_PARAMS_ARRAY]); // Getting the Hudmsg SetTask Array Index Size
for(f = 0; f < n; f++) // looping through the Array.
{
ArrayGetArray(any:xArray2[HUDMSG_DATA_PARAMS_ARRAY], f, aHUDMSG_DATA);
if(g_aHUDMSG_DATA[HUDMSG_DATA_ARRAY_ITEM] > x) // Checking if the g_ArrayRepeatingData Item id is bigger than the counter x
{
aHUDMSG_DATA[HUDMSG_DATA_ARRAY_ITEM]--; // decreasing item id by 1 grade.
ArraySetArray(any:xArray2[HUDMSG_DATA_PARAMS_ARRAY], f, aHUDMSG_DATA); // Save back to the Hudmsg SetTask Array.
}
}
Show when array is created and when task is created
Natsheh
07-22-2021 16:15
Re: Invalid array handler
its already shown in the code, the problem is some bad algorithm i am sure about it.
Bugsy
07-22-2021 16:43
Re: Invalid array handler
Did you try making 1 the minimum valid array handle, instead of 0?
Shadows Adi
07-22-2021 17:59
Re: Invalid array handler
Quote:
Originally Posted by Natsheh
(Post 2753399)
its already shown in the code, the problem is some bad algorithm i am sure about it.
I mean, when are called. The function name.
CrazY.
07-22-2021 19:54
Re: Invalid array handler
Invalid_Array is 0 not -1
Quote:
/**
* Cellarray tag declaration
*
* @note These dynamic arrays are intended to be used for a form of global
* storage without requiring a #define that needs to be increased each
* time the plugin author requires more storage. These are not designed
* to be a full replacement for normal arrays, as those are faster and
* should be used whenever possible.
* @note Plugins are responsible for freeing all Array handles they acquire,
* including those from ArrayClone. Failing to free handles will result
* in the plugin and AMXX leaking memory.
*/
enum Array
{
Invalid_Array = 0
};
Natsheh
07-23-2021 00:32
Re: Invalid array handler
So there is a problem caused of memory leak i am assuming some of the arrays are been created are not freed altho i am freeing them in remove_hudtask function which is called when an event occurred now the tasks and hudmsgs are removed but i am not sure if the arrays are freed.
I am going to do some debugging and I'll post the results the only problem is its hard to tell when the error occurs.
Quote:
Originally Posted by Shadows Adi
(Post 2753406)
I mean, when are called. The function name.
The function is called when an special event occurs.
Natsheh
07-23-2021 11:59
Re: ArrayCreate returns invalid array index
Fixed a small bug but the issue is now alot better.
PHP Code:
if(g_aHUDMSG_DATA
:arrow:
PHP Code:
if(aHUDMSG_DATA
Shadows Adi
07-23-2021 14:35
Re: ArrayCreate returns invalid array index
1. Make some debugging to make sure that you pass correct array handle ID.
3. I can't see the purpose of using "any:" everywhere, can you explain why are you using? You just get confused by using that.
Natsheh
07-23-2021 15:49
Re: ArrayCreate returns invalid array index
Quote:
Originally Posted by Shadows Adi
(Post 2753490)
1. Make some debugging to make sure that you pass correct array handle ID.
that not the case it returns an invalid array id because there's a memory leak some how, i am doing some debugs be right back with a solution pretty soon, so far i've tested it and every array been created it gets removed which is a good sign.
Quote:
Originally Posted by Shadows Adi
(Post 2753490)
3. I can't see the purpose of using "any:" everywhere, can you explain why are you using? You just get confused by using that.
to avoid compilation warnings, and its not that confusing tbh.