Positioner [v1]
Iaaaae Galera, como vão? Hoje vim lhes apresentar o meu Action. É o Positioner, oque ele faz?
- O Positioner é um item (ID:1956 - MAPA), ao dar USE, ele grava suas coordenadas, ai você pode ir para aonde quiser. Pode até morrer, dando USE novamente, voltará para aquelas coordenadas (posição) que salvou. Legal né? Eu adaptei alguns códigos que achei para fazê-lo, vamos lá.
Vá em data/lib, abra o arquivo 050-function.lua, as vezes pode estar só com o nome function.lua. Lá, na última linha de todas, dê um enter, pule uma linha e acrescente isso:
function savePosition(cid) RETORNAR = {x = getPlayerStorageValue(cid, 20000), y = getPlayerStorageValue(cid, 20001), z = getPlayerStorageValue(cid, 20002)} local PLAYER = getPlayerGUID(cid) addEvent(function() if isCreature(cid) then setPlayerStorageValue(PLAYER, 20003, 0) else db.executeQuery("DELETE FROM `player_storage` WHERE `key` = 20003 AND `player_id` = " .. getPlayerGUID(cid) .. ";") end end) end
Essa é a nossa função para salvar a position, usei a do SkyMagnum (talkaction) e adaptei para action. No caso, vá em data/actions/scripts, copie algum arquivo dessa pasta e cole. Renomeie para positioner.lua,abra com o bloco de notas, apague oque estiver dentro e cole:
function onUse(cid, item, frompos, item2, topos) if getPlayerStorageValue(cid, 20003) <= 0 then setPlayerStorageValue(cid, 20000, getCreaturePosition(cid).x) setPlayerStorageValue(cid, 20001, getCreaturePosition(cid).y) setPlayerStorageValue(cid, 20002, getCreaturePosition(cid).z) doSendMagicEffect(getCreaturePosition(cid), 28) doPlayerSendTextMessage(cid,27,"You have saved your position, use the Positoner again to be sent to the starting position.") setPlayerStorageValue(cid, 20003, 1) savePosition(cid) return true end if getPlayerStorageValue(cid, 20003) > 0 then doTeleportThing(cid, RETORNAR) doSendMagicEffect(RETORNAR,28) doSendAnimatedText(RETORNAR,"Returned!",math.random(1,255)) doPlayerSendTextMessage(cid, 27, "You returned to its initial position. To save again, simply use the Positioner.") setPlayerStorageValue(cid, 20000, 0) setPlayerStorageValue(cid, 20001, 0) setPlayerStorageValue(cid, 20002, 0) setPlayerStorageValue(cid, 20003, 0) end return true end
Agora no arquivo actions.xml, adicione essa tag:
<action itemid="1956" event="script" value="positioner.lua"/>
No caso é o item ID 1956 que é um mapa, basta dar USE nele para salvar e dar USE novamente para retornar á position! Se quiser trocar o ID do item na tag pode, mas esse item não pode ser do tipo "Use With..."
Beeeeijo grande galera, aguardem por breves versões