• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Action 3 Chest reward in one chest!

Cornex

Web Developer
Staff member
Global Moderator
Joined
Jun 15, 2008
Messages
3,443
Solutions
6
Reaction score
1,170
Location
Sweden
Hello, this scripts works as all reward is in the same chest.
Etc, if you claim nr 1 reward on level 20, it say "You have claimed your reward, come back when you are level 50 for next reward"

(I want to bring an big thanks to summ also)

LUA:
local config = {
    {lvl = 20, rewards = {2160, 10}, storage = 5182},
    {lvl = 50, rewards = {2160, 25}, storage = 5183},
    {lvl = 100, rewards = {2160, 50}, storage = 5184},
}
 
function onUse(cid,item,fromPosition,itemEx,toPosition)
local level = getPlayerLevel(cid)
    for i = 1, #config do
	 if getPlayerStorageValue(cid, config[i].storage) < 1 then
            if level < config[i].lvl then
                 doPlayerSendCancel(cid, "You need to be level " .. config[i].lvl .. " to receive this reward.")
            else
                doPlayerAddItem(cid, config[i].rewards[1], config[i].rewards[2])
                doPlayerSetStorageValue(cid, config[i].storage, 1)
                if config[i + 1] then
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You have get the reward for level " .. config[i].lvl .. "! Come back when you are level " .. config[i + 1].lvl .. " to claim next reward! ")
                else
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You have get the reward for level " .. config[i].lvl .. "! This was the last reward..")
                end
                return true
            end
            break
        end
       
        if i == #config then
            doPlayerSendCancel(cid, "You already claimed all rewards.")
        end
end
   return true
end
 
Last edited:
well instead of using 3 different storages you could just use one storage and then higher it each time a player takes the reward, so you use fewer storages.

EDIT:
LUA:
local config =
{
	[uniqueid] =
	{
		storage = 5000,
		level =
		{
			{
				20, rewards = {2160, 10}
			},
			{
				50, rewards = {2160, 25}
			},
			{
				100, rewards = {2160, 50}
			}
		}
	}
	--[[[uniqueid] = example of another one.
	{
		storage = 5001,
		level =
		{
			{
				20, rewards = {2160, 10}
			},
			{
				50, rewards = {2160, 25}
			},
			{
				100, rewards = {2160, 50}
			}
		}
	}]]
}
		
 
function onUse(cid,item,fromPosition,itemEx,toPosition)
local rew = config[item.uid]
	if getPlayerStorageValue(cid, rew.storage) < #rew.level then
		for i = 1, #rew.level do
			if getPlayerStorageValue(cid, rew.storage) < i then
				if getPlayerLevel(cid) >= rew.level[i][1] then
					doPlayerAddItem(cid, rew.level[i].rewards[1], rew.level[i].rewards[2])
					setPlayerStorageValue(cid, rew.storage, i)
					if #rew.level == i then
						doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You have received the reward for level " .. rew.level[i][1] .. "! This was the last reward..")
					else
						doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You have received the reward for level " .. rew.level[i][1] .. "! Come back when you are level " .. rew.level[i+1][1] .. " to claim next reward! ")
					end
				else
					doPlayerSendCancel(cid, "You do not have the required level to take the reward.")
				end
				break
			end
		end
	else
		doPlayerSendCancel(cid, "You already claimed all rewards.")
	end
	return true
end

something like this, still needs some improvement but should do the job.
It also supports more then one quest chest in the script with seperated uniqueid's.
 
Last edited:
Back
Top