|
When is an item added to the local cache?
I write a mod that adds item its sees in channels to its own database.
Annoyingly it also adds items it sees in languages that are not the clients current default language. So I thought it would be cool to filter those out.
To do this, when I see an item not in my database, I get its item id from the link in the text and then call GetItemInfo. I use the returned values to check that the name of the item i see in the text is the same as the name returned by GetItemInfo. If it is, I add it to my database. If its not, I assume its an item in another language and ignore it.
The problem is, it seems to add items randomly. Sometimes GetItemInfo returns null, sometimes it does not. I know its supposed to return null if the item is not in your local cache, but I assumed seeing it in a channel message would add it to the local cache.
If the item in question is whispered to me, it always seems to work. If the item is in another channel it normally seems to fail, but does work sometimes. :)
function TypeLinks_OnEvent()
if (event == "CHAT_MSG_CHANNEL") then
TypeLinks_ScanTextForLinks(arg1);
end
end
I simply call my scanner method on all channel messages. What I guess I want to know is when the item is added to the cache and if I can ensure its added to the cache before my method fires?
Can anyone help?
|