• 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 Level to open chest

Dankoo

Active Member
Joined
Sep 4, 2010
Messages
1,007
Reaction score
27
I'm trying to make an quest, in wich player need level X to open the chest, if he is lower level, receive an message

Someone knows where to find scripts like this? I'm trying here but no results so far

thanks :peace:
 
Just incase you still dont know lol. :p
LUA:
local msg = "You dont have the needed level"  -- cancel msg
local amount = 10000000   -- money in Gp
local lvl = 50   -- lvl min
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(getPlayerLevel(cid) < lvl) then
		doPlayerSendCancel(cid, msg)
	else
		doPlayerAddMoney(cid,amount)
	end
	return true
end
 
Last edited:
But, how do I set an storageid for it?

So the player can't take it everytime lol

thanks for the answer so far
 
Code:
local config = {
	rewards = {{2160, 100}, {2152, 50}},
	level = 50,
	messages = {
		'You have found something interessing inside this chest.',
		'Seems like you have already opened this chest.'
	},
	storage = 1337
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(getPlayerLevel(cid) < config.level) then
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You have to be at least '.. config.level ..' level to open this chest.')
		return true
	end

	if(getCreatureStorage(cid, config.storage) ~= EMPTY_STORAGE) then
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, config.messages[2])
		return true
	end

	for _, item in ipairs(config.rewards) do
		doPlayerAddItem(cid, item[1], item[2])
	end
	doCreatureSetStorage(cid, config.storage, 1)
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, config.messages[1])
	return true
end
 
I did not test yet, but I can't thank you enough already

Gotta go to school now, I'll test as soon as I get back

I believe support is a double way road, one day you help me, tomorrow, if you need anything, ask me and I'll do my best to help :]

thanks again, see u guys
 
Back
Top