• 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 Fix Annhi Lever!

Trader

New Member
Joined
Aug 12, 2009
Messages
219
Reaction score
2
Code:
-- Made by Third Aid

function monsterSpawns()
        local monsters = {"Giant Spider", "Hydra", "Gazer", "Demon Skeleton", "Dark Torturer", "Fury", "Merlkin", "Grim Reaper", "Zombie", "Witch", "Undead Gladiator", "Banshee", "Vampire Bride",
                                          "Dwarf Geomancer", "Kongra"}
                                         
        local monstersPos = {x=1571, y=1169, z=7} -- Where the monsters should be spawned
       
        local bombPos = {x=1565, y=1170, z=7, stackpos=2} -- Position of the bomb
        local getBomb = getThingFromPos(bombPos)
       
        local northWestX = 1559 -- North West X of the room with the bomb
        local northEastX = 1571 -- North East X of the room with the bomb
        local northWestY = 1167 -- North West Y of the room with the bomb
        local southWestY = 1173 -- South West Y of the room with the bomb
        local roomFloor = 7 -- Floor / Z of the room with the bomb
       
        if getGlobalStorageValue(17001) == 0 then
                doTransformItem(getBomb.uid, 9890)
        end
       
        setGlobalStorageValue(17001, getGlobalStorageValue(17001)+1)
        doSendAnimatedText(bombPos, "" .. 16-getGlobalStorageValue(17001) .. " min", TEXTCOLOR_YELLOW)
       
        if getGlobalStorageValue(17001) <= 15 then
                doSummonCreature(monsters[getGlobalStorageValue(17001)], monstersPos)
                doSummonCreature(monsters[getGlobalStorageValue(17001)], monstersPos)
                doSummonCreature(monsters[getGlobalStorageValue(17001)], monstersPos)
                addEvent(monsterSpawns, 60*1000)
        else
                setGlobalStorageValue(17000, 0)
                setGlobalStorageValue(17001, 0)
                doTransformItem(getBomb.uid, 9891)
                for x = northWestX, northEastX do
                        for y = northWestY, southWestY do
                        local explosionArea = {x=x, y=y, z=roomFloor, stackPos=253}
                        local getCreatures = getTopCreature(explosionArea).uid
                                doSendMagicEffect(explosionArea, CONST_ME_FIREATTACK)
                                if(isCreature(getCreatures) == TRUE) then
                                        doCreatureAddHealth(getCreatures, -getCreatureHealth(getCreatures))
                                end
                        end
                end
               
                for _, pid in ipairs(getPlayersOnline()) do
                        if getPlayerStorageValue(pid, 17000) == 1 then
                                setPlayerStorageValue(pid, 17000, 0)
                                doCreatureAddHealth(pid, -getCreatureHealth(pid))
                                setGlobalStorageValue(17000, 0)
                        end
                end
        end
return true
end
       
       
function onUse(cid, item, fromPosition, itemEx, toPosition)
        local playerPos1 = {x=1518, y=1141, z=7, stackpos=STACKPOS_TOP_CREATURE} -- The tiles they should stand on when pulling the switch
        local playerPos2 = {x=1517, y=1141, z=7, stackpos=STACKPOS_TOP_CREATURE}
        local playerPos3 = {x=1516, y=1141, z=7, stackpos=STACKPOS_TOP_CREATURE}
        local playerPos4 = {x=1515, y=1141, z=7, stackpos=STACKPOS_TOP_CREATURE}
       
        local getPlayerPos1 = getThingFromPos(playerPos1)
        local getPlayerPos2 = getThingFromPos(playerPos2)
        local getPlayerPos3 = getThingFromPos(playerPos3)
        local getPlayerPos4 = getThingFromPos(playerPos4)
       
        local newPlayerPos1 = {x=1567, y=1169, z=7} -- Where they get teleported in the room with the bomb
        local newPlayerPos2 = {x=1563, y=1169, z=7}
        local newPlayerPos3 = {x=1567, y=1171, z=7}
        local newPlayerPos4 = {x=1563, y=1171, z=7}
       
        local wallName = "Brick Wall" -- Name of the "Wall monster"
        local wallPos = {x=1572, y=1170, z=7} -- Where the wall should be
       
       
                if getPlayerPos1.itemid > 0 and getPlayerPos2.itemid > 0 and getPlayerPos3.itemid > 0 and getPlayerPos4.itemid > 0 then
                        if getGlobalStorageValue(17000) <= 0 then
                                setPlayerStorageValue(getPlayerPos1.uid, 17000, 1)
                                setPlayerStorageValue(getPlayerPos2.uid, 17000, 1)
                                setPlayerStorageValue(getPlayerPos3.uid, 17000, 1)
                                setPlayerStorageValue(getPlayerPos4.uid, 17000, 1)
                                doTeleportThing(getPlayerPos1.uid, newPlayerPos1)
                                doTeleportThing(getPlayerPos2.uid, newPlayerPos2)
                                doTeleportThing(getPlayerPos3.uid, newPlayerPos3)
                                doTeleportThing(getPlayerPos4.uid, newPlayerPos4)
                                doSendMagicEffect(newPlayerPos1, CONST_ME_TELEPORT)
                                doSendMagicEffect(newPlayerPos2, CONST_ME_TELEPORT)
                                doSendMagicEffect(newPlayerPos3, CONST_ME_TELEPORT)
                                doSendMagicEffect(newPlayerPos4, CONST_ME_TELEPORT)
                                doSendMagicEffect(playerPos1, CONST_ME_POFF)
                                doSendMagicEffect(playerPos2, CONST_ME_POFF)
                                doSendMagicEffect(playerPos3, CONST_ME_POFF)
                                doSendMagicEffect(playerPos4, CONST_ME_POFF)
                                setGlobalStorageValue(17000, 1)
                                setGlobalStorageValue(17001, 0)
                                doSummonCreature(wallName, wallPos)
                                addEvent(doSendAnimatedText, 30*1000, {x=1565, y=1170, z=7}, "ACTIVATED", TEXTCOLOR_GREEN)
                                addEvent(monsterSpawns, 30*1000)
                                for _, pid in ipairs(getPlayersOnline()) do
                                        if getPlayerStorageValue(pid, 17000) == 1 then
                                                doPlayerSendTextMessage(pid, 22, "The bomb will start ticking in 30 seconds, you have 5 minutes to destroy the wall and get out of the room before it explodes! Three monsters will spawn every minute!")
                                        end
                                end
                        else
                                doPlayerSendTextMessage(cid, 22, "Some people are already in there, wait until they're done.")
                        end
                else
                        doPlayerSendCancel(cid, "Sorry, not possible.")
                end
        return true
