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

chest give reward from lvl 100 then 200 etc

Hello,
So, first of all it's my first script :), so you need to try it first because there can be some bugs.. maybe other (well programmer) will look on this code and fix it if there are any bugs.
You need to crate ChestQuest.lua and copy this in :
Code:
{ --[[ 
Made by Shawak Edited by Maladiec
]] --
	
config = 
		
		items = { --     id,count
			item_1 = {2494,1},  -- Demon Armor 
			item_2 = {2400,1},  -- Magic Sword
			item_3 = {2431,1},  -- Stonecutter Axe
			item_4 = {2494,1},  -- Demon Armor 
			item_5 = {2400,1},  -- Magic Sword
			item_6 = {2431,1},  -- Stonecutter Axe
			item_7 = {2494,1},  -- Demon Armor 
			item_8 = {2400,1},  -- Magic Sword
			item_9 = {2431,1},  -- Stonecutter Axe
			item_10 = {2421,1}   -- Thunder Hammer
		},
level = {
			min=100, -- minimum level which can take reward
			change=100, -- change between levels atm 100 it means (0,100,200,300..)
			max=1000 -- Max level to reach (100,200,300..600,700,800,900,1000 will get rewards)
		}
		
	}


function onUse(cid, item, frompos, item2, topos)
local nowstorage = getPlayerStorageValue(cid, 17523)
needlevel = nowstorage * config.level.change + config.level.min -- DONT CHANGE
-- MSG CONFIG
msgempty="The chest is empty." -- Chest is empty.
msgnocap="Low cap." -- You have too low cap.
msgnoneededlevel = "Your level is too low to take the reward. Level "..needlevel.." is needed to get a reward." -- You have too low level to get reward.   
-- MSG CONFIGS END
if getPlayerLevel(cid) >= needlevel and getPlayerStorageValue(cid, 17523) < 10  then
pass=1
else 
pass=0
end

 if getPlayerStorageValue(cid, 17522) == 0 then
   		if item.uid == 17522 and getPlayerStorageValue(cid, 17523) == 0 then
			newItem = config.items.item_1[1]
			count = config.items.item_1[2]
   		elseif item.uid == 17522 and getPlayerStorageValue(cid, 17523) == 1 then
			newItem = config.items.item_2[1]
			count = config.items.item_2[2]
   		elseif item.uid == 17522 and getPlayerStorageValue(cid, 17523) == 2 then
			newItem = config.items.item_3[1]
			count = config.items.item_3[2]
			count = config.items.item_2[2]
		elseif item.uid == 17522 and getPlayerStorageValue(cid, 17523) == 3 then
			newItem = config.items.item_4[1]
			count = config.items.item_4[2]
		elseif item.uid == 17522 and getPlayerStorageValue(cid, 17523) == 4 then
			newItem = config.items.item_5[1]
			count = config.items.item_5[2]
		elseif item.uid == 17522 and getPlayerStorageValue(cid, 17523) == 5 then
			newItem = config.items.item_6[1]
			count = config.items.item_6[2]
		elseif item.uid == 17522 and getPlayerStorageValue(cid, 17523) == 6 then
			newItem = config.items.item_7[1]
			count = config.items.item_7[2]
		elseif item.uid == 17522 and getPlayerStorageValue(cid, 17523) == 7 then
			newItem = config.items.item_8[1]
			count = config.items.item_8[2]
		elseif item.uid == 17522 and getPlayerStorageValue(cid, 17523) == 8 then
			newItem = config.items.item_9[1]
			count = config.items.item_9[2]
		elseif item.uid == 17522 and getPlayerStorageValue(cid, 17523) == 9 then
			newItem = config.items.item_10[1]
			count = config.items.item_10[2]			
		elseif item.uid == 17522 and getPlayerStorageValue(cid, 17523) > 9 then
			doPlayerSendTextMessage(cid,21,msgempty)
	
		    
			

		end
