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