MA
pedido

Colocar exhaust em uma action

Por Malusz, 01 de dez. de 2013 em Scripts

resolvido
13
2.9k
MaluszM
01 de dezembro de 2013 às 14:11

function onUse(cid, item, frompos, item2, topos)

local config = {
pz = "yes", -- players precisam estar em protection zone para usar? ("yes" or "no").
battle = "yes", -- players deve estar sem battle ("yes" or "no")
pos = {x=1053, y=1049, z=7}
}
if(config.pz == "yes") and (getTilePzInfo(getCreaturePosition(cid)) == FALSE) then
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT,"você precisa estar em protection zone pra poder teleportar.")
return TRUE
end
if(config.battle == "yes") and (getCreatureCondition(cid, CONDITION_INFIGHT) == TRUE) then
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "Você precisa estar sem battler pra poder teleportar.")
return TRUE
end
if item.itemid == 5957 then
doPlayerSendTextMessage(cid,25,"Você foi teleportado para o CP de Saffron!")
doPlayerRemoveItem(cid, 13691, 1)
doTeleportThing(cid,config.pos)
doSendMagicEffect(getCreaturePosition(cid), 6)
end
return 1

end

 

Alguem poderia colocar exhausted de 10 minutos para usar este item que teleporta?

gonorreiaswatG
01 de dezembro de 2013 às 14:28

Não testei:

local config = {
pz = "yes", -- players precisam estar em protection zone para usar? ("yes" or "no").
battle = "yes", -- players deve estar sem battle ("yes" or "no")
pos = {x=1053, y=1049, z=7},
tempo = 10, -- tempo em minutos de exhaust
strg = 50030, -- storage que salva o tempo (não precisa mexer)
}

function onUse(cid, item, frompos, item2, topos)
    if(config.pz == "yes") and (getTilePzInfo(getCreaturePosition(cid)) == FALSE) then
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT,"Voce precisa estar em protection zone pra poder teleportar.")
    return TRUE
end
    if(config.battle == "yes") and (getCreatureCondition(cid, CONDITION_INFIGHT) == TRUE) then
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "Voce precisa estar sem battle pra poder teleportar.")
    return TRUE
end
    if exhaustion.check(cid, strg) then
        doPlayerSendCancel(cid, "Voce precisa aguardar "..exhaustion.get(cid, strg).." segundos para usar novamente este item.")
    return TRUE
end
    if item.itemid == 5957 then
        doPlayerSendTextMessage(cid,25,"Voce foi teleportado para o CP de Saffron!")
        doPlayerRemoveItem(cid, 13691, 1)
        doTeleportThing(cid,config.pos)
        doSendMagicEffect(getCreaturePosition(cid), 6)
        exhaustion.set(cid, strg, tempo * 60)
    end
  return 1
end

Boa sorte.

Editado Dezembro 1 por Adriano Swatt

MaluszM
01 de dezembro de 2013 às 15:56

Então amigo, testei deu esse erro olha.

 

[01/12/2013 15:54:41] [Error - Action Interface]

[01/12/2013 15:54:41] data/actions/scripts/teele.lua:onUse
[01/12/2013 15:54:41] Description:
[01/12/2013 15:54:41] data/actions/scripts/teele.lua:27: attempt to perform arithmetic on global 'tempo' (a nil value)
[01/12/2013 15:54:41] stack traceback:
[01/12/2013 15:54:41] data/actions/scripts/teele.lua:27: in function <data/actions/scripts/teele.lua:9>

zipter98Z
01 de dezembro de 2013 às 15:58


local config = {

pz = "yes", -- players precisam estar em protection zone para usar? ("yes" or "no").

battle = "yes", -- players deve estar sem battle ("yes" or "no")

pos = {x=1053, y=1049, z=7},

tempo = 10, -- tempo em minutos de exhaust

strg = 50030, -- storage que salva o tempo (não precisa mexer)

}

 

function onUse(cid, item, frompos, item2, topos)

if(config.pz == "yes") and (getTilePzInfo(getCreaturePosition(cid)) == FALSE) then

doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT,"Voce precisa estar em protection zone pra poder teleportar.")

return TRUE

end

if(config.battle == "yes") and (getCreatureCondition(cid, CONDITION_INFIGHT) == TRUE) then

doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "Voce precisa estar sem battle pra poder teleportar.")

return TRUE

end

if exhaustion.check(cid, strg) then

doPlayerSendCancel(cid, "Voce precisa aguardar "..exhaustion.get(cid, strg).." segundos para usar novamente este item.")

return TRUE

end

if item.itemid == 5957 then

doPlayerSendTextMessage(cid,25,"Voce foi teleportado para o CP de Saffron!")

doPlayerRemoveItem(cid, 13691, 1)

doTeleportThing(cid,config.pos)

doSendMagicEffect(getCreaturePosition(cid), 6)

exhaustion.set(cid, config.strg, config.tempo * 60)

end

return 1

end

Editado Dezembro 1 por zipter98

MaluszM
01 de dezembro de 2013 às 16:03