-- MSG CONFIGS
msgitem = "You have found "..getItemArticleById(newItem).." "..getItemNameById(newItem).." level needed to take this reward is " ..needlevel.."." -- Change this if you know what are you doing.
-- msg config end

if getPlayerFreeCap(cid) >= getItemWeightById(newItem,count) and pass == 1  then
   			setPlayerStorageValue(cid, 17523,nowstorage+1)
   			doPlayerAddItem(cid,newItem,count)
   			doPlayerSendTextMessage(cid,21,msgitem)

		elseif item.uid == 17522 and getPlayerStorageValue(cid, 17523) <= 9 then
			doPlayerSendTextMessage(cid,21,msgnoneededlevel)
				
		elseif getPlayerFreeCap(cid) <= getItemWeightById(newItem,count) then
			doPlayerSendTextMessage(cid,21,msgnocap)
		
		end
		
		
   	end

    return true

end

To make it work in actions.xml you need to add this string
Code:
<action uniqueid="17522" script="ChestQuest.lua" />
And give that chest unique id 17522
WARNING! DO NOT TAKE 17523 STORAGE!
Let me know how it works.
Your's,
Maladiec
 
use this, just edit the items table and the storageValue nothing more.

LUA:
items = 
{
	[1] = {itemid, count},
	[2] = {itemid, count},
	[3] = {itemid, count},
	[4] = {itemid, count},
	[5] = {itemid, count},
	[6] = {itemid, count},
	[7] = {itemid, count},
	[8] = {itemid, count},
	[9] = {itemid, count},
	[10] = {itemid, count}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
local storageValue = 20000 -- only change this
local storage = 1 -- do not edit this one!
	if getPlayerStorageValue(cid, storageValue) == #items then
		doPlayerSendCancel(cid, "You already took the last reward of the chest.")
		return false
	end
	if getPlayerStorageValue(cid, storageValue) ~= -1 then
		storage = getPlayerStorageValue(cid, storageValue) + 1
	end
	if getPlayerLevel(cid) >= storage*100 then
		if doPlayerAddItem(cid, items[storage][1], items[storage][2]) then
			setPlayerStorageValue(cid, storageValue, storage)
			doPlayerSendTextMessage(cid, 21, "You have found ".. getItemInfo(items[storage][1]).article .." ".. getItemInfo(items[storage][1]).name ..".")
		else
			doPlayerSendCancel(cid, "You do not have enough space or cap to receive your reward.")
		end
	else
		doPlayerSendCancel(cid, "You do not have the required level to take the reward.")
	end
	return true
end


kind regards, Evil Hero.
 
Last edited:
use this, just edit the items table and the storageValue nothing more.

LUA:
items = 
{
	[1] = {itemid, count},
	[2] = {itemid, count},
	[3] = {itemid, count},
	[4] = {itemid, count},
	[5] = {itemid, count},
	[6] = {itemid, count},
	[7] = {itemid, count},
	[8] = {itemid, count},
	[9] = {itemid, count},
	[10] = {itemid, count}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
local storageValue = 20000 -- only change this
local storage = 1 -- do not edit this one!
	if getPlayerStorageValue(cid, storageValue) == #items then
		doPlayerSendCancel(cid, "You already took the last reward of the chest.")
		return false
	end
	if getPlayerStorageValue(cid, storageValue) ~= -1 then
		storage = getPlayerStorageValue(cid, storageValue) + 1
	end
	if getPlayerLevel(cid) >= storage*100 then
		if doPlayerAddItem(cid, items[storage].itemid, items[storage].count) then
			setPlayerStorageValue(cid, storageValue, storage)
			doPlayerSendTextMessage(cid, 21, "You have found ".. getItemInfo(items[storage].itemid).article .." ".. getItemInfo(items[storage].itemid).name ..".")
		else
			doPlayerSendCancel(cid, "You do not have enough space or cap to receive your reward.")
		end
	else
		doPlayerSendCancel(cid, "You do not have the required level to take the reward.")
	end
	return true
end


kind regards, Evil Hero.
Nice one, thanks for this, Goin to study all code ;P
 
Back
Top