Ir para conteúdo

Posts Recomendados

Tipo: Talkaction.

Testado: Não.


 

Breve explicação

É uma talkaction, que serve para que quando você está morrendo você use ela, e então quando você morrer, você fala !return, e volta para aonde você morreu ou salvou, é simples assim.

  • Fácil configuração


 

Primeiro vá em data depois em lib e em seguida na pasta 050-FUNCTION então adicione isso lá:

 

MAIN_CONFIG = {
POSITION_STORAGE_X = 10090,
POSITION_STORAGE_Y = 10091,
POSITION_STORAGE_Z = 10092,
STORAGE_CHECK = 10093,
STORAGE_TIME = 10094,
MESSAGE_WAIT = "You need wait " .. getPlayerStorageValue(cid, MAIN_CONFIG.STORAGE_TIME) - os.time() .. " seconds.",
MESSAGE_SAVE = "You sucefully save your position, if your down say !return.",
MESSAGE_RETURNING = "You has been teleported for you save position",
MESSAGE_BATTLE = "?",
MESSAGE_PROTECTION = "?",
MESSAGE_USING = "?",
}

 

e isso também:

 

function resetStatusInTime(cid)

local P_ID = getPlayerGUID(cid)
local PLAYER = getPlayerByGUID(P_ID)

addEvent(function() 
if isCreature(PLAYER) then
setPlayerStorageValue(PLAYER, MAIN_CONFIG.STORAGE_TIME, 0)
setPlayerStorageValue(PLAYER, MAIN_CONFIG.STORAGE_CHECK, 0)
else
db.executeQuery("DELETE FROM `player_storage` WHERE `key` = 10093 AND `player_id` = " .. getPlayerGUID(PLAYER) .. ";")
db.executeQuery("DELETE FROM `player_storage` WHERE `key` = 10094 AND `player_id` = " .. getPlayerGUID(PLAYER) .. ";")
end
end, 360 * 1000)

end

  • Não mecha em nada que não tenha MESSAGE

agora vá na pasta talkactions crie 2 arquivos um chamado returnPos e coloque isso dentro:

function onSay(cid, words, param, channel)

local RETURN_PLAYER_POS = {x = getPlayerStorageValue(cid, MAIN_CONFIG.POSITION_STORAGE_X), y = getPlayerStorageValue(cid, MAIN_CONFIG.POSITION_STORAGE_Y), z = getPlayerStorageValue(cid, MAIN_CONFIG.POSITION_STORAGE_Z)}

if getPlayerStorageValue(cid, MAIN_CONFIG,STORAGE_CHECK) > 0 then
  if getCreatureCondition(cid, CONDITION_INFIGHT) then
     if getTileInfo(getThingPos(cid)).pz then
         doTeleportThing(cid, RETURN_PLAYER_POS)
            doPlayerSendTextMessage(cid, 27, MAIN_CONFIG.MESSAGE_RETURNING)
               setPlayerStorageValue(cid, MAIN_CONFIG.POSITION_STORAGE_X, 0)
                  setPlayerStorageValue(cid, MAIN_CONFIG.POSITION_STORAGE_Y, 0)
                     setPlayerStorageValue(cid, MAIN_CONFIG.POSITION_STORAGE_Z, 0)
                        setPlayerStorageValue(cid, MAIN_CONFIG.STORAGE_CHECK, 0)
                           setPlayerStorageValue(cid, MAIN_CONFIG.STORAGE_TIME, 0)
                               else
                                    doPlayerSendCancel(cid, MAIN_CONFIG.MESSAGE_PROTECTION)
                                    end
                                       else
                     doPlayerSendCancel(cid, MAIN_CONFIG.MESSAGE_BATTLE)
                  end
              end
  return true
end

 

e o outro savePos e coloque isso dentro:

 

 

function onSay(cid, words, param, channel)


if getPlayerStorageValue(cid, MAIN_CONFIG.STORAGE_TIME) <= os.time() then
   if getPlayerStorageValue(cid, MAIN_CONFIG.STORAGE_CHECK) <= 0 then
      setPlayerStorageValue(cid, MAIN_CONFIG.POSITION_STORAGE_X, getThingPos(cid).x)
      setPlayerStorageValue(cid, MAIN_CONFIG.POSITION_STORAGE_Y, getThingPos(cid).y)
          setPlayerStorageValue(cid, MAIN_CONFIG.POSITION_STORAGE_Z, getThingPos(cid).z)
              doPlayerSendTextMessage(cid, 27, MAIN_CONFIG.MESSAGE_SAVE .. "You have 360 seconds for this.")
                 doSendMagicEffect(getThingPos(cid), 28)
                    setPlayerStorageValue(cid, MAIN_CONFIG.STORAGE_CHECK, 1)
                        setPlayerStorageValue(cid, MAIN_CONFIG.STORAGE_TIME, os.time() + 360)
                          resetStatusInTime(cid)
                           else
                               doPlayerSendCancel(cid, MAIN_CONFIG.MESSAGE_USING)
                               end
                                   else
                doPlayerSendCancel(cid, MAIN_CONFIG.MESSAGE_WAIT)
            end
return true
end

 

qlr erro posta ai, fiz rapido o script e o topico tbm, ent vlw flws, se ti tbm sapora ai foi mals, vlw flws, ta lgd, flws e vlw.

Link para o comentário
https://xtibia.com/forum/topic/207397-returning-talkaction/
Compartilhar em outros sites

Rapaz, legal o sistema, mesmo já existindo outras versões na net, mas você não acha que tá muito pogado não?

 

 

  Mostrar conteúdo oculto

 

 

OBS: A identação do seu código tá muito errada.

Editado por LuckOake
Link para o comentário
https://xtibia.com/forum/topic/207397-returning-talkaction/#findComment-1466569
Compartilhar em outros sites

legal, mas seria melhor vc salvar a pos quando o jogador morre, e, quando ele da !return, ele zera a pos, pq se nao ele pode ficar voltando e tudo mais

e digo isso pq por exemplo, se tiver 1 boss q geral quer matar quando spawnar, o jogador pode dar !save naquela pos e ir pra lá

entao acho q é meio falho o script, mas ta valendo, obrigado por compartilhar.

Link para o comentário
https://xtibia.com/forum/topic/207397-returning-talkaction/#findComment-1466812
Compartilhar em outros sites

Fiz mais só pra zuar mesmo, não curto muito gmatch eu usaria gsub:

setPlayerStorageValue(cid, storagePos, ":".. p.x ..",:".. p.y ..",:".. p.z)

pra checar

local pPos = tostring(getPlayerStorageValue(cid, storagePos)):gsub(':', ''):explode(',')

 

pPos[1] -> x

pPos[2] -> y

pPos[3] -> z

Link para o comentário
https://xtibia.com/forum/topic/207397-returning-talkaction/#findComment-1467517
Compartilhar em outros sites

e como ficaria isso draky? '--'

 

e eu usaria assim sei la..

local sto = "x: 1000, y: 500, z: 7;"
local x, y, z = sto:match("x: (.-), y: (.-), z: (.-);")
print(x, y, z)

 

soh um exemplo ta... kk

Link para o comentário
https://xtibia.com/forum/topic/207397-returning-talkaction/#findComment-1467717
Compartilhar em outros sites

Ficaria tipo assim então:

 

local pos = getPlayerPosition(cid)
local tablePos = {x = pos.x, y = pos.y, z = pos.z}

setPlayerStorageValue(cid, 3500, tablePos)

sinceramente acho que isso não funciona

Link para o comentário
https://xtibia.com/forum/topic/207397-returning-talkaction/#findComment-1467914
Compartilhar em outros sites

×
×
  • Criar Novo...