now it just doesn't give it to you hahaha
local config = {
needStorageKey = 77756, -- storage key required to open the chest?
needStorageValue = 1, -- storage value required to open the chest?
giveStorageKey = 50033, -- storage key given after chest opened?
giveStorageValue = 1, -- storage value given after chest opened?
itemId = 36266, -- give this item
itemCount = 1 -- give this amount
}
local a = Action()
function a.onUse(player, item, fromPosition, target, toPosition, isHotkey)
local p = player
if not p then
return false
end
local reward = ItemType(config.itemId)
if player:getStorageValue(config.giveStorageKey) ~= config.giveStorageValue then
if...
Hello, can you help me with a script of a chest or a coal basin by clicking on an item only if you have this storage 50033
local storageValue = 50033
function onUse(cid, item, fromPosition, itemEx, toPosition)
if getPlayerStorageValue(cid, storageValue) > 0 then
-- do something
end
return true
end
I want a chest that when you click it gives you an item if you have this Storage 50033, I use TFS 1.3 from OTBRIm not sure what you want to be done, and what tfs version you use.
Here is a example for tfs 0.x, to check if a player got storage 50033 set
Lua:local storageValue = 50033 function onUse(cid, item, fromPosition, itemEx, toPosition) if getPlayerStorageValue(cid, storageValue) > 0 then -- do something end return true end
This should do the trick, but the player would be able to spawn as many items he wants to.I want a chest that when you click it gives you an item if you have this Storage 50033, I use TFS 1.3 from OTBR
local storageValue = 50033
local newItemId = --ADD ITEMID HERE
function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey)
local player = Player(cid)
if player:getStorageValue(storageValue) > 0 then
player:addItem(newItemId)
end
return true
end
I want a chest that when you click it gives you an item if you have this Storage 50033, I use TFS 1.3 from OTBR
local storageValue = 50033
local reward = {2160, 10}
local a = Action()
function a.onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
if player:getStorageValue(storageValue) <= 0 then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You don\t have the storage.')
return true
end
player:addItem(reward[1], reward[2])
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have found an item.')
return true
end
a:id(CHEST_ID_HERE)
a:register()
local config = {
storageKey = 50033, -- storage key required to open the chest?
storageValue = 1, -- storage value required to open the chest?
itemId = 2160, -- give this item
itemCount = 5 -- give this amount
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local p = player
if not p then
return false
end
local reward = ItemType(config.itemId)
if p:getCapacity() > reward:getWeight(config.itemCount) then
if p:getStorageValue(config.storageKey) == config.storageValue then
p:addItem(config.itemId, config.itemCount)
p:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have received "..reward:getArticle().." "..reward:getName()..".")
p:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
else
return p:sendTextMessage(MESSAGE_STATUS_WARNING, "You don't have permission to open this.")
end
else
return p:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need at least "..reward:getWeight(config.itemCount).." cap to receive the reward from this chest.")
end
return true
end
I understand you, I'll explain you better
Need Storage: 77756
Chest: 36267
View attachment 57455
--------------------------------------------------
Reward: 36266
Reward Storage: 50033
View attachment 57456
Message: "You find a golden symbol at the bottom of the blood-filled basin."
local config = {
needStorageKey = 77756, -- storage key required to open the chest?
needStorageValue = 1, -- storage value required to open the chest?
giveStorageKey = 50033, -- storage key given after chest opened?
giveStorageValue = 1, -- storage value given after chest opened?
itemId = 36266, -- give this item
itemCount = 1 -- give this amount
}
local a = Action()
function a.onUse(player, item, fromPosition, target, toPosition, isHotkey)
local p = player
if not p then
return false
end
local reward = ItemType(config.itemId)
if p:getCapacity() > reward:getWeight(config.itemCount) then
if p:getStorageValue(config.needStorageKey) == config.needStorageValue then
p:addItem(config.itemId, config.itemCount)
p:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You find "..reward:getArticle().." "..reward:getName().." at the bottom of the blood-filled basin.")
p:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
p:setStorageValue(config.giveStorageKey, config.giveStorageValue)
else
return p:sendTextMessage(MESSAGE_STATUS_WARNING, "You don't have permission to open this.")
end
else
return p:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need at least "..reward:getWeight(config.itemCount).." capacity to open this chest.")
end
return true
end
a:id(36267) -- carefull this means all items with this id can be opened, no matter where they are (i would use action id instead for this)
a:register()
create file "basin.lua" on data/scripts/
and add this on the file:
Lua:local config = { needStorageKey = 77756, -- storage key required to open the chest? needStorageValue = 1, -- storage value required to open the chest? giveStorageKey = 50033, -- storage key given after chest opened? giveStorageValue = 1, -- storage value given after chest opened? itemId = 2160, -- give this item itemCount = 5 -- give this amount } local a = Action() function a.onUse(player, item, fromPosition, target, toPosition, isHotkey) local p = player if not p then return false end local reward = ItemType(config.itemId) if p:getCapacity() > reward:getWeight(config.itemCount) then if p:getStorageValue(config.needStorageKey) == config.needStorageValue then p:addItem(config.itemId, config.itemCount) p:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You find "..reward:getArticle().." "..reward:getName().." at the bottom of the blood-filled basin.") p:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW) p:setStorageValue(config.giveStorageKey, config.giveStorageValue) else return p:sendTextMessage(MESSAGE_STATUS_WARNING, "You don't have permission to open this.") end else return p:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need at least "..reward:getWeight(config.itemCount).." capacity to open this chest.") end return true end a:id(36267) -- carefull this means all items with this id can be opened, no matter where they are (i would use action id instead for this) a:register()
Note: the way you described your request means players can open this chest anywhere in the map if they have the storage and they can open as many times as they want xd
local config = {
needStorageKey = 77756, -- storage key required to open the chest?
needStorageValue = 1, -- storage value required to open the chest?
giveStorageKey = 50033, -- storage key given after chest opened?
giveStorageValue = 1, -- storage value given after chest opened?
itemId = 36266, -- give this item
itemCount = 1 -- give this amount
}
local a = Action()
function a.onUse(player, item, fromPosition, target, toPosition, isHotkey)
local p = player
if not p then
return false
end
local reward = ItemType(config.itemId)
if p:getCapacity() > reward:getWeight(config.itemCount) then
if p:getStorageValue(config.needStorageKey) == config.needStorageValue then
p:addItem(config.itemId, config.itemCount)
p:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You find "..reward:getArticle().." "..reward:getName().." at the bottom of the blood-filled basin.")
p:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
p:setStorageValue(config.giveStorageKey, config.giveStorageValue)
else
return p:sendTextMessage(MESSAGE_STATUS_WARNING, "You don't have permission to open this.")
end
else
return p:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need at least "..reward:getWeight(config.itemCount).." capacity to open this chest.")
end
return true
end
a:id(36267) -- carefull this means all items with this id can be opened, no matter where they are (i would use action id instead for this)
a:register()
This should fix it, he forgot to check if you had new storage setLua:local config = { needStorageKey = 77756, -- storage key required to open the chest? needStorageValue = 1, -- storage value required to open the chest? giveStorageKey = 50033, -- storage key given after chest opened? giveStorageValue = 1, -- storage value given after chest opened? itemId = 36266, -- give this item itemCount = 1 -- give this amount } local a = Action() function a.onUse(player, item, fromPosition, target, toPosition, isHotkey) local p = player if not p then return false end local reward = ItemType(config.itemId) if p:getCapacity() > reward:getWeight(config.itemCount) then if p:getStorageValue(config.needStorageKey) == config.needStorageValue then p:addItem(config.itemId, config.itemCount) p:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You find "..reward:getArticle().." "..reward:getName().." at the bottom of the blood-filled basin.") p:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW) p:setStorageValue(config.giveStorageKey, config.giveStorageValue) else return p:sendTextMessage(MESSAGE_STATUS_WARNING, "You don't have permission to open this.") end else return p:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need at least "..reward:getWeight(config.itemCount).." capacity to open this chest.") end return true end a:id(36267) -- carefull this means all items with this id can be opened, no matter where they are (i would use action id instead for this) a:register()
I put it like this, it works for me but I can use it many times
local config = {
needStorageKey = 77756, -- storage key required to open the chest?
needStorageValue = 1, -- storage value required to open the chest?
giveStorageKey = 50033, -- storage key given after chest opened?
giveStorageValue = 1, -- storage value given after chest opened?
itemId = 36266, -- give this item
itemCount = 1 -- give this amount
}
local a = Action()
function a.onUse(player, item, fromPosition, target, toPosition, isHotkey)
local p = player
if not p then
return false
end
local reward = ItemType(config.itemId)
if p:getCapacity() > reward:getWeight(config.itemCount) then
if p:getStorageValue(config.needStorageKey) == config.needStorageValue and p:getStorageValue(config.giveStorageKey) ~= config.giveStorageValue then
p:addItem(config.itemId, config.itemCount)
p:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You find "..reward:getArticle().." "..reward:getName().." at the bottom of the blood-filled basin.")
p:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
p:setStorageValue(config.giveStorageKey, config.giveStorageValue)
else
return p:sendTextMessage(MESSAGE_STATUS_WARNING, "You don't have permission to open this.")
end
else
return p:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need at least "..reward:getWeight(config.itemCount).." capacity to open this chest.")
end
return true
end
a:id(36267) -- carefull this means all items with this id can be opened, no matter where they are (i would use action id instead for this)
a:register()
I put it like this, it works for me but I can use it many times
local config = {
needStorageKey = 77756, -- storage key required to open the chest?
needStorageValue = 1, -- storage value required to open the chest?
giveStorageKey = 50033, -- storage key given after chest opened?
giveStorageValue = 1, -- storage value given after chest opened?
itemId = 36266, -- give this item
itemCount = 1 -- give this amount
}
local a = Action()
function a.onUse(player, item, fromPosition, target, toPosition, isHotkey)
local p = player
if not p then
return false
end
local reward = ItemType(config.itemId)
if player:getStorageValue(config.giveStorageKey) ~= config.giveStorageValue then
if p:getCapacity() > reward:getWeight(config.itemCount) then
if p:getStorageValue(config.needStorageKey) == config.needStorageValue then
p:addItem(config.itemId, config.itemCount)
p:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You find "..reward:getArticle().." "..reward:getName().." at the bottom of the blood-filled basin.")
p:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
p:setStorageValue(config.giveStorageKey, config.giveStorageValue)
else
return p:sendTextMessage(MESSAGE_STATUS_WARNING, "You don't have permission to open this.")
end
else
return p:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need at least "..reward:getWeight(config.itemCount).." capacity to open this chest.")
end
else
return p:sendTextMessage(MESSAGE_EVENT_ADVANCE, "The chest is emtpy.")
end
return true
end
a:id(36267) -- carefull this means all items with this id can be opened, no matter where they are (i would use action id instead for this)
a:register()
now it just doesn't give it to you hahahaYeah that's what I said in my last post... xD
Lua:local config = { needStorageKey = 77756, -- storage key required to open the chest? needStorageValue = 1, -- storage value required to open the chest? giveStorageKey = 50033, -- storage key given after chest opened? giveStorageValue = 1, -- storage value given after chest opened? itemId = 36266, -- give this item itemCount = 1 -- give this amount } local a = Action() function a.onUse(player, item, fromPosition, target, toPosition, isHotkey) local p = player if not p then return false end local reward = ItemType(config.itemId) if player:getStorageValue(config.giveStorageKey) == 0 then if p:getCapacity() > reward:getWeight(config.itemCount) then if p:getStorageValue(config.needStorageKey) == config.needStorageValue then p:addItem(config.itemId, config.itemCount) p:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You find "..reward:getArticle().." "..reward:getName().." at the bottom of the blood-filled basin.") p:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW) p:setStorageValue(config.giveStorageKey, config.giveStorageValue) else return p:sendTextMessage(MESSAGE_STATUS_WARNING, "You don't have permission to open this.") end else return p:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need at least "..reward:getWeight(config.itemCount).." capacity to open this chest.") end else return p:sendTextMessage(MESSAGE_EVENT_ADVANCE, "The chest is emtpy.") end return true end a:id(36267) -- carefull this means all items with this id can be opened, no matter where they are (i would use action id instead for this) a:register()
now it just doesn't give it to you hahaha
local config = {
needStorageKey = 77756, -- storage key required to open the chest?
needStorageValue = 1, -- storage value required to open the chest?
giveStorageKey = 50033, -- storage key given after chest opened?
giveStorageValue = 1, -- storage value given after chest opened?
itemId = 36266, -- give this item
itemCount = 1 -- give this amount
}
local a = Action()
function a.onUse(player, item, fromPosition, target, toPosition, isHotkey)
local p = player
if not p then
return false
end
local reward = ItemType(config.itemId)
if player:getStorageValue(config.giveStorageKey) ~= config.giveStorageValue then
if p:getCapacity() > reward:getWeight(config.itemCount) then
if p:getStorageValue(config.needStorageKey) == config.needStorageValue then
p:addItem(config.itemId, config.itemCount)
p:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You find "..reward:getArticle().." "..reward:getName().." at the bottom of the blood-filled basin.")
p:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
p:setStorageValue(config.giveStorageKey, config.giveStorageValue)
else
return p:sendTextMessage(MESSAGE_STATUS_WARNING, "You don't have permission to open this.")
end
else
return p:sendTextMessage(MESSAGE_STATUS_WARNING, "You need at least "..reward:getWeight(config.itemCount).." capacity to open this chest.")
end
else
return p:sendTextMessage(MESSAGE_EVENT_ADVANCE, "The chest is emtpy.")
end
return true
end
a:id(36267) -- carefull this means all items with this id can be opened, no matter where they are (i would use action id instead for this)
a:register()
local config = {
STORAGE_PERMISSION = 77756, -- storage key required to open the chest?
STORAGE_CHEST_OPENED = 50033, -- storage key given after chest opened?
itemId = 36266, -- give this item
itemCount = 1 -- give this amount
}
local a = Action()
function a.onUse(player, item, fromPosition, target, toPosition, isHotkey)
local reward = ItemType(config.itemId)
if player:getStorageValue(config.STORAGE_CHEST_OPENED) > 0 then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "The chest is emtpy.")
return true
end
if player:getCapacity() < reward:getWeight(config.itemCount) then
player:sendTextMessage(MESSAGE_STATUS_WARNING, "You need at least "..reward:getWeight(config.itemCount).." capacity to open this chest.")
return true
end
if player:getStorageValue(config.STORAGE_PERMISSION) <= 0 then
player:sendTextMessage(MESSAGE_STATUS_WARNING, "You don't have permission to open this.")
return true
end
player:addItem(config.itemId, config.itemCount)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You find "..reward:getArticle().." "..reward:getName().." at the bottom of the blood-filled basin.")
player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
player:setStorageValue(config.STORAGE_CHEST_OPENED, 1)
return true
end
a:id(36267)
a:register()
Improved readability
Lua:local config = { STORAGE_PERMISSION = 77756, -- storage key required to open the chest? STORAGE_CHEST_OPENED = 50033, -- storage key given after chest opened? itemId = 36266, -- give this item itemCount = 1 -- give this amount } local a = Action() function a.onUse(player, item, fromPosition, target, toPosition, isHotkey) local reward = ItemType(config.itemId) if player:getStorageValue(config.STORAGE_CHEST_OPENED) > 0 then player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "The chest is emtpy.") return true end if player:getCapacity() < reward:getWeight(config.itemCount) then player:sendTextMessage(MESSAGE_STATUS_WARNING, "You need at least "..reward:getWeight(config.itemCount).." capacity to open this chest.") return true end if player:getStorageValue(config.STORAGE_PERMISSION) <= 0 then player:sendTextMessage(MESSAGE_STATUS_WARNING, "You don't have permission to open this.") return true end player:addItem(config.itemId, config.itemCount) player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You find "..reward:getArticle().." "..reward:getName().." at the bottom of the blood-filled basin.") player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW) player:setStorageValue(config.STORAGE_CHEST_OPENED, 1) return true end a:id(36267) a:register()
local config = {
STORAGE_PERMISSION = 50039, -- storage key required to open the chest?
STORAGE_CHEST_OPENED = 50039, -- storage key given after chest opened?
itemId = 36282, -- give this item
itemCount = 1 -- give this amount
}
local a = Action()
function a.onUse(player, item, fromPosition, target, toPosition, isHotkey)
local reward = ItemType(config.itemId)
if player:getStorageValue(config.STORAGE_CHEST_OPENED) > 1 then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "The chest is emtpy.")
return true
end
if player:getCapacity() < reward:getWeight(config.itemCount) then
player:sendTextMessage(MESSAGE_STATUS_WARNING, "You need at least "..reward:getWeight(config.itemCount).." capacity to open this chest.")
return true
end
if player:getStorageValue(config.STORAGE_PERMISSION) <= 3 then
player:sendTextMessage(MESSAGE_STATUS_WARNING, "You don't have permission to open this.")
return true
end
player:addItem(config.itemId, config.itemCount)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You find "..reward:getArticle().." "..reward:getName().." at the bottom of the blood-filled basin.")
player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
player:setStorageValue(config.STORAGE_CHEST_OPENED, 1)
return true
end
a:id(36292)
a:register()
if you wanna use actionidLua:local config = { STORAGE_PERMISSION = 50039, -- storage key required to open the chest? STORAGE_CHEST_OPENED = 50039, -- storage key given after chest opened? itemId = 36282, -- give this item itemCount = 1 -- give this amount } local a = Action() function a.onUse(player, item, fromPosition, target, toPosition, isHotkey) local reward = ItemType(config.itemId) if player:getStorageValue(config.STORAGE_CHEST_OPENED) > 1 then player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "The chest is emtpy.") return true end if player:getCapacity() < reward:getWeight(config.itemCount) then player:sendTextMessage(MESSAGE_STATUS_WARNING, "You need at least "..reward:getWeight(config.itemCount).." capacity to open this chest.") return true end if player:getStorageValue(config.STORAGE_PERMISSION) <= 3 then player:sendTextMessage(MESSAGE_STATUS_WARNING, "You don't have permission to open this.") return true end player:addItem(config.itemId, config.itemCount) player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You find "..reward:getArticle().." "..reward:getName().." at the bottom of the blood-filled basin.") player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW) player:setStorageValue(config.STORAGE_CHEST_OPENED, 1) return true end a:id(36292) a:register()
it doesn't work for me with this bag
View attachment 57478
a:id(36292) -- use item id
a:aid(36292) -- use actionid
lol i didn't see thatif you wanna use actionid
replace
withLua:a:id(36292) -- use item id
Lua:a:aid(36292) -- use actionid
15:28 You don't have permission to open this.lol i didn't see that
Permissions should be given when value of 50039 is 3 ?15:28 You don't have permission to open this.
I have storage 50039, 1 and I want it from 50039, 3
if player:getStorageValue(config.STORAGE_PERMISSION) <= 3 then
<= 3
< 3