Raised This Month: $51 Target: $400
 12% 

Issue Store_GetItemDisplayName()


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Gecko
SourceMod Donor
Join Date: Nov 2010
Location: Vancouver, Canada
Old 09-18-2013 , 01:39   Store_GetItemDisplayName()
Reply With Quote #1

The Store_GetItemDisplayName() function sometimes throws this error:

Code:
L 09/18/2013 - 00:35:42: [SM] Plugin encountered error 15: Array index is out of bounds
L 09/18/2013 - 00:35:42: [SM] Displaying call stack trace for plugin "store/store-backend.smx":
L 09/18/2013 - 00:35:42: [SM]   [0]  Line 1620, store-backend.sp::Native_GetItemDisplayName()
L 09/18/2013 - 00:35:42: [SM] Plugin encountered error 15: Array index is out of bounds
L 09/18/2013 - 00:35:42: [SM] Native "Store_GetItemDisplayName" reported: Error encountered while processing a dynamic native
L 09/18/2013 - 00:35:42: [SM] Displaying call stack trace for plugin "storetest.smx":
L 09/18/2013 - 00:35:42: [SM]   [0]  Line 57, storetest.sp::GetItemsCallback()
The storetest plugin I built is just randomly pulling different item ids from the array returned by Store_GetItems(). This error occurs sometimes (about a 50/50) when I use Get_ItemDisplayName() inside of a GetItemsCallback. I tried performing Store_GetItems() using the store cache, and also not using it. Both ways seemed to cause this error.

I have no idea what it means, can anyone help??
__________________
"My brain is so left-sided, it isn't even funny... at all."

Last edited by Gecko; 09-18-2013 at 01:42.
Gecko is offline
alongub
Veteran Member
Join Date: Aug 2009
Location: Israel
Old 09-19-2013 , 17:40   Re: Store_GetItemDisplayName()
Reply With Quote #2

Can you paste your code?

And what version are you using?
__________________

Last edited by alongub; 09-19-2013 at 17:43.
alongub is offline
Gecko
SourceMod Donor
Join Date: Nov 2010
Location: Vancouver, Canada
Old 09-19-2013 , 20:43   Re: Store_GetItemDisplayName()
Reply With Quote #3

Quote:
Originally Posted by alongub View Post
Can you paste your code?

And what version are you using?
Using Store 1.1

Code:
//TestFunc gets all the items from the database with the only filter being that the items are
//buyable. It then passes it to the GetItemsCallback.

TestFunc(client)
{
    new Handle:pack = CreateDataPack();
    WritePackCell(pack, GetClientSerial(client));
    
    new Handle:filter = CreateTrie();
    SetTrieValue(filter, "is_buyable", 1);

    Store_GetItems(filter, GetItemsCallback, false, pack);
}

//The callback picks a random item from the returned array of ids, and gives it to the client
//retrieved from the serial.

public GetItemsCallback(ids[], count, any:pack)
{   
    ResetPack(pack);
    
    new serial = ReadPackCell(pack);
    
    CloseHandle(pack);
    
    new client = GetClientFromSerial(serial);
    
    if (client == 0)
        return;

    new id = Math_GetRandomInt(0, count);
    PrintToConsole(client, "Count: %i", count);
    PrintToConsole(client, "Item ID chosen: %i   (Index: %i)", ids[id], id);
    
    decl String:itemName[128];
    decl String:itemType[128];

    //Occasionally (about 50% of the time) it will get this far, and then throw the error posted in
    //the OP. There doesn't seem to be any rhyme or reason as to the items themselves, I
    //checked the ID's, and they vary anywhere inbetween 1 and 600. The names also don't
    //seem to have any cause in the error, the errors occur with all different types of names
    //(short ones, long ones, ones with/without spaces)

    Store_GetItemDisplayName(id, itemName, sizeof(itemName));
    Store_GetItemType(id, itemType, sizeof(itemType));
    
    PrintToConsole(client, "Name: %s", itemName);
    PrintToConsole(client, "Type: %s", itemType);
    
    new accountId = Store_GetClientAccountID(client);
    Store_GiveItem(accountId, id, Store_Unknown);
    
}
__________________
"My brain is so left-sided, it isn't even funny... at all."

Last edited by Gecko; 09-19-2013 at 20:43.
Gecko is offline
alongub
Veteran Member
Join Date: Aug 2009
Location: Israel
Old 09-20-2013 , 03:24   Re: Store_GetItemDisplayName()
Reply With Quote #4

In Store_GetItem* change id to ids[id], and it'll work.

The problem is that Store_GetItem* and Store_GiveItem accept one of the values of the ids array as the id parameter, and not just their index. I know it's confusing, but I couldn't find a better way to implement it with SourceMod's limited "enum classes".
__________________

Last edited by alongub; 09-20-2013 at 03:28.
alongub is offline
Gecko
SourceMod Donor
Join Date: Nov 2010
Location: Vancouver, Canada
Old 09-20-2013 , 04:14   Re: Store_GetItemDisplayName()
Reply With Quote #5

Ahhh okay, yeah no that makes sense. Awesome. Thanks for the help, and great plugin you've got here.
__________________
"My brain is so left-sided, it isn't even funny... at all."
Gecko 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 02:42.


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