GU

[Encerrado] Como fazer item teleportar pro templo e só pode ser usado a cada X Horas

Por guirlz, 31 de mai. de 2013 em Tópicos Sem Resposta

12
1.3k
guirlzG
31 de maio de 2013 às 17:37

Dei uma olhada no forum, achei varios itens que teleportam pro templo e tals, mas este item que preciso é um "Anti-bug" pra caso alguem fique bugado em um local e precise voltar ele deve usar este item.

 

Funciona assim o item X pode ser usado a cada X horas e te teleporta pro templo town1

 

 

Outra coisa, qual comando MySQL para injetar esse item na bag de TODOS chars que já estão criados ?

 

Att,

Obrigado.

SkymagnumS
31 de maio de 2013 às 18:09
function getTime(s)
  local h = math.floor(s / 3600)
  local m = math.floor((s - h * 3600 )/ 60)
  local s = s - h * 3600 - m * 60

  return h .. ":" .. m .. ":" .. s
end

function onUse(cid, item, fromPosition, itemEx, toPosition)

local message = "You can use again at %d hours"
local time = getPlayerStorageValue(cid, 83922) 
local hours = 3

   if time - os.time() > 0 then
       return doPlayerSendCancel(cid, message:format(getTime(time)))
   end

   setPlayerStorageValue(cid, 83922, os.time() + hours * 60 * 1000)
   return doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
end

guirlzG
01 de junho de 2013 às 11:34

Uma pergunta, caso seja uma talkaction o script também é o mesmo ?

AsMinaPiraA
01 de junho de 2013 às 16:51

/\ não

2 semanas depois...
guirlzG
11 de junho de 2013 às 20:23

Da este erro:

 

 

 

 

[11/06/2013 20:17:54] [Error - Action Interface]

[11/06/2013 20:17:54] data/actions/scripts/townstone.lua:onUse

[11/06/2013 20:17:54] Description:

[11/06/2013 20:17:54] data/actions/scripts/townstone.lua:16: bad argument #1 to 'format' (number expected, got string)

[11/06/2013 20:17:54] stack traceback:

[11/06/2013 20:17:54] [C]: in function 'format'

[11/06/2013 20:17:54] data/actions/scripts/townstone.lua:16: in function <data/actions/scripts/townstone.lua:9>

 

E se puder fazer com talkaction agradeço também !

SkymagnumS
11 de junho de 2013 às 20:38

function getTime(s)

local h = math.floor(s / 3600)

local m = math.floor((s - h * 3600 )/ 60)

local s = s - h * 3600 - m * 60

 

return h .. ":" .. m .. ":" .. s

end

 

function onUse(cid, item, fromPosition, itemEx, toPosition)

 

local message = "You can use again at %s hours"

local time = getPlayerStorageValue(cid, 83922)

local hours = 3

 

if time - os.time() > 0 then

return doPlayerSendCancel(cid, message:format(getTime(time)))

end

 

setPlayerStorageValue(cid, 83922, os.time() + hours * 60 * 1000)

return doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))

end

guirlzG
11 de junho de 2013 às 20:57

Funcionou, mas ta falando assim:

 

You can use again in 380881:56:48 hours

 

o.O

brun123B
11 de junho de 2013 às 23:31

troca essa linha:

 

setPlayerStorageValue(cid, 83922, os.time() + hours * 60 * 1000)

 

por essa:

 

setPlayerStorageValue(cid, 83922, os.time() + hours * 3600)

 

os.time trabalha em segundos...

guirlzG
12 de junho de 2013 às 16:14

Agora fica: 380854:13:50 Hours

Se puder me passar ela para usar com talkaction também.. agradeço muito !

Editado Junho 12 por guirlz

brun123B
12 de junho de 2013 às 17:44

Em talkaction:

 

function onSay(cid)

   local function getTime(s)
       local h = math.floor(s / 3600)
       local m = math.floor((s - h * 3600 )/ 60)
       local s = s - h * 3600 - m * 60
   return h .. ":" .. m .. ":" .. s
   end

   local message = "Você precisa esperar %s para usar novamente."
   local time = getPlayerStorageValue(cid, 83922) - os.time() 
   local hours = 3

   if time > 0 and time < hours * 3600 then
   return doPlayerSendCancel(cid, message:format(getTime(time)))
   end

   setPlayerStorageValue(cid, 83922, os.time() + hours * 3600)
return doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
end

 

pra mudar pra action, basta troca o function onSay por function onUse

guirlzG
12 de junho de 2013 às 21:02

Funcionou, valeu cara ! rep+

4 anos depois...
StigalS
21 de abril de 2018 às 02:48
A questão neste tópico de suporte foi encerrada por falta de respostas. Este tópico está fechado e foi movido para Suporte - Tópicos Sem Resposta.

+ Caso a dúvida não tenha sido resolvida você poderá criar outro tópico solicitando ajuda.
* Lembre-se que é permitido dar UP no tópico a cada 24 horas para assim o destacar e manter movimentado.