end

Help please, How do I make it so that you can pull the lever every 15 minutes?

I will add rep+!
 
PHP:
function monsterSpawns()
        local monsters = {"Giant Spider", "Hydra", "Gazer", "Demon Skeleton", "Dark Torturer", "Fury", "Merlkin", "Grim Reaper", "Zombie", "Witch", "Undead Gladiator", "Banshee", "Vampire Bride",
                                          "Dwarf Geomancer", "Kongra"}
                                         
        local monstersPos = {x=1571, y=1169, z=7} -- Where the monsters should be spawned
       
        local bombPos = {x=1565, y=1170, z=7, stackpos=2} -- Position of the bomb
        local getBomb = getThingFromPos(bombPos)
       
        local northWestX = 1559 -- North West X of the room with the bomb
        local northEastX = 1571 -- North East X of the room with the bomb
        local northWestY = 1167 -- North West Y of the room with the bomb
        local southWestY = 1173 -- South West Y of the room with the bomb
        local roomFloor = 7 -- Floor / Z of the room with the bomb
       
        if getGlobalStorageValue(17001) == 0 then
                doTransformItem(getBomb.uid, 9890)
        end
       
        setGlobalStorageValue(17001, getGlobalStorageValue(17001)+1)
        doSendAnimatedText(bombPos, "" .. 16-getGlobalStorageValue(17001) .. " min", TEXTCOLOR_YELLOW)
       
        if getGlobalStorageValue(17001) <= 15 then
                doSummonCreature(monsters[getGlobalStorageValue(17001)], monstersPos)
                doSummonCreature(monsters[getGlobalStorageValue(17001)], monstersPos)
                doSummonCreature(monsters[getGlobalStorageValue(17001)], monstersPos)
                addEvent(monsterSpawns, 60*1000)
        else
                setGlobalStorageValue(17000, 0)
                setGlobalStorageValue(17001, 0)
                doTransformItem(getBomb.uid, 9891)
                for x = northWestX, northEastX do
                        for y = northWestY, southWestY do
                        local explosionArea = {x=x, y=y, z=roomFloor, stackPos=253}
                        local getCreatures = getTopCreature(explosionArea).uid
                                doSendMagicEffect(explosionArea, CONST_ME_FIREATTACK)
                                if(isCreature(getCreatures) == TRUE) then
                                        doCreatureAddHealth(getCreatures, -getCreatureHealth(getCreatures))
                                end
                        end
                end
               
                for _, pid in ipairs(getPlayersOnline()) do
                        if getPlayerStorageValue(pid, 17000) == 1 then
                                setPlayerStorageValue(pid, 17000, 0)
                                doCreatureAddHealth(pid, -getCreatureHealth(pid))
                                setGlobalStorageValue(17000, 0)
                        end
                end
        end
