SK
talkaction

Returning Talkaction

Por Skymagnum, 11 de fev. de 2013 em Actions e Talkactions

script
17
1.8k
SkymagnumS
11 de fevereiro de 2013 às 23:09

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.

leoperez011L
11 de fevereiro de 2013 às 23:23

cara tem como colocar so para vip poder usar isso ?

SkymagnumS
11 de fevereiro de 2013 às 23:26

vc usa q sismtema vip?

leoperez011L
11 de fevereiro de 2013 às 23:29

como assim que sistema vip ?

SkymagnumS
11 de fevereiro de 2013 às 23:32

O sistema vip que você usa, você queria que eu colocasse só para vip's usarem.

leoperez011L
11 de fevereiro de 2013 às 23:34

eu não sei que sistema que eu uso sou novo nesse negocio de ots

LuckOakeL
11 de fevereiro de 2013 às 23:35

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

 

 

local pos = 79131
local exha = 79132
local time = 360 -- Tempo para usar a talk
local cost = true -- Cobrar? (true / false)
local price = 1000 -- Preço
local battle = false -- Permitido usar o comando com Battle? (true / false)
local protection = true -- É necessário estar em Protection Zone? (true / false)

function onSay(cid, words)
   if words == "!save" then
       if cost and not doPlayerRemoveMoney(cid, price) then
           doPlayerSendCancel(cid, "It costs "..price.." gold coins to save your position.") return true
       elseif battle and hasCondition(cid, CONDITION_INFIGHT) then
           doPlayerSendCancel(cid, "You can't use this command while in battle.") return true
       elseif protection and not getTilePzInfo(getCreaturePosition(cid)) then
           doPlayerSendCancel(cid, "You can only use this command in Protection Zones.") return true
       end

       setPlayerStorageValue(cid, pos, "x = "..(getCreaturePos(cid).x)..", y = "..(getCreaturePos(cid).y)..", z = "..(getCreaturePos(cid).z)..",")
       exhaustion.set(cid, exha, time)
       doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You've saved your position successfully. You have "..time.." seconds to return.")
   elseif words == "!return" then
       if not exhaustion.check(cid, exha) then
           doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Sorry, but your time has expired or you've never saved your position.") return true
       elseif battle and hasCondition(cid, CONDITION_INFIGHT) then
           doPlayerSendCancel(cid, "You can't use this command while in battle.") return true
       elseif protection and not getTilePzInfo(getCreaturePosition(cid)) then
           doPlayerSendCancel(cid, "You can only use this command in Protection Zones.") return true
       end

       local stor = getPlayerStorageValue(cid, pos)
       local posit = {x = tonumber(stor:match("x = (.-),")), y = tonumber(stor:match("y = (.-),")), z = tonumber(stor:match("z = (.-),"))}

       doTeleportThing(cid, posit)
       exhaustion.set(cid, exha, 0)
       setPlayerStorageValue(cid, pos, -1)
       doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You've returned to your saved position successfully.")
       doSendMagicEffect(getCreaturePos(cid), 10)
   end
return true
end

 

 

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

Editado Fevereiro 11 por LuckOake

SkymagnumS
12 de fevereiro de 2013 às 00:03

Fiz ele rapidin o xtibia fica bugando a identação

20cm2
12 de fevereiro de 2013 às 06:42

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.

caoticC
12 de fevereiro de 2013 às 11:08

Opa fico legal.

E melhor salvar as pos tudo em uma storage depois usar gmatch para procurar os valores(como o script que luck monstro).

Mais ta legal sim.

Parabéns

SkymagnumS
12 de fevereiro de 2013 às 16:41

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

drakylucasD
12 de fevereiro de 2013 às 17:10

cara, storages também salvam tabela viu.. nao precisa usar gmatch nem gsub... é só salvar todos os dados em uma tabela em uma unica storage ¬¬

SlicerS
12 de fevereiro de 2013 às 20:40

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

SkymagnumS
13 de fevereiro de 2013 às 01:10

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

SlicerS
13 de fevereiro de 2013 às 10:43

/\ no meu teste retornou nil... ;x