Raised This Month: $ Target: $400
 0% 

Issue Store_GetItemDisplayName()


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 


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 14:28.


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