return true
end
       
       
function onUse(cid, item, fromPosition, itemEx, toPosition)
        local playerPos1 = {x=1518, y=1141, z=7, stackpos=STACKPOS_TOP_CREATURE} -- The tiles they should stand on when pulling the switch
        local playerPos2 = {x=1517, y=1141, z=7, stackpos=STACKPOS_TOP_CREATURE}
        local playerPos3 = {x=1516, y=1141, z=7, stackpos=STACKPOS_TOP_CREATURE}
        local playerPos4 = {x=1515, y=1141, z=7, stackpos=STACKPOS_TOP_CREATURE}
       
        local getPlayerPos1 = getThingFromPos(playerPos1)
        local getPlayerPos2 = getThingFromPos(playerPos2)
        local getPlayerPos3 = getThingFromPos(playerPos3)
        local getPlayerPos4 = getThingFromPos(playerPos4)
       
        local newPlayerPos1 = {x=1567, y=1169, z=7} -- Where they get teleported in the room with the bomb
        local newPlayerPos2 = {x=1563, y=1169, z=7}
        local newPlayerPos3 = {x=1567, y=1171, z=7}
        local newPlayerPos4 = {x=1563, y=1171, z=7}
       
        local wallName = "Brick Wall" -- Name of the "Wall monster"
        local wallPos = {x=1572, y=1170, z=7} -- Where the wall should be
       
       
                if getPlayerPos1.itemid > 0 and getPlayerPos2.itemid > 0 and getPlayerPos3.itemid > 0 and getPlayerPos4.itemid > 0 then
                        if getGlobalStorageValue(17000) <= 0 then
                                setPlayerStorageValue(getPlayerPos1.uid, 17000, 1)
                                setPlayerStorageValue(getPlayerPos2.uid, 17000, 1)
                                setPlayerStorageValue(getPlayerPos3.uid, 17000, 1)
                                setPlayerStorageValue(getPlayerPos4.uid, 17000, 1)
                                doTeleportThing(getPlayerPos1.uid, newPlayerPos1)
                                doTeleportThing(getPlayerPos2.uid, newPlayerPos2)
                                doTeleportThing(getPlayerPos3.uid, newPlayerPos3)
                                doTeleportThing(getPlayerPos4.uid, newPlayerPos4)
                                doSendMagicEffect(newPlayerPos1, CONST_ME_TELEPORT)
                                doSendMagicEffect(newPlayerPos2, CONST_ME_TELEPORT)
                                doSendMagicEffect(newPlayerPos3, CONST_ME_TELEPORT)
                                doSendMagicEffect(newPlayerPos4, CONST_ME_TELEPORT)
                                doSendMagicEffect(playerPos1, CONST_ME_POFF)
                                doSendMagicEffect(playerPos2, CONST_ME_POFF)
                                doSendMagicEffect(playerPos3, CONST_ME_POFF)
                                doSendMagicEffect(playerPos4, CONST_ME_POFF)
                                setGlobalStorageValue(17000, 1)
                                setGlobalStorageValue(17001, 0)
                                doSummonCreature(wallName, wallPos)
                                addEvent(doSendAnimatedText, 30*1000, {x=1565, y=1170, z=7}, "ACTIVATED", TEXTCOLOR_GREEN)
                                addEvent(monsterSpawns, 150*1000)
                                for _, pid in ipairs(getPlayersOnline()) do
                                        if getPlayerStorageValue(pid, 17000) == 1 then
                                                doPlayerSendTextMessage(pid, 22, "The bomb will start ticking in 30 seconds, you have 5 minutes to destroy the wall and get out of the room before it explodes! Three monsters will spawn every minute!")
                                        end
                                end
                        else
                                doPlayerSendTextMessage(cid, 22, "Some people are already in there, wait until they're done.")
                        end
                else
                        doPlayerSendCancel(cid, "Sorry, not possible.")
                end
        return true
end

try this
 
This script works, I tested it myself. Just change the coordinates, etc.
PHP:
local config = {
	daily = "no", -- allow only one enter per day? (like in global Tibia)
	level = 100,
	storage = 30015,
	entry =
	{
		{x = 789, y = 335, z = 9},
		{x = 773, y = 352, z = 9},
		{x = 771, y = 358, z = 9},
		{x = 787, y = 362, z = 9}
	},
	destination =
	{
		{x = 737, y = 362, z = 9},
		{x = 736, y = 362, z = 9},
		{x = 735, y = 362, z = 9},
		{x = 734, y = 362, z = 9}
	}
}

config.daily = getBooleanFromString(config.daily)
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(item.itemid == 1946) then
		if(config.daily) then
			doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
		else
			doTransformItem(item.uid, item.itemid - 1)
		end

		return true
	end

	if(item.itemid ~= 1945) then
		return true
	end

	local players = {}
	for _, position in ipairs(config.entry) do
		local pid = getTopCreature(position).uid
		if(pid == 0 or not isPlayer(pid) or getCreatureStorage(pid, config.storage) > 0 or getPlayerLevel(pid) < config.level) then
			doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
			return true
		end

		table.insert(players, pid)
	end

	for i, pid in ipairs(players) do
		doSendMagicEffect(config.entry[i], CONST_ME_POFF)
		doTeleportThing(pid, config.destination[i], false)
		doSendMagicEffect(config.destination[i], CONST_ME_ENERGYAREA)
	end

	doTransformItem(item.uid, item.itemid + 1)
	return true
end
 
Back
Top