local cfg = {
['rat'] = {tpDestination = Position(433, 504, 7), removeAfter = 30 * 1000}
}
local function remove(pos)
local item = Tile(pos):getItemById(1387)
if item then
item:remove()
end
end
function onKill(creature, target)
local tmp = cfg[target:getName():lower()]
if tmp and target:isMonster() then
local pos = target:getPosition()
local teleport = Game.createItem(1387, -1, pos)
Teleport(teleport.uid):setDestination(tmp.tpDestination)
addEvent(remove, tmp.removeAfter, pos)
end
return true
end
<event type="kill" name="bosstp" script="bosstp"/>
local bosses = {
['demon'] = 50000 ------------> storange can change it for which you do not occupy
}
function onKill(player, target)
local targetMonster = target:getMonster()
if not targetMonster then
return true
end
local targetName = targetMonster:getName():lower()
local bossStorage = bosses[targetName]
if not bossStorage then
return true
end
local function deleteTeleport(position)
local teleport = Tile(position):getItemById(1387)
if teleport then
teleport:remove()
end
end
local newValue = 2
Game.setStorageValue(bossStorage, newValue)
local item = Game.createItem(1387, 1,{x = 33548, y = 31623, z = 8}) ------> where will be created
if item:isTeleport() then
item:setDestination({x = 33495, y = 31583, z = 7}) ------> where will teleport you?
end
if newValue == 2 then
player:say('You now have 1 minute to exit this room through the teleporter.', TALKTYPE_MONSTER_SAY)
addEvent(deleteTeleport, 1 * 60 * 1000, {x = 33548, y = 31623, z = 8}) ------> where will remove
end
return true
end
player:registerEvent("bosstp")
he already found a solutionTry
creaturescript
Code:<event type="kill" name="bosstp" script="bosstp"/>
Lua:local bosses = { ['demon'] = 50000 ------------> storange can change it for which you do not occupy } function onKill(player, target) local targetMonster = target:getMonster() if not targetMonster then return true end local targetName = targetMonster:getName():lower() local bossStorage = bosses[targetName] if not bossStorage then return true end local function deleteTeleport(position) local teleport = Tile(position):getItemById(1387) if teleport then teleport:remove() end end local newValue = 2 Game.setStorageValue(bossStorage, newValue) local item = Game.createItem(1387, 1,{x = 33548, y = 31623, z = 8}) ------> where will be created if item:isTeleport() then item:setDestination({x = 33495, y = 31583, z = 7}) ------> where will teleport you? end if newValue == 2 then player:say('You now have 1 minute to exit this room through the teleporter.', TALKTYPE_MONSTER_SAY) addEvent(deleteTeleport, 1 * 60 * 1000, {x = 33548, y = 31623, z = 8}) ------> where will remove end return true end
login.lua
Code:player:registerEvent("bosstp")
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/onkill.lua:onKill
data/creaturescripts/scripts/onkill.lua:17: attempt to index a nil value
stack traceback:
[C]: in function '__index'
data/creaturescripts/scripts/onkill.lua:17: in function <data/creaturescripts/scripts/onkill.lua:12>
local cfg = {
['rat'] = {tpDestination = Position(32010, 32628, 7), removeAfter = 30 * 1000}
}
local function remove(pos)
local item = Tile(pos):getItemById(1949)
if item then
item:remove()
end
end
function onKill(creature, target)
local tmp = cfg[target:getName():lower()]
if tmp and target:isMonster() then
local pos = target:getPosition()
local teleport = Game.createItem(1949, -1, pos)
Teleport(teleport.uid):setDestination(tmp.tpDestination)
addEvent(remove, tmp.removeAfter, pos)
end
return true
end