.Smile
Member
- Joined
- Jan 27, 2019
- Messages
- 29
- Reaction score
- 11
Hello anyone could help me to solve the problem in this code?
It was to perform an action depending on the Storage that the player has but is not working
Apparently the problem is in these lines I do not know if I declared it right
It was to perform an action depending on the Storage that the player has but is not working
Lua:
function onStepIn(creature, item, position, fromPosition)
local config = {
--[[Islands]]] --
[47001] = {townid = 7, storageid = 47001, msg = "Welcome to the Fire Island", pos = {x=29997, y=28758, z=7}},
[47002] = {townid = 7, storageid = 47002, msg = "Welcome to the Water Island", pos = {x=29846, y=28645, z=7}},
}
local exhaustiontime = 2 -- Exhaustion Time
local exhaustionstorage = 40001 -- Exhaustion Storage
local position = creature:getPosition()
local player = creature:getPlayer()
local cfg = config[player:getStorageValue()]
if not creature:isPlayer() then
return false
end
if player:getExhaustion(exhaustionstorage) > 0 then
player:teleportTo(fromPosition, false)
return true
end
if cfg == 1 then
player:teleportTo(cfg.pos)
player:setTown(Town(cfg.townid))
player:sendTextMessage(MESSAGE_STATUS_DEFAULT, "".. cfg.msg ..".")
player:setStorageValue(cfg.storageid, -1)
player:setExhaustion(exhaustionstorage, exhaustiontime)
Position({x = position.x + 1, y = position.y + 1, z = position.z}):sendMagicEffect(21)
end
return true
end
Apparently the problem is in these lines I do not know if I declared it right
Lua:
local cfg = config[player:getStorageValue()]
if cfg == 1 then