Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local portalId, t = 1387,
- {
- ["demon"] = {
- message = "You killed a Demon!",
- config = {
- createPos = {x = 100, y = 100, z = 7},
- toPos = {x = 100, y = 100, z = 7},
- portalTime = 5, --minutes
- storage = 123
- }
- },
- ["orshabaal"] = {
- message = "You have defeated Orshabaal!",
- config = {
- createPos = {}, --NOTE: You may use empty brackets to create the portal where the monster dies.
- toPos = {x = 100, y = 100, z = 7},
- portalTime = 1, --minutes
- storage = 123
- }
- }
- }
- local function removePortal(position)
- local portal = Tile(position):getItemById(portalId)
- if portal then
- portal:remove()
- end
- end
- function onKill(creature, target)
- if not target:isMonster() or target:getMaster() then
- return true
- end
- local player = Player(cid)
- local k = t[target:getName():lower()]
- if not k then
- return true
- end
- local pos, cPos = target:getPosition()
- if type(k.config.createPos) == 'table' then
- if next(k.config.createPos) == nil then
- cPos = pos
- else
- cPos = k.config.createPos
- end
- end
- local item = Game.createItem(portalId, 1, cPos)
- if item:isTeleport() then
- item:setDestination(k.config.toPos)
- end
- for i, damage in pairs(target:getDamageMap()) do
- local p = Player(i)
- if p then
- if p.getStorageValue(k.config.storage) < 1 then
- p:setStorageValue(k.config.storage, 1)
- end
- end
- end
- local pt = k.config.portalTime
- player:sendTextMessage(MESSAGE_INFO_DESCR, k.message .. " You have " .. pt .. " " .. (pt > 1 and "minutes" or "minute") .. " to escape!")
- addEvent(removePortal, k.config.portalTime * 60 * 1000, cPos)
- return true
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement