• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Help with Annihilator

nawelter

New Member
Joined
May 29, 2009
Messages
6
Reaction score
0
I got annihilator working and everything, but when you flip the switch to be tele'd down, the switch stays in the same spot so you can't do it more than once everytime you restart. This is the code I have:

Code:
-- annihilator lever

local config = {
	monster = "Demon",
	positions = {
		{x=525, y=768, z=14}, {x=527, y=768, z=14}, {x=529, y=770, z=14},
		{x=530, y=770, z=14}, {x=528, y=772, z=14}, {x=526, y=772, z=14}
	}
}
function onUse(cid, item, frompos, item2, topos)
    local dzwignia = os.clock()
    if item.uid == 7000 and item.itemid == 1945 then
		local player1pos = {x=525, y=770, z=12, stackpos=253}
		local player1 = getThingfromPos(player1pos)
		local player2pos = {x=526, y=770, z=12, stackpos=253}
		local player2 = getThingfromPos(player2pos)
		local player3pos = {x=527, y=770, z=12, stackpos=253}
		local player3 = getThingfromPos(player3pos)
		local player4pos = {x=528, y=770, z=12, stackpos=253}
		local player4 = getThingfromPos(player4pos)
        if player1.itemid > 0 and player2.itemid > 0 and player3.itemid > 0 and player4.itemid > 0 then
            local queststatus1 = getPlayerStorageValue(player1.uid,7000)
            local queststatus2 = getPlayerStorageValue(player2.uid,7000)
            local queststatus3 = getPlayerStorageValue(player3.uid,7000)
            local queststatus4 = getPlayerStorageValue(player4.uid,7000)
            if queststatus1 == -1 and queststatus2 == -1 and queststatus3 == -1 and queststatus4 == -1 then
                local nplayer1pos = {x=525, y=770, z=14}
                local nplayer2pos = {x=526, y=770, z=14}
                local nplayer3pos = {x=527, y=770, z=14}
                local nplayer4pos = {x=528, y=770, z=14}
                doSendMagicEffect(player1pos,2)
                doSendMagicEffect(player2pos,2)
                doSendMagicEffect(player3pos,2)
                doSendMagicEffect(player4pos,2)
				for i = 1, table.maxn(config.positions) do
					doSummonCreature(config.monster, config.positions[i])
				end
                doTeleportThing(player1.uid,nplayer1pos)
                doTeleportThing(player2.uid,nplayer2pos)
                doTeleportThing(player3.uid,nplayer3pos)
                doTeleportThing(player4.uid,nplayer4pos)
                doSendMagicEffect(nplayer1pos,10)
                doSendMagicEffect(nplayer2pos,10)
                doSendMagicEffect(nplayer3pos,10)
                doSendMagicEffect(nplayer4pos,10)
                doTransformItem(item.uid,item.itemid+1)
            else
                doPlayerSendCancel(cid,"Alguem no seu time jah fez a quest.")
            end
        else
            doPlayerSendCancel(cid,"You need 4 players to do Annihilator.")
        end

    elseif item.uid ==7000 and item.itemid == 1945 then
        if (dzwignia - os.clock()) > 60 then
			doTransformItem(item.uid,item.itemid-1)
        end
        if getPlayerAccess(cid) > 0 then
            doTransformItem(item.uid,item.itemid-1)
            end
        end
    return TRUE
end
 
The TFS anni script is bad, since you can only do it once per server reset.

And instead of using os time, use
LUA:
addEvent(reset, 60*1000, item)

function reset(item)
   doTransformItem(item.uid, item.itemid-1)
end

This will reset it after 60 seconds.
 
thanks watkins. only thing is we have to add a line to make it only switch back only if switch is flipped :p do you know the code we need to enter to do that?
 
Code:
-- annihilator lever

