• 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!

[Script] Help

tobias89

Pikaz Liek Pikaz
Joined
Apr 24, 2010
Messages
110
Reaction score
0
Need some help with a simple TP script.


PHP:
local seconds = 60
local monsterName = "Demon"
local monsterPos = {x=648, y=607, z=3}

local config = {
	level = 100,
	storage = 19044,
	entry = 
	{
		{x = 604, y = 607, z = 3},
		{x = 604, y = 608, z = 3},
		{x = 604, y = 609, z = 3}
	},
	destination =
	{
		{x = 643, y = 602, z = 3},
		{x = 653, y = 602, z = 3},
		{x = 648, y = 614, z = 3}
	}
}

function mapArea(fromPos, toPos, stack)
    -- Area iterator by Colandus @ OTFans.net
    local pos = {x=fromPos.x, y=fromPos.y-1, z=fromPos.z}
    return function()
        if (pos.y < toPos.y) then
            pos.y = pos.y+1
        elseif (pos.x <= toPos.x) then
            pos.y = fromPos.y
            pos.x = pos.x+1
        else
            pos.x = fromPos.x
            pos.y = fromPos.y
            pos.z = pos.z+1
        end
        if (pos.x <= toPos.x and pos.y <= toPos.y or pos.z < toPos.z) then
            if (stack == nil) then
                return pos
            else
                pos.stackpos = stack
                return pos, getThingfromPos(pos)
            end
        end
    end
end

function checkArea(cid)
	
	local fromPos = {x=641, y=600, z=3}
	local toPos = {x=655, y=614, z=3}
	local treasure = {x=143, y=82, z=9}
	local creature = getTopCreature(monsterPos).uid
	if (isCreature(creature) == true) then	
		for pos, thing in mapArea(fromPos, toPos, 253) do        
			if(isPlayer(thing.uid)) then 
				doCreatureAddMana(thing.uid, -getCreatureMana(thing.uid))
				doCreatureAddHealth(thing.uid, -getCreatureHealth(thing.uid))
			end    
		end
	else
		doTeleportThing(thing.uid, treasure) 
		doPlayerSendTextMessage(cid, 22, "You have killed " .. monsterName .. "!")
	end
	return true
end

function onUse(cid, item, frompos, item2, topos)
	if item.uid == 5000 then
		if item.itemid == 1945 then
 
			player1pos = {x=604, y=607, z=3, stackpos=253}
			player1 = getThingfromPos(player1pos)
 
			player2pos = {x=604, y=608, z=3, stackpos=253}
			player2 = getThingfromPos(player2pos)
 
			player3pos = {x=604, y=609, z=3, stackpos=253}
			player3 = getThingfromPos(player3pos)
 

			if player1.itemid > 0 and player2.itemid > 0 and player3.itemid > 0 then
 
				player1level = getPlayerLevel(player1.uid)
				player2level = getPlayerLevel(player2.uid)
				player3level = getPlayerLevel(player3.uid)
				 
				questlevel = 100
 
				if player1level >= questlevel and player2level >= questlevel and player3level >= questlevel  then
 
					queststatus1 = getPlayerStorageValue(player1.uid,7000)
					queststatus2 = getPlayerStorageValue(player2.uid,7000)
					queststatus3 = getPlayerStorageValue(player3.uid,7000)
					 
					if queststatus1 == -1 and queststatus2 == -1 and queststatus3 == -1 then
 
 						doSummonCreature("Demon", monsterPos)
 
						nplayer1pos = {x=652, y=603, z=3}
						nplayer2pos = {x=644, y=603, z=3}
						nplayer3pos = {x=648, y=614, z=3}
						 
						doSendMagicEffect(player1pos,2)
						doSendMagicEffect(player2pos,2)
						doSendMagicEffect(player3pos,2)
						 
						doTeleportThing(player1.uid,nplayer1pos)
						doTeleportThing(player2.uid,nplayer2pos)
						doTeleportThing(player3.uid,nplayer3pos)
						 
						doSendMagicEffect(nplayer1pos,10)
						doSendMagicEffect(nplayer2pos,10)
						doSendMagicEffect(nplayer3pos,10)
						 
						doTransformItem(item.uid,item.itemid+1)
						
						doPlayerSendTextMessage(player1.uid, 22, "Your team have exactly " .. seconds .. " to kill " .. monsterName .. " \nGood Luck !")
						doPlayerSendTextMessage(player2.uid, 22, "Your team have exactly " .. seconds .. " to kill " .. monsterName .. " \nGood Luck !")
						doPlayerSendTextMessage(player3.uid, 22, "Your team have exactly " .. seconds .. " to kill " .. monsterName .. " \nGood Luck !")

						addEvent(checkArea, seconds * 1000, cid)
 
					else
						doPlayerSendCancel(cid,"Sorry, not possible.")
					end
				else
					doPlayerSendCancel(cid,"Sorry, not possible.")
				end
			else
				doPlayerSendCancel(cid,"Sorry, not possible.")
			end
		elseif item.itemid == 1946 then
			if getPlayerAccess(cid) == 3 then
				doTransformItem(item.uid,item.itemid-1)
			else
				doPlayerSendCancel(cid,"Sorry, not possible.")
			end
		end
	end
	return 1
end
 
Lua:
function onUse(cid, item, frompos, item2, topos)
	npos = {x=frompos.x,  y=frompos.y,  z=frompos.z}
	if item.itemid == 1386 or item.itemid == 3678 then
		npos.y = npos.y + 1
		npos.z = npos.z - 1
		doTeleportThing(cid, npos)
	else
		npos.z = npos.z + 1
		doTeleportThing(cid, npos)
	end
	return 1
end
 
Code:
local entry = {
	{x = 604, y = 607, z = 3},
	{x = 604, y = 608, z = 3},
	{x = 604, y = 609, z = 3}
}
local dest = {
	{x = 643, y = 602, z = 3},
	{x = 653, y = 602, z = 3},
	{x = 648, y = 614, z = 3}
}

local function check(pos)
	local centerPosition = {x=652, y=603, z=3}
	for x = -centerPosition.x, centerPosition.x do
		for y = -centerPosition.y, centerPosition.y do
			local creature = getTopCreature({x = pos.x+x, y = pos.y+y, z = pos.z}).uid
			if isPlayer(creature) then
				doCreatureAddHealth(creature, -getCreatureMaxHealth(creature), false)
				doCreatureAddMana(creature, -getCreatureMaxMana(creature), false)
			end
			doRemoveCreature(creature)
		end
	end
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemid == 1945 then
		return doTransformItem(item.uid, 1946)
	end
	local list = {}
	for _, pos in ipairs(entry) do
		local creature = getTopCreature(pos).uid
		if isPlayer(creature) then
			table.insert(list, creature)
		end
	end
	if #list ~= 3 then
		return doPlayerSendTextMessage(cid, 27, "You need atleast 3 players to enter.")
	end
	for i, v in ipairs(list) do
		doSendMagicEffect(entry[i], CONST_ME_POFF)
		doTeleportThing(v, dest[i], true)
		doSendMagicEffect(dest[i], CONST_ME_TELEPORT)
	end
	doSummonCreature("Demon", {x=652, y=603, z=3})
	doTransformItem(item.uid, 1945)
	addEvent(check, 60 * 1000, getThingPos(cid))
	return true
end
 
Last edited:
Back
Top