Jump to content
Faller

Items With Expiration

Recommended Posts

Hey! I'd like if anyone has any ideas on how to make items with expiration date?

I don't think there's any scripts for that, but if there is, I'd be really happy if you shared with me. :)

Any ideas on how I can do it? I'm thinking of using log files to store the item date, but am not sure how to delete the item in-game after the expiration date.. lol

Seems very complex for now.

I hope you can help me, thank you!

Share this post


Link to post
Share on other sites

You'll need unique identifiers for items if you're talking about having more than one of the same item that can expire since with logs it'll be kinda hard. Otherwise, if it's one item per inventory, then just apply a timer (with logs if you really want) and when it expires, make a check for that and then use "RemoveItem" function. 

  • Like 2

Share this post


Link to post
Share on other sites
 --while giving item do
    --Change the local variables values to what you want (like local hours = 5 means 5 hours.)
    local mins  = 25200 -- i've done for 1 week only
    mins = mins * 60
    local hours = 0
    hours = hours * 3600
    local days = 0
    days = days * 86400
    local ItemID = --put item id here!
    item = GetChaItem2 (  character , 2 , ItemID )
    SetItemAttr(item, ITEMATTR_URE, mins) -- i've set this for mins only you can change the variables values and place what you want here, if its days or hours or what ever.

-- place >>TimedItem(role)<< in cha_timer
function Timed_Item(role)

    local ItemID = --put item id here
    local Bag_Item = GetChaItem2 ( role , 2 , ItemID )
    local mins = GetItemAttr(Bag_Item,ITEMATTR_URE)
    if mins > 0 then
    SetItemAttr(Bag_Item,ITEMATTR_URE, -1)

    elseif mins == 5 then
    SystemNotice(role,"the item will dissappear in  seconds.")
    SetItemAttr(Bag_Item,ITEMATTR_URE, -1)

    elseif mins <= 0 then
    DelBagItem ( role , ItemID , 1)
    return
    end
end

 Credits; Don't Remember

Edited by Ximboliex
  • Like 1

xbx3.png

Share this post


Link to post
Share on other sites

@Ximboliex, that may probably work (I haven't tested it though) on common items, but an issue my arise when trying to apply it into items or equipment that use some stats for placeholders, such as: black dragon items (equipment and altar), medal of honor (I think it uses URE besides the strength and constitution attributes, not sure) and some others I can't remember at the moment.

 

This script can be applied as long as you don't try to add more placeholders within that item, at least that they don't interfere with URE probably MAXURE as well.

  • Like 2

Share this post


Link to post
Share on other sites
13 minutes ago, Totoka said:

Hey faller, and what about using something like this?

 

Screenshot_10.png

> Lineage 2: https://l2wiki.com/Items#Shadow_Items

 

~ Flag the item as non repairable, and when equipped just countdown its duration.

There was an item like that, can't remember the name, but it was a sword that could be obtained from treasure chest by using the hunter npc from ToP2. You obtained the sowrd with X durabilty, if you died, sword dropped and its location was brodcasted in system for others to grab it, if its durability went to zero, the sword was removed from your inventory.

  • Like 1

Share this post


Link to post
Share on other sites

Good evening friends, :morning1:

 

How can I use the function to make a sword disappear after 2 hours of the inventory of the player?

 

Note: Starting from when he receives it the sword. He can use the sword.

Share this post


Link to post
Share on other sites
5 hours ago, Faller said:

Hello @Ximboliex!

I just tested the script you have shared, and sadly it didn't seem to work. :/

If you strip the provided code, you will see that the code has semantic errors:

On 12/21/2016 at 10:39 PM, Ximboliex said:

    if mins > 0 then
        SetItemAttr(Bag_Item,ITEMATTR_URE, -1)
    elseif mins == 5 then
        SystemNotice(role,"the item will dissappear in  seconds.")
        SetItemAttr(Bag_Item,ITEMATTR_URE, -1)
    elseif mins <= 0 then
        DelBagItem ( role , ItemID , 1)
        return
    end

 

setting your item to -1 and then takes the item before you can use it.

On 12/21/2016 at 10:39 PM, Ximboliex said:

    local hours = 0
    hours = hours * 3600
    local days = 0
    days = days * 86400

 

Useless variables.

On 12/21/2016 at 10:39 PM, Ximboliex said:

    local days = 7
    days = days * 86400
    local ItemID = --put item id here!
    item = GetChaItem2 (  character , 2 , ItemID )
    SetItemAttr(item, ITEMATTR_URE, days)

 

At some point and if not careful, your ITEMATTR_URE value will exceed the maximum number it can store.
Just want to point that there are better functions that already exists. Try looking for

Evil Sword¡¤Soul Eating

On 12/25/2016 at 3:34 AM, Angelix said:

There was an item like that, can't remember the name, but it was a sword that could be obtained from treasure chest by using the hunter npc from ToP2. You obtained the sowrd with X durabilty, if you died, sword dropped and its location was brodcasted in system for others to grab it, if its durability went to zero, the sword was removed from your inventory.

 

  • Like 2

kong.png

a2.png

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...