local config = {
	monster = "Demon",
	positions = {
		{x=525, y=768, z=14}, {x=527, y=768, z=14}, {x=529, y=770, z=14},
		{x=530, y=770, z=14}, {x=528, y=772, z=14}, {x=526, y=772, z=14}
	}
}
function onUse(cid, item, frompos, item2, topos)
    local dzwignia = os.clock()
    if item.uid == 7000 and item.itemid == 1945 then
		local player1pos = {x=525, y=770, z=12, stackpos=253}
		local player1 = getThingfromPos(player1pos)
		local player2pos = {x=526, y=770, z=12, stackpos=253}
		local player2 = getThingfromPos(player2pos)
		local player3pos = {x=527, y=770, z=12, stackpos=253}
		local player3 = getThingfromPos(player3pos)
		local player4pos = {x=528, y=770, z=12, stackpos=253}
		local player4 = getThingfromPos(player4pos)
        if player1.itemid > 0 and player2.itemid > 0 and player3.itemid > 0 and player4.itemid > 0 then
            local queststatus1 = getPlayerStorageValue(player1.uid,7000)
            local queststatus2 = getPlayerStorageValue(player2.uid,7000)
            local queststatus3 = getPlayerStorageValue(player3.uid,7000)
            local queststatus4 = getPlayerStorageValue(player4.uid,7000)
            if queststatus1 == -1 and queststatus2 == -1 and queststatus3 == -1 and queststatus4 == -1 then
                local nplayer1pos = {x=525, y=770, z=14}
                local nplayer2pos = {x=526, y=770, z=14}
                local nplayer3pos = {x=527, y=770, z=14}
                local nplayer4pos = {x=528, y=770, z=14}
                doSendMagicEffect(player1pos,2)
                doSendMagicEffect(player2pos,2)
                doSendMagicEffect(player3pos,2)
                doSendMagicEffect(player4pos,2)
				for i = 1, table.maxn(config.positions) do
					doSummonCreature(config.monster, config.positions[i])
				end
                doTeleportThing(player1.uid,nplayer1pos)
                doTeleportThing(player2.uid,nplayer2pos)
                doTeleportThing(player3.uid,nplayer3pos)
                doTeleportThing(player4.uid,nplayer4pos)
                doSendMagicEffect(nplayer1pos,10)
                doSendMagicEffect(nplayer2pos,10)
                doSendMagicEffect(nplayer3pos,10)
                doSendMagicEffect(nplayer4pos,10)
                doTransformItem(item.uid,item.itemid+1)
            else
                doPlayerSendCancel(cid,"Alguem no seu time jah fez a quest.")
            end
        else
            doPlayerSendCancel(cid,"You need 4 players to do Annihilator.")
        end

    elseif item.uid ==7000 and item.itemid == 1945 then
        if (dzwignia - os.clock()) > 60 then
			doTransformItem(item.uid,item.itemid-1)
        end
        if getPlayerAccess(cid) > 0 then
            doTransformItem(item.uid,item.itemid-1)
            end
        end
    return TRUE
end

you have a mistake in your script check there

Code:
    elseif item.uid ==7000 and item.itemid == 1945 then
        if (dzwignia - os.clock()) > 60 then
			doTransformItem(item.uid,item.itemid-1)
        end
        if getPlayerAccess(cid) > 0 then
            doTransformItem(item.uid,item.itemid-1)
            end
        end
    return TRUE
end
again 1945? if you used 1945 the first time then it do 1+ it become 1946 so put there 1946 and then you acan use anni again.

so the script will look like this
Code:
-- annihilator lever

local config = {
	monster = "Demon",
	positions = {
		{x=525, y=768, z=14}, {x=527, y=768, z=14}, {x=529, y=770, z=14},
		{x=530, y=770, z=14}, {x=528, y=772, z=14}, {x=526, y=772, z=14}
	}
}
function onUse(cid, item, frompos, item2, topos)
    local dzwignia = os.clock()
    if item.uid == 7000 and item.itemid == 1945 then
		local player1pos = {x=525, y=770, z=12, stackpos=253}
		local player1 = getThingfromPos(player1pos)
		local player2pos = {x=526, y=770, z=12, stackpos=253}
		local player2 = getThingfromPos(player2pos)
		local player3pos = {x=527, y=770, z=12, stackpos=253}
		local player3 = getThingfromPos(player3pos)
		local player4pos = {x=528, y=770, z=12, stackpos=253}
		local player4 = getThingfromPos(player4pos)
        if player1.itemid > 0 and player2.itemid > 0 and player3.itemid > 0 and player4.itemid > 0 then
            local queststatus1 = getPlayerStorageValue(player1.uid,7000)
            local queststatus2 = getPlayerStorageValue(player2.uid,7000)
            local queststatus3 = getPlayerStorageValue(player3.uid,7000)
            local queststatus4 = getPlayerStorageValue(player4.uid,7000)
            if queststatus1 == -1 and queststatus2 == -1 and queststatus3 == -1 and queststatus4 == -1 then
                local nplayer1pos = {x=525, y=770, z=14}
                local nplayer2pos = {x=526, y=770, z=14}
                local nplayer3pos = {x=527, y=770, z=14}
                local nplayer4pos = {x=528, y=770, z=14}
                doSendMagicEffect(player1pos,2)
                doSendMagicEffect(player2pos,2)
                doSendMagicEffect(player3pos,2)
                doSendMagicEffect(player4pos,2)
				for i = 1, table.maxn(config.positions) do
					doSummonCreature(config.monster, config.positions[i])
				end
                doTeleportThing(player1.uid,nplayer1pos)
                doTeleportThing(player2.uid,nplayer2pos)
                doTeleportThing(player3.uid,nplayer3pos)
                doTeleportThing(player4.uid,nplayer4pos)
                doSendMagicEffect(nplayer1pos,10)
                doSendMagicEffect(nplayer2pos,10)
                doSendMagicEffect(nplayer3pos,10)
                doSendMagicEffect(nplayer4pos,10)
                doTransformItem(item.uid,item.itemid+1)
            else
                doPlayerSendCancel(cid,"Alguem no seu time jah fez a quest.")
            end
        else
            doPlayerSendCancel(cid,"You need 4 players to do Annihilator.")
        end

    elseif item.uid ==7000 and item.itemid == 1946 then
        if (dzwignia - os.clock()) > 60 then
			doTransformItem(item.uid,item.itemid-1)
        end
        if getPlayerAccess(cid) > 0 then
            doTransformItem(item.uid,item.itemid-1)
            end
        end
    return TRUE
