Ir para conteúdo

Alguem Me Ajuda Nessa Script?


fmiguel

Posts Recomendados

Estou precisando de ajuda nessa script que teleporta players de uma posição para outra

ai está:

 

 

local arenas = {

[7667] = {

fromPos ={

{x = 1005, y = 995, z = 10}, --player 1 start pos

{x = 1006, y = 995, z = 10} --player 2 start pos

},

toPos = {

{x = 1008, y = 995, z = 10}, --player 1 teleport position

{x = 1009, y = 995, z = 10} --player 2 teleport position

}

}

}

 

function onUse(cid, item, fromPosition, itemEx, toPosition)

if(item.itemid == 1946) then

doTransformItem(item.uid, 1945)

return TRUE

end

 

local arena = arenas[item.uid]

if(not arena) then

return FALSE

end

 

local players = {}

for _, pos in pairs(arena.fromPos) do

pos.stackpos = STACKPOS_TOP_CREATURE

local tmp = getThingfromPos(pos).uid

if(tmp > 0 and isCreature(tmp) == TRUE) then

table.insert(players, tmp)

end

end

 

if(table.maxn(players) < table.maxn(arena.fromPos)) then

doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need more creatures for duel.")

return TRUE

end

 

for i, pid in pairs(players) do

doSendMagicEffect(arena.fromPos, CONST_ME_POFF)

doTeleportThing(pid, arena.toPos)

doSendMagicEffect(arena.toPos, CONST_ME_TELEPORT)

doPlayerSendTextMessage(pid, MESSAGE_INFO_DESCR, "FIGHT!")

end

 

return TRUE

end

 

Essa script está funcionando perfeitamente, 2 players são transportados assim que a alavanca de UID 7667 é usada...

O problema agora é que se eu adicionar mais players na script ela deixa de funfar não sei a razão:

 

local arenas = {

[7667] = {

fromPos ={

{x = 1005, y = 995, z = 10}, --player 1 start pos

{x = 1006, y = 995, z = 10} --player 2 start pos

{x = 1007, y = 995, z = 10} --player 3 start pos

},

toPos = {

{x = 1008, y = 995, z = 10}, --player 1 teleport position

{x = 1009, y = 995, z = 10} --player 2 teleport position

{x = 1010, y = 995, z = 10} --player 3 teleport position

}

}

}

 

function onUse(cid, item, fromPosition, itemEx, toPosition)

if(item.itemid == 1946) then

doTransformItem(item.uid, 1945)

return TRUE

end

 

local arena = arenas[item.uid]

if(not arena) then

return FALSE

end

 

local players = {}

for _, pos in pairs(arena.fromPos) do

pos.stackpos = STACKPOS_TOP_CREATURE

local tmp = getThingfromPos(pos).uid

if(tmp > 0 and isCreature(tmp) == TRUE) then

table.insert(players, tmp)

end

end

 

if(table.maxn(players) < table.maxn(arena.fromPos)) then

doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need more creatures for duel.")

return TRUE

end

 

for i, pid in pairs(players) do

doSendMagicEffect(arena.fromPos, CONST_ME_POFF)

doTeleportThing(pid, arena.toPos)

doSendMagicEffect(arena.toPos, CONST_ME_TELEPORT)

doPlayerSendTextMessage(pid, MESSAGE_INFO_DESCR, "FIGHT!")

end

 

return TRUE

end

 

Se eu meter assim ela já não funciona, alguem sabe porquê?

Vlw

Link para o comentário
Compartilhar em outros sites

local arenas = {

[7667] = {

fromPos ={

{x = 1005, y = 995, z = 10}, --player 1 start pos

{x = 1006, y = 995, z = 10}, --player 2 start pos

{x = 1007, y = 995, z = 10} --player 3 start pos

},

toPos = {

{x = 1008, y = 995, z = 10}, --player 1 teleport position

{x = 1009, y = 995, z = 10}, --player 2 teleport position

{x = 1010, y = 995, z = 10} --player 3 teleport position

}

}

}

 

function onUse(cid, item, fromPosition, itemEx, toPosition)

if(item.itemid == 1946) then

doTransformItem(item.uid, 1945)

return TRUE

end

 

local arena = arenas[item.uid]

if(not arena) then

return FALSE

end

 

local players = {}

for _, pos in pairs(arena.fromPos) do

