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

Level Req Quest Chest (rep +)

Chrippe

New Member
Joined
Jun 17, 2007
Messages
51
Reaction score
0
Hello!

I've been searching like a lunitic without any result, so I decided to make a new thread about it! Here we go:

What I need is a questchest with a level requirement to open it. Say for example a quest for level 50s to open which should give them 50 platinum coins.

If you manage to help me, I'll give you some rep++


Ps.
I don't need anyone to tell me that I could implent a door with a level requirement, because that's not what I'm out for!

Thanks in advance!
/Chrippe

Edit: I'm using The Forgotten Server 0.3.5 (Crying Damson)
 
Last edited:
Lua:
local config = {
	level = 50,
	storageValue = item.uniqueid,
	itemToAdd = 2152,
	amount = 50
}

function onUse(cid, item, fromPosition, itemEx, toPosition)

	if getPlayerStorageValue(cid, config.storagevalue) == -1 then
		if getPlayerLevel(cid) >= config.level then
			doPlayerAddItem(cid, config.itemToAdd, config.amount)
			doPlayerSetStorageValue(cid, config.storagevalue, 1)
		else
			doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "You need level ".. config.level .." to get this reward.")
		end
	else
		doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "You already completed this quest.")
	end
	return 1
end
 
Lua:
local config = {
	level = 50,
	storageValue = item.uniqueid,
	itemToAdd = 2152,
	amount = 50
}

function onUse(cid, item, fromPosition, itemEx, toPosition)

	if getPlayerStorageValue(cid, config.storagevalue) == -1 then
		if getPlayerLevel(cid) >= config.level then
			doPlayerAddItem(cid, config.itemToAdd, config.amount)
			doPlayerSetStorageValue(cid, config.storagevalue, 1)
		else
			doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "You need level ".. config.level .." to get this reward.")
		end
	else
		doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "You already completed this quest.")
	end
	return 1
end

I used your piece of code in a new .lua file and added it to actions.xml, tho it doesn't seem to work:

Lua:
[21/12/2009 22:36:22] Lua Script Error: [Action Interface] 
[21/12/2009 22:36:22] data/actions/scripts/quests/noobmoney.lua

[21/12/2009 22:36:22] data/actions/scripts/quests/noobmoney.lua:3: attempt to index global 'item' (a nil value)
[21/12/2009 22:36:22] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/quests/noobmoney.lua)

I could need some lua lessons, but till then, please help me solve the issue!

Thanks in advance,
Chrippe!
 
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local chest = {
		items = { {2152,50} },
		storage = 43415,
                level = 50
	}
	if getPlayerStorageValue(cid, chest.storage) == -1 then
		if getPlayerLevel(cid) >= chest.level then
			for i = 1, #chest.items do
				doPlayerAddItem(cid, chest.items[i][1], chest.items[i][2])
			end
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have recieved your prize!")
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_FIREWORKS)
                        setPlayerStorageValue(cid, chest.storage, 1)
		else
			doPlayerSendCancel(cid, "Your level is not high enough.")
		end
	else
		doPlayerSendCancel(cid, "The chest is empty.")
	end
	return true
end
 
Last edited:
Back
Top Bottom