Zipter não deu nenhum erro, mas o player está teleportando a hora que quiser.

zipter98Z
01 de dezembro de 2013 às 16:25

Tenta:

function onUse(cid, item, frompos, item2, topos)
 
 
local config = {
pz = "yes", -- players precisam estar em protection zone para usar? ("yes" or "no").
battle = "yes", -- players deve estar sem battle ("yes" or "no")
pos = {x=1053, y=1049, z=7},
tempo = 10,
}
 
 
if(config.pz == "yes") and (getTilePzInfo(getCreaturePosition(cid)) == FALSE) then
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT,"você precisa estar em protection zone pra poder teleportar.")
return TRUE
end
    if getPlayerStorageValue(cid, 102911) > os.time() then
        return doPlayerSendCancel(cid, "Aguarde "..getPlayerStorageValue(cid, 102911) - os.time().." segundo(s) para teleportar novamente.")
    end
    
if(config.battle == "yes") and (getCreatureCondition(cid, CONDITION_INFIGHT) == TRUE) then
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "Você precisa estar sem battler pra poder teleportar.")
return TRUE
end
 
if item.itemid == 5957 then
doPlayerSendTextMessage(cid,25,"Você foi teleportado para o CP de Saffron!")
doPlayerRemoveItem(cid, 13691, 1)
doTeleportThing(cid,config.pos)
doSendMagicEffect(getCreaturePosition(cid), 6)
setPlayerStorageValue(cid, 102911, cfg.tempo * 60 * 1000)
 
end
return 1
end

Ou

 

function onUse(cid, item, frompos, item2, topos)
 
 
local config = {
pz = "yes", -- players precisam estar em protection zone para usar? ("yes" or "no").
battle = "yes", -- players deve estar sem battle ("yes" or "no")
pos = {x=1053, y=1049, z=7},
tempo = 10,
}
 
 
if(config.pz == "yes") and (getTilePzInfo(getCreaturePosition(cid)) == FALSE) then
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT,"você precisa estar em protection zone pra poder teleportar.")
return TRUE
end
    
if(config.battle == "yes") and (getCreatureCondition(cid, CONDITION_INFIGHT) == TRUE) then
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "Você precisa estar sem battler pra poder teleportar.")
return TRUE
end
 
    if item.itemid == 5957 then
        if getPlayerStorageValue(cid, 102911) > os.time() then
            return doPlayerSendCancel(cid, "Aguarde "..getPlayerStorageValue(cid, 102911) - os.time().." segundo(s) para teleportar novamente.")
        end
        doPlayerSendTextMessage(cid,25,"Você foi teleportado para o CP de Saffron!")
        doPlayerRemoveItem(cid, 13691, 1)
        doTeleportThing(cid,config.pos)
        doSendMagicEffect(getCreaturePosition(cid), 6)
        setPlayerStorageValue(cid, 102911, cfg.tempo * 60 * 1000)
 
end
return 1
end

Editado Dezembro 1 por zipter98

MaluszM
01 de dezembro de 2013 às 16:29
[01/12/2013 16:29:15] [Error - Action Interface]

[01/12/2013 16:29:15] data/actions/scripts/teele.lua:onUse

[01/12/2013 16:29:15] Description:

[01/12/2013 16:29:15] data/actions/scripts/teele.lua:30: attempt to index global 'cfg' (a nil value)

[01/12/2013 16:29:15] stack traceback:

[01/12/2013 16:29:15] data/actions/scripts/teele.lua:30: in function <data/actions/scripts/teele.lua:1>

zipter98Z
01 de dezembro de 2013 às 16:44

Força do hábito colocar cfg, desculpe.

function onUse(cid, item, frompos, item2, topos)
 
 
local config = {
pz = "yes", -- players precisam estar em protection zone para usar? ("yes" or "no").
battle = "yes", -- players deve estar sem battle ("yes" or "no")
pos = {x=1053, y=1049, z=7},
tempo = 10,
}
 
 
if(config.pz == "yes") and (getTilePzInfo(getCreaturePosition(cid)) == FALSE) then
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT,"você precisa estar em protection zone pra poder teleportar.")
return TRUE
end
    if getPlayerStorageValue(cid, 102911) > os.time() then
        return doPlayerSendCancel(cid, "Aguarde "..getPlayerStorageValue(cid, 102911) - os.time().." segundo(s) para teleportar novamente.")
    end
    
if(config.battle == "yes") and (getCreatureCondition(cid, CONDITION_INFIGHT) == TRUE) then
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "Você precisa estar sem battler pra poder teleportar.")
return TRUE
end
 
if item.itemid == 5957 then
doPlayerSendTextMessage(cid,25,"Você foi teleportado para o CP de Saffron!")
doPlayerRemoveItem(cid, 13691, 1)
doTeleportThing(cid,config.pos)
doSendMagicEffect(getCreaturePosition(cid), 6)
setPlayerStorageValue(cid, 102911, config.tempo * 60 * 1000)
 
