Postado Outubro 29, 2017 7 anos Autor @psychonaut Coloquei essa script ai e a porta continua virando e não faz nada, vou te mandar a script q acabei de fazer tirando algumas coisas\/ ela não faz nada + a porta tambem nao vira será que se vc acrescentar a ID Key consegue? Citar local config = { areas = { [1] = { topLeftPos = {x = 1076, y = 1147, z = 8}, bottomRightPos = {x = 1080, y = 1151, z = 8}, }, [2] = { topLeftPos = {x = 1076, y = 1147, z = 8}, bottomRightPos = {x = 1080, y = 1151, z = 8}, }, }, entry = { {x = 1085, y = 1145, z = 6}, }, destination = { {x = 1078, y = 1149, z = 8}, } } local teleport = {x=1078, y=1149, z=8} -- Coordenadas para onde o player irá ser teleportado. local item_id = 2091 -- ID do item que o player precisa para ser teleportado. local posmonstro = {x = 1077, y = 1147, z = 8} local monstro = "Arenator" function onUse(cid, item, fromPosition, item2, toPosition) if getPlayerItemCount(cid,item_id) >= 1 then doTeleportThing(cid, teleport) doSendMagicEffect(getPlayerPosition(cid), 10) doPlayerRemoveItem(cid, item_id, 1) doPlayerSendTextMessage(cid, 20, "Você tem 2 minutos para matar o Arenator!") else doPlayerSendTextMessage(cid, 20, "Você precisa de uma "..getItemNameById(item_id).." para entrar.") end local function CheckAnihilationInUse() for i = 1, #config.areas do for x = config.areas.topLeftPos.x, config.areas.bottomRightPos.x do for y = config.areas.topLeftPos.y, config.areas.bottomRightPos.y do for z = config.areas.topLeftPos.z, config.areas.bottomRightPos.z do local creature = getTopCreature({x = x, y = y, z = z}).uid if isPlayer(creature) then return true end end end end end return false end local function RemoveMonsters() local monsters = {} for i = 1, #config.areas do for x = config.areas.topLeftPos.x, config.areas.bottomRightPos.x do for y = config.areas.topLeftPos.y, config.areas.bottomRightPos.y do for z = config.areas.topLeftPos.z, config.areas.bottomRightPos.z do local position = {x = x, y = y, z = z, stackpos = 253} local creature = getThingfromPos(position) if isMonster(creature.uid) then table.insert(monsters, creature.uid) end end end end end for m in pairs(monsters) do doRemoveCreature(m) end end function onUse(cid, item, fromPosition, itemEx, toPosition) if(item.itemid == 6265) then if(config.daily) then doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE) else doTransformItem(item.uid, item.itemid - 1) end return true end if(item.itemid ~= 6265) then return true end if CheckAnihilationInUse() then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "A arena esta em uso, espere.") 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 or getPlayerMoney(cid) < config.money) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "No minimo players de level ".. config.level .." e possuir ".. config.money .." gold coins.") return true end table.insert(players, pid) end RemoveMonsters() doCreateMonster(monstro, posmonstro) doSendMagicEffect(config.entry, CONST_ME_POFF) doTeleportThing(cid, config.destination, false) doSendMagicEffect(config.destination, CONST_ME_ENERGYAREA) return true end
Postado Outubro 29, 2017 7 anos @OfWar Vê assim: Mostrar conteúdo oculto local t = { level = 100, key = {id = 1111, remove = "yes"}, -- id da chave que deve estar na mão, "yes" para remover, "no" para não remover area = {{x=1,y=1,z=1}, {x=1,y=1,z=1}}, -- posição do canto superior esquerdo, inferior direito da área arenaPos = {x=1,y=1,z=1}, -- posição para qual o player será teleportado ao entrar monster = {"Demon", {x=1,y=1,z=1}}, -- posição que o monstro aparecerá kick = {{1, "min"}, {x=1,y=1,z=1}} -- tempo para kikar o player da arena, posição para qual irá quando for kikado } function onUse(cid, item, fromPosition, itemEx, toPosition) local p, l, r = getPlayerPosition(cid), getPlayerSlotItem(cid, CONST_SLOT_LEFT), getPlayerSlotItem(cid, CONST_SLOT_RIGHT) if getPlayerLevel(cid) < t.level then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Only players level " .. t.level.. " or higher can pass.") doSendMagicEffect(p, CONST_ME_POFF) return true end if (l.itemid ~= t.key.id and r.itemid ~= t.key.id) then local key = getItemNameById(t.key.id) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You need ".. getArticle(key) .. " " .. key .. " in your hand.") doSendMagicEffect(p, CONST_ME_POFF) return true end local players = getPlayersInArea(t.area[1], t.area[2]) if #players > 0 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Somebody is inside the arena.") doSendMagicEffect(p, CONST_ME_POFF) return true end if t.key.remove == "yes" then doRemoveItem(l.itemid == t.key.id and l.uid or r.uid) end local monster = doCreateMonster(t.monster[1], t.monster[2]) doTeleportThing(cid, t.arenaPos) doSendMagicEffect(t.arenaPos, CONST_ME_TELEPORT) doCreatureSay(cid, "You will have " .. t.kick[1][1] .. " " .. t.kick[1][2] .. " to kill the " .. t.monster[1] .. "!", TALKTYPE_ORANGE_1) addEvent(kickFromArena, mathtime(t.kick[1]) * 1000, cid, monster) return true end function kickFromArena(cid, monster) local check = true if isMonster(monster) then doRemoveCreature(monster) check = false end if isPlayer(cid) then doTeleportThing(cid, t.kick[2]) doSendMagicEffect(t.kick[2], CONST_ME_TELEPORT) if check == false then doCreatureSay(cid, "Your time is over!", TALKTYPE_ORANGE_1) else doCreatureSay(cid, "Congratulations! You killed the " .. t.monster[1].. ".", TALKTYPE_ORANGE_1) end end end function getPlayersInArea(fromPos, toPos) local players = {} for _, pid in ipairs(getPlayersOnline()) do if isInRange(getPlayerPosition(pid), fromPos, toPos) then table.insert(players, pid) end end return players end function mathtime(table) -- by dwarfer local unit = {"sec", "min", "hour", "day"} for i, v in pairs(unit) do if v == table[2] then return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1) end end return error("Bad declaration in mathtime function.") end No actions.xml: <action actionid="ACTION_ID_DA_PORTA" script="NOMEDOARQUIVO.lua" /> Contato: Email: dwarfer@sapo.pt Discord: Dwarfer#2715
Postado Outubro 29, 2017 7 anos Autor @Dwarfer Mano, o item não precisa está na mão, só na backpack ja esta bom. não teleportou para sala do monstro e deu o seguinte erro Citar [29/10/2017 19:27:06] [Error - Action Interface] [29/10/2017 19:27:06] data/actions/scripts/arenaporta.lua:onUse [29/10/2017 19:27:06] Description: [29/10/2017 19:27:06] data/lib/032-position.lua:2: attempt to index global 'position' (a nil value) [29/10/2017 19:27:06] stack traceback: [29/10/2017 19:27:06] data/lib/032-position.lua:2: in function 'isInRange' [29/10/2017 19:27:06] data/actions/scripts/arenaporta.lua:60: in function 'getPlayersInArea' [29/10/2017 19:27:06] data/actions/scripts/arenaporta.lua:23: in function <data/actions/scripts/arenaporta.lua:10> Editado Outubro 29, 2017 7 anos por OfWar (veja o histórico de edições)
Postado Outubro 29, 2017 7 anos Solução Como assim não precisa estar na mão? Você colocou no tópico que "o Player clicka na porta com o XXX Item na mão", da próxima vez tente deixar seu pedido bem detalhado. Fiz a alteração para verificar se o player possui o item, independente de estar na mão. Mostrar conteúdo oculto local t = { level = 100, key = {id = 1111, remove = "yes"}, -- id da chave, "yes" para remover, "no" para não remover area = {{x=1,y=1,z=1}, {x=1,y=1,z=1}}, -- posição do canto superior esquerdo, inferior direito da área arenaPos = {x=1,y=1,z=1}, -- posição para qual o player será teleportado ao entrar monster = {"Demon", {x=1,y=1,z=1}}, -- posição que o monstro aparecerá kick = {{1, "min"}, {x=1,y=1,z=1}} -- tempo para kikar o player da arena, posição para qual irá quando for kikado } function onUse(cid, item, fromPosition, itemEx, toPosition) local p = getPlayerPosition(cid) if getPlayerLevel(cid) < t.level then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Only players level " .. t.level.. " or higher can pass.") doSendMagicEffect(p, CONST_ME_POFF) return true end if getPlayerItemCount(cid, t.key.id) == 0 then local key = getItemNameById(t.key.id) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You need ".. getArticle(key) .. " " .. key .. " to pass.") doSendMagicEffect(p, CONST_ME_POFF) return true end local players = getPlayersInArea(t.area[1], t.area[2]) if #players > 0 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Somebody is inside the arena.") doSendMagicEffect(p, CONST_ME_POFF) return true end if t.key.remove == "yes" then doPlayerRemoveItem(cid, t.key.id, 1) end local monster = doCreateMonster(t.monster[1], t.monster[2]) doTeleportThing(cid, t.arenaPos) doSendMagicEffect(t.arenaPos, CONST_ME_TELEPORT) doCreatureSay(cid, "You will have " .. t.kick[1][1] .. " " .. t.kick[1][2] .. " to kill the " .. t.monster[1] .. "!", TALKTYPE_ORANGE_1) addEvent(kickFromArena, mathtime(t.kick[1]) * 1000, cid, monster) return true end function kickFromArena(cid, monster) local check = true if isMonster(monster) then doRemoveCreature(monster) check = false end if isPlayer(cid) then doTeleportThing(cid, t.kick[2]) doSendMagicEffect(t.kick[2], CONST_ME_TELEPORT) if check == false then doCreatureSay(cid, "Your time is over!", TALKTYPE_ORANGE_1) else doCreatureSay(cid, "Congratulations! You killed the " .. t.monster[1].. ".", TALKTYPE_ORANGE_1) end end end function getPlayersInArea(fromPos, toPos) local players = {} for _, pid in ipairs(getPlayersOnline()) do if isInRange(getPlayerPosition(pid), fromPos, toPos) then table.insert(players, pid) end end return players end function mathtime(table) -- by dwarfer local unit = {"sec", "min", "hour", "day"} for i, v in pairs(unit) do if v == table[2] then return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1) end end return error("Bad declaration in mathtime function.") end Com relação ao erro, se você configurar as posições corretamente, vai funcionar. Contato: Email: dwarfer@sapo.pt Discord: Dwarfer#2715
Postado Outubro 29, 2017 7 anos Autor @Dwarfer Desculpa, foi pq pedi para o meu irmão montar o pedido. Fiz tudo perfeito e não deu certo. Então deu o seguinte error \/ Citar [29/10/2017 19:57:19] [Error - Action Interface] [29/10/2017 19:57:19] data/actions/scripts/arenaporta.lua:onUse [29/10/2017 19:57:19] Description: [29/10/2017 19:57:20] data/lib/032-position.lua:2: attempt to index global 'position' (a nil value) [29/10/2017 19:57:20] stack traceback: [29/10/2017 19:57:20] data/lib/032-position.lua:2: in function 'isInRange' [29/10/2017 19:57:20] data/actions/scripts/arenaporta.lua:60: in function 'getPlayersInArea' [29/10/2017 19:57:20] data/actions/scripts/arenaporta.lua:23: in function <data/actions/scripts/arenaporta.lua:10>
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.