• 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 Paradox Chests + onStepIn

ond

Veteran OT User
Joined
Mar 24, 2008
Messages
2,775
Solutions
25
Reaction score
483
Location
Sweden
Hello, I wonder if someone got time to help me with an issue. I'm creating paradox quest and I have a problem with some scripting.

NOTE: The letters tells you which rewards you WON'T get. So, if you want 10k and 32 talons, walk over the two switch tiles E and W. This will remove Phoenix Egg and Wand of Cosmic Energy.

K = 10k gp
W = Wand of Cosmic Energy
T = 32 Talons
E = Phoenix Egg

WARNING: Walk over the items you don't want get!, so be careful. The light green words show what reward each chest gives.
Paradoxswitchs.jpg


Therefore, if you walk straight up the 2nd left, your rewards will be 100 Platinum Coins and 32 Talons (W and E removed).

Here is a link to how paradox quest works:
Tibia Wikia - Paradox Quest

Here is my scripts so far:

Actions::Chests
Lua:
function onUse(cid, item, item2, toPos, fromPos)

cash = getPlayerStorageValue(cid, 19795),
egg	 = getPlayerStorageValue(cid, 19796),
wand = getPlayerStorageValue(cid, 19797),
talon = getPlayerStorageValue(cid, 19798)

-- Remember, everything should reversed.
-- Walking on tile "cash" and "wand" should result in egg & talon as reward
-- And so on...

if item.uid == 2056 then
if wand == -1 or wand == 0 then
setPlayerStorageValue(cid, wand, 1)
doPlayerAddItem(cid, 2189, 1)
doPlayerSendTextMessage(cid,22,"You have found a wand of cosmic energy.")

else
doPlayerSendTextMessage(cid,22,"It is empty.")
end

elseif item.uid == 2057 then
if talon == -1 or talon == 0 then
setPlayerStorageValue(cid, talon, 1)
doPlayerAddItem(cid, 2151, 32)
doPlayerSendTextMessage(cid,22,"You have found 32 talons.")

else
doPlayerSendTextMessage(cid,22,"It is empty.")
end

elseif item.uid == 2058 then 
if cash == -1 or cash == 0 then
setPlayerStorageValue(cid, cash, 1)
doPlayerAddItem(cid, 2152, 1000)
doPlayerSendTextMessage(cid,22,"You have found 100 platinum coins.")

else
doPlayerSendTextMessage(cid,22,"It is empty.")
end

elseif item.uid == 2059 then 
if egg == -1 or egg == 0 then
setPlayerStorageValue(cid, egg, 1)
doPlayerAddItem(cid, 2328, 1)
doPlayerSendTextMessage(cid,22,"You have found a pheonix egg.")

else
doPlayerSendTextMessage(cid,22,"It is empty.")
end

else
return 0
end
return 1
end

and

Movements::Tiles
Lua:
function onStepIn(cid, item, pos)
 
	local phoenixegg = {x=32477, y=31900, z=1, stackpos=1}
	local gold = {x=32478, y=31900, z=1, stackpos=1}
	local talons = {x=32479, y=31900, z=1, stackpos=1}
	local wand = {x=32480, y=31900, z=1, stackpos=1}
 
	if item.actionid == 131 then --Phoenix Egg
		setPlayerStorageValue(cid,19795,1)
		doSendMagicEffect(phoenixegg,5)
	elseif item.actionid == 132 then --10k
		setPlayerStorageValue(cid,19796,1)
		doSendMagicEffect(gold,5)
	elseif item.actionid == 133 then --32 Talons
		setPlayerStorageValue(cid,19797,1)
		doSendMagicEffect(talons, 5)
	elseif item.actionid == 134 then --Wand Of Cosmic
		setPlayerStorageValue(cid,19798,1)
		doSendMagicEffect(wand, 5)
	end
	return TRUE
end
 
Last edited:
Its not that hard look:
1 Tile is each reward right?
So, use same storage per tile
Example: (Lets make it as we only have 2 tiles and 2 rewards)
Egg Tile = 9000
Phoenix Tile = 9001

