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

a special chest

Snow

New Member
Joined
Jan 16, 2008
Messages
381
Reaction score
0
A Special Chest!

What will happen?
player will open chest and he'll get items x,y and there's a chance (configurable) for him to get item z or get item a
player will be teleported after that
player will not get storage value, meaning he can open that chest as many times as he wants (that's why he'll be teleported)
player will get a message if he doesn't have cap or space for items

Something like the chests of abyssador, gnomevil and deathstrike

Thanks in advance!!
Much rep++
 
C'mon this is an easy script :) won't take a minute let me try

Lua:
-- Time Chest by Limos Edited by tetra
function onUse(cid, item, fromPosition, itemEx, toPosition)
local rewarditems = {
	{id = 2492, chance = 5, count = 1}, -- start with the lowest chances
	{id = 2498, chance = 10, count = 1},
	{id = 2488, chance = 15, count = 1},
	{id = 2152, chance = 70, count = math.random(1, 50)}
}
local pos = {x=,y=,z=}
	local chance = math.random(1,100)
	for i = 1, #rewarditems, 1 do
		if chance < rewarditems[i].chance then
			local info = getItemInfo(rewarditems[i].id)
			if rewarditems[i].count > 1 then	
				text = rewarditems[i].count .. " " .. info.plural
			else
                		text = info.article .. " " .. info.name
			end
 
			local item = doCreateItemEx(rewarditems[i].id, rewarditems[i].count)
			if(doPlayerAddItemEx(cid, item, false) ~= RETURNVALUE_NOERROR) then
				doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
				text = "You have found a reward. It is to heavy or you have not enough space."
			else
				text = "You have found " .. text .. "."
				doTeleportThing(cid, pos)
			end
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, text)
			return true
		else
			chance = chance - rewarditems[i].chance
		end
	end
end
 
It worked okay....but see this
I want those 4 items to ALWAYS BE LOOTED, the chance will only be weather you a necklace of the deep or jaul's pearl, the other items have 100% of coming.
Rep++ anyway, please add that :D
Lua:
-- Time Chest by Limos Edited by tetra
function onUse(cid, item, fromPosition, itemEx, toPosition)
local rewarditems = {
	{id = 15434, chance = 10, count = 1}, -- start with the lowest chances
	{id = 15403, chance = 90, count = 1},
	{id = 15454, chance = 100, count = 1},
	{id = 15621, chance = 100, count = 1},
	{id = 15453, chance = 100, count = 1},
	{id = 2152, chance = 100, count = 50}
}
local pos = {x= 33575,y= 31302,z= 11}
	local chance = math.random(1,100)
	for i = 1, #rewarditems, 1 do
		if chance < rewarditems[i].chance then
			local info = getItemInfo(rewarditems[i].id)
			if rewarditems[i].count > 1 then	
				text = rewarditems[i].count .. " " .. info.plural
			else
                		text = info.article .. " " .. info.name
			end
 
			local item = doCreateItemEx(rewarditems[i].id, rewarditems[i].count)
			if(doPlayerAddItemEx(cid, item, false) ~= RETURNVALUE_NOERROR) then
				doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
				text = "You have found a reward. It is to heavy or you have not enough space."
			else
				text = "You have found " .. text .. "."
				doTeleportThing(cid, pos)
			end
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, text)
			return true
		else
			chance = chance - rewarditems[i].chance
		end
	end
end
 
Code:
-- Time Chest by Limos Edited by tetra
function onUse(cid, item, fromPosition, itemEx, toPosition)
local rewarditems = {
	{id = 15434, chance = 10, count = 1}, -- start with the lowest chances
	{id = 15403, chance = 90, count = 1}
}
local pos = {x= 33575,y= 31302,z= 11}
local items = {2152,15453,15621,15454}
	local chance = math.random(1,100)
	for i = 1, #rewarditems, 1 do
		if chance < rewarditems[i].chance then
			local info = getItemInfo(rewarditems[i].id)
			if rewarditems[i].count > 1 then	
				text = rewarditems[i].count .. " " .. info.plural
			else
                		text = info.article .. " " .. info.name
			end
 
			local item = doCreateItemEx(rewarditems[i].id, rewarditems[i].count)
			if(doPlayerAddItemEx(cid, item, false) ~= RETURNVALUE_NOERROR) then
				doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
				text = "You have found a reward. It is to heavy or you have not enough space."
			else
				text = "You have found " .. text .. "."
				doTeleportThing(cid, pos)
                                doPlayerAddItem(cid, items, 1)
			end
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, text)
			return true
		else
			chance = chance - rewarditems[i].chance
		end
	end
end
 
Code:
-- Time Chest by Limos Edited by tetra
function onUse(cid, item, fromPosition, itemEx, toPosition)
local rewarditems = {
    {id = 15434, chance = 10, count = 1}, -- start with the lowest chances
    {id = 15403, chance = 90, count = 1}
}
local pos = {x= 33575,y= 31302,z= 11}
local items = {2152,15453,15621,15454}
    local chance = math.random(1,100)
    for i = 1, #rewarditems, 1 do
        if chance < rewarditems[i].chance then
            local info = getItemInfo(rewarditems[i].id)
            if rewarditems[i].count > 1 then    
                text = rewarditems[i].count .. " " .. info.plural
            else
                        text = info.article .. " " .. info.name
            end
 
            local item = doCreateItemEx(rewarditems[i].id, rewarditems[i].count)
            if(doPlayerAddItemEx(cid, item, false) ~= RETURNVALUE_NOERROR) then
                doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
                text = "You have found a reward. It is to heavy or you have not enough space."
            else
                text = "You have found " .. text .. "."
                doTeleportThing(cid, pos)
                                doPlayerAddItem(cid, items, 1)
            end
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, text)
            return true
        else
            chance = chance - rewarditems[i].chance
        end
    end
end

tetra is learning jajajaj
 
tetra is learning jajajaj
:)...edited some little things
Lua:
-- Time Chest by Limos Edited by tetra
function onUse(cid, item, fromPosition, itemEx, toPosition)
local rewarditems = {
	{id = 15434, chance = 10, count = 1}, -- start with the lowest chances
	{id = 15403, chance = 90, count = 1}
}
local pos = {x= 33575,y= 31302,z= 11}
local items = {15453,15621,15454}
	local chance = math.random(1,100)
	for i = 1, #rewarditems, 1 do
		if chance < rewarditems[i].chance then
			local info = getItemInfo(rewarditems[i].id)
			if rewarditems[i].count > 1 then	
				text = rewarditems[i].count .. " " .. info.plural
			else
                		text = info.article .. " " .. info.name
			end
 
			local item = doCreateItemEx(rewarditems[i].id, rewarditems[i].count)
			if(doPlayerAddItemEx(cid, item, false) ~= RETURNVALUE_NOERROR) then
				doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
				text = "You have found a reward. It is to heavy or you have not enough space."
			else
				text = "You have found " .. text .. "."
				doTeleportThing(cid, pos)
                               doPlayerAddItem(cid, items, 1)
                              doPlayerAddItem(cid, 2152, 50)
			end
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, text)
			return true
		else
			chance = chance - rewarditems[i].chance
		end
	end
end
 
Back
Top