FOnline Development > Questions and Answers

Get ItemCl without using player's slots

(1/1)

vaulttec:
I can't get ItemCl by id. Here example, that should spam Deterioration of item in log, but item is not valid.


--- Code: ---ItemCl@[] items;
CritterCl@ chosen= GetChosen();
chosen.GetItems( -1, items);
ItemCl@ item = GetItem(items[0].Id);
if(valid(item)) Message(" "+item.Deterioration);
--- End code ---

Generally I want to get items, that not in player's inventory - containers and npc inv. When I trade 'em or loot 'em, I can see all parametres, such as Deterioration, in item's description, which means, that client have access to them, but I have no idea how to get/use this values in client scripts.
Sorry for my language.

JovankaB:

--- Quote ---When I trade 'em or loot 'em, I can see all parametres, such as Deterioration, in item's description, which means, that client have access to them
--- End quote ---

If I remember correctly, that info is only sent by server when you trade NPC or loot
container, the item isn't in Chosen's inventory until it's actually moved there, so you
can't get it with chosen.GetItems and probably it's not even available with GetItem
if you knew the Id upfront and had the looting/trading window opened (but I'm not
100% sure, it might be worth trying, but I would be surprised if it worked).

For items in inventories and containers you will have to call a server function that
will get that data for client and send it back.

vaulttec:

--- Quote from: b__B on January 11, 2014, 08:30:49 am ---If I remember correctly, that info is only sent by server when you trade NPC or loot
container, the item isn't in Chosen's inventory until it's actually moved there, so you
can't get it with chosen.GetItems and probably it's not even available with GetItem
if you knew the Id upfront and had the looting/trading window opened (but I'm not
100% sure, it might be worth trying, but I would be surprised if it worked).

For items in inventories and containers you will have to call a server function that
will get that data for client and send it back.

--- End quote ---
Well, course I was going to use it only when barter/pickup screens is active.
The point is that I can't get item by Id even when it's in player's inventory and can be picked by chosen.GetItems

JovankaB:
I guess GetItem is for items on the map (seen by Chosen).

Maybe check out items_collection function in client_main.fos, it looks like something you need, although I never used it.

vaulttec:

--- Quote from: b__B on January 12, 2014, 09:39:58 am ---I guess GetItem is for items on the map (seen by Chosen).

Maybe check out items_collection function in client_main.fos, it looks like something you need, although I never used it.

--- End quote ---
Oh, that's great, this is it! ;D Thank you!
And I was going to use unsafe_ scripts...

Navigation

[0] Message Index

Go to full version