Elnelson 0 #1 Postado 3 Agosto, 2018 Version: TFS 0.4 Base: Olá. Eu tenho esse script, mas ele não está funcionando corretamente, ele deveria regenerar a resistência, mas quando eu usá-lo eu tenho 3 erros no console e não funciona.aqui está o roteiro. também a roupa não está na posição correta (veja imagem) Qual erro está surgindo? [17:52:07.767] [Error - Action Interface] [17:52:07.773] data/actions/scripts/resting.lua:onUse [17:52:07.775] Description: [17:52:07.778] attempt to index a number value [17:52:07.783] stack traceback: [17:52:07.785] [C]: in function 'getTileItemById' [17:52:07.788] data/actions/scripts/resting.lua:44: in function <data/actions/scripts/resting.lua:1> [17:52:13.080] [Error - Action Interface] [17:52:13.098] data/actions/scripts/resting.lua:onUse [17:52:13.118] Description: [17:52:13.140] attempt to index a number value [17:52:13.143] stack traceback: [17:52:13.145] [C]: in function 'doTeleportThing' [17:52:13.156] data/actions/scripts/resting.lua:41: in function <data/actions/scripts/resting.lua:1> Script: function onUse(cid, item, fromPosition, itemEx, toPosition) local config = { soul = 0, -- amount of souls to start timer = 1, -- time in minutes rateStamina = 10, -- percent } if getPlayerSoul(cid) >= config.soul then local myOutfit, cstamina, secondPos, changeType, changeStraw, straw = getCreatureOutfit(cid), getPlayerStamina(cid), toPosition, 0, 0, 0 local clookType = myOutfit.lookType if itemEx.itemid == 5501 then toPosition = toPosition.x - 1 straw = 5500 elseif itemEx.itemid == 5503 then toPosition = toPosition.y - 1 straw = 5502 elseif itemEx.itemid == 5500 then secondPos = secondPos.x + 1 straw = itemEx.itemid elseif itemEx.itemid == 5502 then secondPos = secondPos.y + 1 straw = itemEx.itemid end if itemEx.itemid == 5500 or 5501 then if getPlayerSex(cid) == PLAYERSEX_FEMALE then changeType = 7841 changeStraw = 7842 else changeType = 5496 changeStraw = 5497 end elseif itemEx.itemid == 5502 or 5503 then if getPlayerSex(cid) == PLAYERSEX_FEMALE then changeType = 7843 changeStraw = 7844 else changeType = 5498 changeStraw = 5499 end end doTeleportThing(cid, toPosition, false) doCreatureChangeOutfit(cid, {lookTypeEx = changeType}) doCreatureSetNoMove(cid, true) doTransformItem(getTileItemById(secondPos, straw).uid, changeStraw) doSendAnimatedText(toPosition, "RESTING", TEXTCOLOR_ORANGE) addEvent(function() if isPlayer(cid) then doPlayerSetStamina(cid, cstamina + cstamina * config.rateStamina) doCreatureChangeOutfit(cid, {lookType = clookType}) doRemoveItem(getTileItemById(secondPos, changeStraw).uid, 1) doCreateItem(straw, 1, secondPos) doCreatureSetNoMove(cid, false) doSendAnimatedText(toPosition, "RESTED", TEXTCOLOR_GREEN) end end, config.timer * 60 * 1000) end return true end Compartilhar este post Link para o post Compartilhar em outros sites
0 gpedro 47 #2 Postado 11 Agosto, 2018 teoricamente, o problema ocorre pela falta de atenção na hora do desenvolvimento, ao invés de manter a variável secondPos como um objeto de coordenada valida (com x, y e z) ele atribui o valor de um número inteiro. function onUse(cid, item, fromPosition, itemEx, toPosition) local config = { soul = 0, -- amount of souls to start timer = 1, -- time in minutes rateStamina = 10, -- percent } if getPlayerSoul(cid) >= config.soul then local myOutfit, cstamina, secondPos, changeType, changeStraw, straw = getCreatureOutfit(cid), getPlayerStamina(cid), toPosition, 0, 0, 0 local clookType = myOutfit.lookType if itemEx.itemid == 5501 then -- problema 01 toPosition.x = toPosition.x - 1 straw = 5500 elseif itemEx.itemid == 5503 then -- problema 02 toPosition.y = toPosition.y - 1 straw = 5502 elseif itemEx.itemid == 5500 then -- problema 03 secondPos.x = secondPos.x + 1 straw = itemEx.itemid elseif itemEx.itemid == 5502 then -- problema 04 secondPos.y = secondPos.y + 1 straw = itemEx.itemid end if itemEx.itemid == 5500 or 5501 then if getPlayerSex(cid) == PLAYERSEX_FEMALE then changeType = 7841 changeStraw = 7842 else changeType = 5496 changeStraw = 5497 end elseif itemEx.itemid == 5502 or 5503 then if getPlayerSex(cid) == PLAYERSEX_FEMALE then changeType = 7843 changeStraw = 7844 else changeType = 5498 changeStraw = 5499 end end doTeleportThing(cid, toPosition, false) doCreatureChangeOutfit(cid, {lookTypeEx = changeType}) doCreatureSetNoMove(cid, true) doTransformItem(getTileItemById(secondPos, straw).uid, changeStraw) doSendAnimatedText(toPosition, "RESTING", TEXTCOLOR_ORANGE) addEvent(function() if isPlayer(cid) then doPlayerSetStamina(cid, cstamina + cstamina * config.rateStamina) doCreatureChangeOutfit(cid, {lookType = clookType}) doRemoveItem(getTileItemById(secondPos, changeStraw).uid, 1) doCreateItem(straw, 1, secondPos) doCreatureSetNoMove(cid, false) doSendAnimatedText(toPosition, "RESTED", TEXTCOLOR_GREEN) end end, config.timer * 60 * 1000) end return true end 1 Nolis reagiu a isto Compartilhar este post Link para o post Compartilhar em outros sites
Version: TFS 0.4
Base:
Olá. Eu tenho esse script, mas ele não está funcionando corretamente, ele deveria regenerar a resistência, mas quando eu usá-lo eu tenho 3 erros no console e não funciona.
aqui está o roteiro. também a roupa não está na posição correta (veja imagem)
Qual erro está surgindo?
Script:
Compartilhar este post
Link para o post
Compartilhar em outros sites