• 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!

Lua Its possible? Isnt request !

Vrotz

Member
Joined
Apr 7, 2011
Messages
1,071
Reaction score
7
Location
Brazil
Hello,

I've a doubt.

The player bought an item by the ShopSystem. Its possible configure the Shop system and/or Globalevents, for that the even withdraws the item after 30 days? If yes, as it does that?

They are able to teach me?
 
Last edited:
Ok, thanks!
So, some exists table or command that I can see how long of duration the item still has? (dont be of the Shop_history).. Or that the player click on to see item and appear, example: "20 days left" ?
 
You can make it with function "onLook" givin the description to the item but you'll see the days left when you look the item again, not at the first time.
You can also make that when you look the item, you get a message in console.
 
Lua:
function onLook(cid, thing, position, lookDistance)

	if isCreature(thing.uid) then return true end
	
	if getItemAttribute(thing.uid, "boughtdate") and getItemAttribute(thing.uid, "boughtdate") > 0 then
		local t = getItemAttribute(thing.uid, "boughtdate")
		local timeLeft =
		{
			secs = t,
			mins = math.floor(t / 60),
			hours = math.floor(t / (60 * 60)),
			days = math.floor(t / (60 * 60 * 24))
		}
		doItemSetAttribute(thing.uid, "description", "It has " .. (timeLeft.days > 0 and (timeLeft.days .. " days") or (timeLeft.hours .. " hours, " .. timeLeft.mins .. " minutes and " .. timeLeft.secs .. " seconds")) .. " left.")
		return true
	end
	return true
end

But you'll see the days left at the description when you look it again. (First look is to set the description to the item.)
Also, you can change this
Lua:
doItemSetAttribute(thing.uid, "description", "It has " .. (timeLeft.days > 0 and (timeLeft.days .. " days") or (timeLeft.hours .. " hours, " .. timeLeft.mins .. " minutes and " .. timeLeft.secs .. " seconds")) .. " left.")

To
Lua:
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "description", "It has " .. (timeLeft.days > 0 and (timeLeft.days .. " days") or (timeLeft.hours .. " hours, " .. timeLeft.mins .. " minutes and " .. timeLeft.secs .. " seconds")) .. " left.")

So you'll get the message with time left instantly.
 
Creaturescript.

Lua:
<event type="look" name="Duration" event="script" value="duration.lua"/>
 
If you would tell me which part you don't undestand I could help.
You just to add the linked function to lib file, add the login part in login.lua under function onLogin(..) and add the duration attribute where the item is created.
 
OMG!
I understood nothing.
Libs? I should add what? Please, what explain me better in detail I should do and as do!
 
Last edited:
Back
Top