end
return 1
end
Ou
function onUse(cid, item, frompos, item2, topos)
 
 
local config = {
pz = "yes", -- players precisam estar em protection zone para usar? ("yes" or "no").
battle = "yes", -- players deve estar sem battle ("yes" or "no")
pos = {x=1053, y=1049, z=7},
tempo = 10,
}
 
 
if(config.pz == "yes") and (getTilePzInfo(getCreaturePosition(cid)) == FALSE) then
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT,"você precisa estar em protection zone pra poder teleportar.")
return TRUE
end
    
if(config.battle == "yes") and (getCreatureCondition(cid, CONDITION_INFIGHT) == TRUE) then
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "Você precisa estar sem battler pra poder teleportar.")
return TRUE
end
 
    if item.itemid == 5957 then
        if getPlayerStorageValue(cid, 102911) > os.time() then
            return doPlayerSendCancel(cid, "Aguarde "..getPlayerStorageValue(cid, 102911) - os.time().." segundo(s) para teleportar novamente.")
        end
        doPlayerSendTextMessage(cid,25,"Você foi teleportado para o CP de Saffron!")
        doPlayerRemoveItem(cid, 13691, 1)
        doTeleportThing(cid,config.pos)
        doSendMagicEffect(getCreaturePosition(cid), 6)
        setPlayerStorageValue(cid, 102911, config.tempo * 60 * 1000)
 
end
return 1
end

Editado Dezembro 1 por zipter98

MaluszM
01 de dezembro de 2013 às 16:54

Zipter eu não sei pq man mais o player está teleportando a hora que quiser ;S o exhausted não funfou

zipter98Z
01 de dezembro de 2013 às 17:03

Ops, foi erro meu mesmo.

function onUse(cid, item, frompos, item2, topos)
 
 
local config = {
pz = "yes", -- players precisam estar em protection zone para usar? ("yes" or "no").
battle = "yes", -- players deve estar sem battle ("yes" or "no")
pos = {x=1053, y=1049, z=7},
tempo = 10,
}
 
 
if(config.pz == "yes") and (getTilePzInfo(getCreaturePosition(cid)) == FALSE) then
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT,"você precisa estar em protection zone pra poder teleportar.")
return TRUE
end
    
if(config.battle == "yes") and (getCreatureCondition(cid, CONDITION_INFIGHT) == TRUE) then
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "Você precisa estar sem battler pra poder teleportar.")
return TRUE
end
 
    if item.itemid == 5957 then
        if getPlayerStorageValue(cid, 102911) > os.time() then
            return doPlayerSendCancel(cid, "Aguarde "..getPlayerStorageValue(cid, 102911) - os.time().." segundo(s) para teleportar novamente.")
        end
        doPlayerSendTextMessage(cid,25,"Você foi teleportado para o CP de Saffron!")
        doPlayerRemoveItem(cid, 13691, 1)
        doTeleportThing(cid,config.pos)
        doSendMagicEffect(getCreaturePosition(cid), 6)
        setPlayerStorageValue(cid, 102911, os.time() + config.tempo * 60 * 1000)
 
end
return 1
end

Ou

function onUse(cid, item, frompos, item2, topos)
 
 
local config = {
pz = "yes", -- players precisam estar em protection zone para usar? ("yes" or "no").
battle = "yes", -- players deve estar sem battle ("yes" or "no")
pos = {x=1053, y=1049, z=7},
tempo = 10,
}
 
 
if(config.pz == "yes") and (getTilePzInfo(getCreaturePosition(cid)) == FALSE) then
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT,"você precisa estar em protection zone pra poder teleportar.")
return TRUE
end
    if getPlayerStorageValue(cid, 102911) > os.time() then
        return doPlayerSendCancel(cid, "Aguarde "..getPlayerStorageValue(cid, 102911) - os.time().." segundo(s) para teleportar novamente.")
    end
    
if(config.battle == "yes") and (getCreatureCondition(cid, CONDITION_INFIGHT) == TRUE) then
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "Você precisa estar sem battler pra poder teleportar.")
return TRUE
end
 
if item.itemid == 5957 then
doPlayerSendTextMessage(cid,25,"Você foi teleportado para o CP de Saffron!")
doPlayerRemoveItem(cid, 13691, 1)
doTeleportThing(cid,config.pos)
doSendMagicEffect(getCreaturePosition(cid), 6)
setPlayerStorageValue(cid, 102911, os.time() + config.tempo * 60 * 1000)
 
end
return 1
end

O sendcancel vai aparecer em segundos, não se assuste com o número que aparecerá.

Editado Dezembro 1 por zipter98

MaluszM
01 de dezembro de 2013 às 17:07

Zipter agora funciou =D REP+

OmegaO
01 de dezembro de 2013 às 18:12

Tópico movido para a seção de dúvidas e pedidos resolvidos.

gonorreiaswatG
01 de dezembro de 2013 às 20:58

No meu eu havia esquecido de por o config.tempo no exhaust.set.

Enfim, que bom que resolveu.

 

Boa sorte com seu Projeto.