• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Duration Items Script

Vrotz

Member
Joined
Apr 7, 2011
Messages
1,071
Reaction score
7
Location
Brazil
It would like to know I can be done someone give me/ or explain as do a script that deletes the item automatically after a determined time in-game.

Example:
The GOD performs the command /i 8924 (hellforged) and this item, upon to be created will have a duration of 30 days.

Thanks.
 
But I put a "duration" in the items and they alone disappear when the player is online with them. I want that they had a function similar to a Premium Account.

Programmer, put the fuction "duration", they just disappear
 
If it is a certtain item maybe you can add text to it as description or as text, then use a function onThink to evaluate if players online got that itemid, if they have it, compare text with os.time and if duration has ended, remove it.

If you want to do it with every item, just add an actionid to item so on function onThink you search for players with that actionid on an item.

Sorry for bad english, hope someone understands.
 
If it is a certtain item maybe you can add text to it as description or as text, then use a function onThink to evaluate if players online got that itemid, if they have it, compare text with os.time and if duration has ended, remove it.

If you want to do it with every item, just add an actionid to item so on function onThink you search for players with that actionid on an item.

Sorry for bad english, hope someone understands.


Good idea.
 
Add this where the item is added:
Lua:
doItemSetAttribute(item.uid, "duration", os.time() + 30 * 24 * 60 * 60)

in onLogin function add:
Lua:
local items = getAllItemsById(cid)
for i = 1, #items do
    local dur = getItemAttribute(items[i].uid, "duration")
    if dur and dur < os.time() then
        doRemoveItem(items[i].uid)
    end
end

with:
http://otland.net/f163/function-get-all-items-id-get-all-items-slot-id-171981/
 
Nope, "duration" = attribute xD The same as if you add it by items.xml

@Summ: And if he wants it to be a ring, but he wants it to dissappear if used the normal time (like 20 minutes) or if dont used in certain time (30 days) ? Your script will cause some troubles with that...
 
Back
Top