pos.stackpos = STACKPOS_TOP_CREATURE

local tmp = getThingfromPos(pos).uid

if(tmp > 0 and isCreature(tmp) == TRUE) then

table.insert(players, tmp)

end

end

 

if(table.maxn(players) < table.maxn(arena.fromPos)) then

doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need more creatures for duel.")

return TRUE

end

 

for i, pid in pairs(players) do

doSendMagicEffect(arena.fromPos, CONST_ME_POFF)

doTeleportThing(pid, arena.toPos)

doSendMagicEffect(arena.toPos, CONST_ME_TELEPORT)

doPlayerSendTextMessage(pid, MESSAGE_INFO_DESCR, "FIGHT!")

end

 

return TRUE

end

 

Coloque assim veja se vai funfar..

Link para o comentário
Compartilhar em outros sites

local arenas = {

[7667] = {

fromPos ={

{x = 1005, y = 995, z = 10}, --player 1 start pos

{x = 1006, y = 995, z = 10}, --player 2 start pos

{x = 1007, y = 995, z = 10} --player 3 start pos

},

toPos = {

{x = 1008, y = 995, z = 10}, --player 1 teleport position

{x = 1009, y = 995, z = 10}, --player 2 teleport position

{x = 1010, y = 995, z = 10} --player 3 teleport position

}

}

}

 

function onUse(cid, item, fromPosition, itemEx, toPosition)

if(item.itemid == 1946) then

doTransformItem(item.uid, 1945)

return TRUE

end

 

local arena = arenas[item.uid]

if(not arena) then

return FALSE

end

 

local players = {}

for _, pos in pairs(arena.fromPos) do

pos.stackpos = STACKPOS_TOP_CREATURE

local tmp = getThingfromPos(pos).uid

if(tmp > 0 and isCreature(tmp) == TRUE) then

table.insert(players, tmp)

end

end

 

if(table.maxn(players) < table.maxn(arena.fromPos)) then

doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need more creatures for duel.")

return TRUE

end

 

for i, pid in pairs(players) do

doSendMagicEffect(arena.fromPos, CONST_ME_POFF)

doTeleportThing(pid, arena.toPos)

doSendMagicEffect(arena.toPos, CONST_ME_TELEPORT)

doPlayerSendTextMessage(pid, MESSAGE_INFO_DESCR, "FIGHT!")

end

 

return TRUE

end

 

Coloque assim veja se vai funfar..

 

Funfou agora :) ... Mas um pequeno problema, quando os players são teleportados e chegam numa localização, Aquele efeito doSendMagicEffect(arena.toPos, CONST_ME_TELEPORT) só está dando num player, sonsegue arrumar a script para que dê em todos os player?

Link para o comentário
Compartilhar em outros sites

@fmiguel

 

Nao sei se vai funcionar, testa ai !

 

local arenas = {

[7667] = {

fromPos ={

{x = 1005, y = 995, z = 10}, --player 1 start pos

{x = 1006, y = 995, z = 10}, --player 2 start pos

{x = 1007, y = 995, z = 10} --player 3 start pos

},

toPos = {

{x = 1008, y = 995, z = 10}, --player 1 teleport position

{x = 1009, y = 995, z = 10}, --player 2 teleport position

{x = 1010, y = 995, z = 10} --player 3 teleport position

}

}

}

 

function onUse(cid, item, fromPosition, itemEx, toPosition)

if(item.itemid == 1946) then

doTransformItem(item.uid, 1945)

return TRUE

end

 

local arena = arenas[item.uid]

if(not arena) then

return FALSE

end

 

local players = {}

for _, pos in pairs(arena.fromPos) do

pos.stackpos = STACKPOS_TOP_CREATURE

local tmp = getThingfromPos(pos).uid

if(tmp > 0 and isCreature(tmp) == TRUE) then

table.insert(players, tmp)

end

end

 

if(table.maxn(players) < table.maxn(arena.fromPos)) then

doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need more creatures for duel.")

return TRUE

end

 

for i, pid in pairs(players) do

doSendMagicEffect(arena.fromPos, CONST_ME_POFF)

doTeleportThing(pid, arena.toPos)

doSendMagicEffect(pid, arena.toPos, CONST_ME_TELEPORT)

doPlayerSendTextMessage(pid, MESSAGE_INFO_DESCR, "FIGHT!")

end

 

return TRUE

end

Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...