Now, if you stand on the 2 tiles, you wont get any reward right? Just set the storage to 1(on stepIn), and when the chest checks if storage is lower than 1(or if its -1), then it wont work.

I stepped on Egg Tile
Lua:
function onStepIn(cid, item, pos)
if item.aid == 130 then
setPlayerStorageValue(cid, 9000, 1)

Now I try to open chest but I can't cuz my storage is higher than it should
Lua:
function onUse(cid, item)
if getPlayerStorageValue(cid, 9000) < 1 then
   doPlayerAddItem--- blablabla
else
---.its empty

Get me?
 
I get you, and i appriciate your help but it's a bit more confusing. First of all, you need to walk on two tiles to gain an item. And this two tiles has to be the opposite to this picture, sec I'm gonig to quote from tibia.wikia
 
Last edited:
Step on tile, get storage.

Lua:
local config = {
	[1000] = {1234, CONST_ME_MAGIC_BLUE}, -- STORAGE / EFFECT
	[1000] = {1234, CONST_ME_MAGIC_BLUE}, -- STORAGE / EFFECT
	[1000] = {1234, CONST_ME_MAGIC_BLUE}, -- STORAGE / EFFECT
	[1000] = {1234, CONST_ME_MAGIC_BLUE} -- STORAGE / EFFECT
}

function onStepIn(cid, item, position, fromPosition)
	local v = config[item.actionid]
	if v then
		if getCreatureStorage(cid, v[1]) < 0 then
			setPlayerStorageValue(cid, v[1], 1)
			doSendMagicEffect(getThingPos(cid), v[2])
		end
	end
end

Didn't think your chests were user friendly.

Lua:
local config = {
	savePlayer = true,
	chests = {
		[1000] = { -- CHEST ACTIONID
			storage = {1234, 5678} -- STORAGE TO OPEN/STORAGE COMPLETED
			id = {
				{2160, 1}
			}
		},
		[1000] = { -- CHEST ACTIONID
			storage = {1234, 5678} -- STORAGE TO OPEN/STORAGE COMPLETED
			id = {
				{2160, 1}
			}
		},
		[1000] = { -- CHEST ACTIONID
			storage = {1234, 5678} -- STORAGE TO OPEN/STORAGE COMPLETED
			id = {
				{2160, 1}
			}
		},
		[1000] = { -- CHEST ACTIONID
			storage = {1234, 5678} -- STORAGE TO OPEN/STORAGE COMPLETED
			id = {
				{2160, 1}
			}
		}
	}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	local v = config.chests[item.actionid]
	if v then
		for _, i in pairs(v.storage) do
			if getCreatureStorage(cid, v.storage[i][1]) > 0 then
				if getCreatureStorage(cid, v.storage[i][2]) < 0 then
					for x = 1, #v.id do
						local id = doCreateItemEx(v.id[x][1], v.id[x][2])
						if doPlayerAddItemEx(cid, id, true) ~= RETURNVALUE_NOERROR then
							return false
						end
						
						setPlayerStorageValue(cid, v.storage[i][2], 1)
						doSendMagicEffect(getThingPos(cid, CONST_ME_MAGIC_BLUE)
					end
				else
					doPlayerSendCancel(cid, "The chest is empty.")
				end
			else
				doPlayerSendCancel(cid, "Sorry, not possible.")
			end
		end
	end
	
	if config.savePlayer then
		doPlayerSave(cid, true)
		return true
	end
	
	return true
end
 
Last edited:
Don't get me wrong, I apriciate your help and all... but to link one storage to the actuall quest script isn't my request, it's to link two, and the ability to vary between the different storages

Example: if I want 10k and talons, I need to step the 2 tiles that not have the same LETTER as in the picture seen above (to eliminate those boxes that I walk on)
 
Thread solved, can be closed. (If you need this scripts, send me an PM because I don't have time to post all now, and later I will forget)
 
Back
Top Bottom