Author Topic: Get ItemCl without using player's slots  (Read 2789 times)

Get ItemCl without using player's slots
« on: January 11, 2014, 04:06:29 am »
I can't get ItemCl by id. Here example, that should spam Deterioration of item in log, but item is not valid.

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

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

  • Guest
Re: Get ItemCl without using player's slots
« Reply #1 on: January 11, 2014, 08:30:49 am »
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

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.
« Last Edit: January 11, 2014, 08:42:03 am by b__B »

Re: Get ItemCl without using player's slots
« Reply #2 on: January 11, 2014, 11:36:59 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.
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

  • Guest
Re: Get ItemCl without using player's slots
« Reply #3 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.
« Last Edit: January 12, 2014, 10:08:28 am by b__B »

Re: Get ItemCl without using player's slots
« Reply #4 on: January 12, 2014, 09:57:07 pm »
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.
Oh, that's great, this is it! ;D Thank you!
And I was going to use unsafe_ scripts...