end
 
Just use this one :thumbup:.
PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)

	-- Annihaltor by Maxi (Shawak) v1.0

	local room = {     -- room with demons
	fromX = 1100,
	fromY = 1192,
	fromZ = 10,
	toX = 1105,
	toY = 1196,
	toZ = 10
	}

	local monster_pos = {        
	[1] = {pos = {1100,1192,10}},
	[2] = {pos = {1102,1192,10}},
	[3] = {pos = {1101,1196,10}},
	[4] = {pos = {1103,1196,10}},
	[5] = {pos = {1104,1194,10}},
	[6] = {pos = {1105,1194,10}}
	}

	local players_pos = {
	{x = 1101,y = 1195,z = 7,stackpos = 253},
	{x = 1101,y = 1194,z = 7,stackpos = 253},
	{x = 1101,y = 1193,z = 7,stackpos = 253},
	{x = 1101,y = 1192,z = 7,stackpos = 253}
	}

	local new_player_pos = {
	{x = 1100, y = 1194, z = 10},
	{x = 1101, y = 1194, z = 10},
	{x = 1102, y = 1194, z = 10},
	{x = 1103, y = 1194, z = 10}
	}

	local monster = "Demon"
	local questLevel = 100


	-- don't touch ------------
	local player = {0, 0, 0, 0}
	local all_ready = 0
	---------------------------


	local player_in_room = getGlobalStorageValue(9000)
	local player1 = getThingfromPos(players_pos[1])
	local player2 = getThingfromPos(players_pos[2])
	local player3 = getThingfromPos(players_pos[3])
	local player4 = getThingfromPos(players_pos[4])

	if item.itemid == 1945 then
		if player1.itemid > 0 and player2.itemid > 0 and player3.itemid > 0 and player4.itemid > 0 then
			for i = 1, 4 do
				player[i] = getThingfromPos(players_pos[i])
				if player[i].itemid > 0 then
					all_ready = 1
				end
			end
		else	
		doPlayerSendTextMessage(cid,19,"You need 4 players to do this quest.")
		end
		if all_ready == 1 then
			for _, area in pairs(monster_pos) do
				doSummonCreature(monster,{x=area.pos[1],y=area.pos[2],z=area.pos[3]}) 
			end
			for i = 1, 4 do
				doSendMagicEffect(players_pos[i], CONST_ME_POFF)
				doTeleportThing(player[i].uid, new_player_pos[i], FALSE)
				doSendMagicEffect(new_player_pos[i], CONST_ME_ENERGYAREA)
				all_ready = 0
			end
			doTransformItem(item.uid,1946)
		end


	elseif item.itemid == 1946 then
		local player_room = 0
		for x = room.fromX, room.toX do
			for y = room.fromY, room.toY do
				for z = room.fromZ, room.toZ do
					local pos = {x=x, y=y, z=z,stackpos = 253}
					local thing = getThingfromPos(pos)
					if thing.itemid > 0 then 
						if isPlayer(thing.uid) == TRUE then
							player_room = player_room+1
						end
					end
				end
			end
		end
		if player_room >= 1 then
			doPlayerSendTextMessage(cid,19,"There is already a team in the quest room.")
						
		elseif player_room == 0 then
			for x = room.fromX, room.toX do
				for y = room.fromY, room.toY do
					for z = room.fromZ, room.toZ do
						local pos = {x=x, y=y, z=z,stackpos = 253}
						local thing = getThingfromPos(pos)
						if thing.itemid > 0 then 
							doRemoveCreature(thing.uid)
						end
					end
				end
			end
			player_room = 0
			doTransformItem(item.uid,1945)
		end
	end
	return TRUE
end

Regards,
Shawak
 
Back
Top