IM

Ajuda script gema

Por imarlonjr, 07 de abr. de 2016 em Scripts

11
2.2k
imarlonjrI
07 de abril de 2016 às 22:22

Desculpa atrapalha-los novamente, mais estou com dificuldade ne um script, adicionei o sistema de gema aqui no Meu OT, porem tipo ta funcionando, a pessoa da use na gema ganha o efeito, mais quando ela desloga some, e não tem como ela usar a gema mais, o que será que ta acontecendo? obg

SkullsS
07 de abril de 2016 às 22:50

Possivelmente o efeito está sendo armazenado só em variáveis temporárias, quando ele loga elas são zeradas e perde-se o efeito. 

Sugestão: adicionar a um storage value e checar via creaturescript quando logar se há efeito de gema e adicionar.

 

Abraços,

imarlonjrI
08 de abril de 2016 às 13:39

Teria como olhar o script pra mim brow?

 

gems.lua

function onUse(cid, item, fromPosition, itemEx, toPosition)gem = gems.id[getPlayerVocation(cid)]if item.itemid == gem thendoUseGem(cid, item, getPlayerVocation(cid))endreturn TRUEend

 

actions.xml

<action itemid="2156" script="gems.lua"/><action itemid="2155" script="gems.lua"/><action itemid="2158" script="gems.lua"/><action itemid="2153" script="gems.lua"/>

 

Pivi.lua pasta lib

function doUseGem(cid, item)
local voc = getPlayerVocation(cid)
local interval = gems.interval[voc]
if item.itemid ~= gems.id[voc] or getPlayerStorageValue(cid, gems.storage[voc]) > 0 then
return FALSE
end
setPlayerStorageValue(cid, gems.storage[voc], 1)
sendGemEffect(cid, gems.storage[voc], gems.interval[voc])
doRemoveItem(item.uid, 1)

return TRUE
end

function sendGemEffect(cid, storage, interval)
local pos = getThingPos(cid)
local voc = getPlayerVocation(cid)
local color = 1
if voc == 1 then
color = gemMsg.colorDruid[math.random(1,#gemMsg.colorDruid)]
elseif voc == 2 then
color = gemMsg.colorSorcerer[math.random(1,#gemMsg.colorSorcerer)]
elseif voc == 3 then
color = gemMsg.colorPaladin[math.random(1,#gemMsg.colorPaladin)]
elseif voc == 4 then
color = gemMsg.colorKnight[math.random(1,#gemMsg.colorKnight)]
elseif voc == 5 then
color = gemMsg.colorDruid[math.random(1,#gemMsg.colorElderDruid)]
elseif voc == 6 then
color = gemMsg.colorSorcerer[math.random(1,#gemMsg.colorMasterSorcerer)]
elseif voc == 7 then
color = gemMsg.colorPaladin[math.random(1,#gemMsg.colorRoyalPaladin)]
elseif voc == 8 then
color = gemMsg.colorKnight[math.random(1,#gemMsg.colorEliteKnight)]
end
doSendAnimatedText(pos, gemMsg.rnd[math.random(1,#gemMsg.rnd)], color)
if getPlayerStorageValue(cid, gems.storage[getPlayerVocation(cid)]) >= 1 then
addEvent(sendGemEffect, interval, cid, storage, interval)
end
end
function doRemoveGemEffect(cid)
if getPlayerStorageValue(cid, gems.storage[getPlayerVocation(cid)]) < 1 then
return FALSE
end
setPlayerStorageValue(cid, gems.storage[getPlayerVocation(cid)], 0)
return TRUE
end
function doRemoveAllGemEffect(cid)
for i = 1, table.maxn(gms.storage) do
setPlayerStorageValue(cid, gems.storage, 0)
end
return TRUE
end
function isGemActivated(cid)
if getPlayerStorageValue(cid, gems.storage[getPlayerVocation(cid)]) > 0 then
return TRUE
end
return FALSE
end

 

 

Pivi_const.lua pasta lib

gems = {
id = {2156, 2155, 2158, 2153, 2156, 2155, 2158, 2156},
storage = {5001, 5002, 5003, 5004, 5005, 5006, 5007, 5008},
interval = {600, 600, 600, 600, 600, 600, 600}, -- Intervalo dos efeitos
}
gemMsg = {
rnd = {"´ .    ,", ".    ´ ,", "` . ,", ",    ´ ."},
colorDruid = {182,213},
colorSorcerer = {215,215},
colorPaladin = {89,89},
colorKnight = {210,210},
colorElderDruid = {182,213},
colorMasterSorcerer = {215,215},
colorRoyalPaladin = {89,89},
colorEliteKnight = {210,210}
}

 

 

 

PoccnnP
08 de abril de 2016 às 14:02

No caso, seu script está funcionando... fim de caso.

 

Você vai ter que criar uma função para quando o player logar e ele estiver com a gem ativa, por o efeito dele.

 

Segue a lógica:

Player entrou no jogo. 

Verifica se ele tem a gem ativa.

Se tiver gem ativa, chama a função que gera o efeito.

imarlonjrI
08 de abril de 2016 às 20:26

A logia eu sei, só não sei programar lua :c não sei as variáveis que usa :c

Só programo PHP

Sei que seria tipo

 

if(pegaplayergemaativa == 1){

Aq o código do efeito

}

 

imarlonjrI
09 de abril de 2016 às 00:25

if getPlayerStorageValue(cid, gems.storage[voc]) > 0 then
    return TRUE
  end

 

???

Só add no login.lua?

PoccnnP
09 de abril de 2016 às 08:56
8 horas atrás, imarlonjr disse:

if getPlayerStorageValue(cid, gems.storage[voc]) > 0 then

    return TRUE

  end

 

???

Só add no login.lua?

 

Sim, desde que a tabela gems seja global para poder ser acessada através do script login.lua.

Eu não usaria return true nesse escopo, pois pode haver outras linhas de informações do script que precisam ser executadas; nesse escopo, você chama a função que gera o efeito dele.

imarlonjrI
09 de abril de 2016 às 17:07

Então no caso ficaria como brow?

imarlonjrI
10 de abril de 2016 às 12:44

Eu peguei esse script de um OTServ 8.4, sabe me dizer se ele é compatível com o TFS 0.4 (8.6)?

No 8.4 ele funciona totalmente corretamente não tem esse problema que eu quero resolver, será alguma variavel que mudou da versão 8.4 pro TFS  0.4?

 

Obrigado.

miguel223M
13 de abril de 2016 às 17:11

Galera, o cara não sabe programar né.... Tem-se de dar uma resposta completo para ele, poxa...

Olha, deleta ssa merda toda, vou criar um outro sistema de gemas(aura) para ti. Vamos la:

 

Em actions.xml, adicione:

 

        <action itemid="2153" script="aura.lua" />
        <action itemid="2154" script="aura.lua" />
        <action itemid="2155" script="aura.lua" />
        <action itemid="2156" script="aura.lua" />
        <action itemid="2158" script="aura.lua" />

 

Em actions/scripts, crie um arquivo chamado aura.lua, e adicione:

 

 

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

if getPlayerStorageValue(cid, 13281) <= 0 then

if item.itemid == 2153 then
setPlayerStorageValue(cid, 13281, 1)
setPlayerStorageValue(cid, 13301, 1)
doSendMagicEffect(getPlayerPosition(cid), 12)
doRemoveItem(item.uid, 1)
doPlayerSendTextMessage(cid, 22, "Voce acabou de adquirir uma aura, jogador.")
end

if item.itemid == 2154 then
setPlayerStorageValue(cid, 13281, 1)
setPlayerStorageValue(cid, 13302, 1)
doSendMagicEffect(getPlayerPosition(cid), 12)
doRemoveItem(item.uid, 1)
doPlayerSendTextMessage(cid, 22, "Voce acabou de adquirir uma aura, jogador.")
end

if item.itemid == 2155 then
setPlayerStorageValue(cid, 13281, 1)
setPlayerStorageValue(cid, 13303, 1)
doSendMagicEffect(getPlayerPosition(cid), 12)
doRemoveItem(item.uid, 1)
doPlayerSendTextMessage(cid, 22, "Voce acabou de adquirir uma aura, jogador.")
end

if item.itemid == 2156 then
setPlayerStorageValue(cid, 13281, 1)
setPlayerStorageValue(cid, 13304, 1)
doSendMagicEffect(getPlayerPosition(cid), 12)
doRemoveItem(item.uid, 1)
doPlayerSendTextMessage(cid, 22, "Voce acabou de adquirir uma aura, jogador.")
end

if item.itemid == 2158 then
setPlayerStorageValue(cid, 13281, 1)
setPlayerStorageValue(cid, 13305, 1)
doSendMagicEffect(getPlayerPosition(cid), 12)
doRemoveItem(item.uid, 1)
doPlayerSendTextMessage(cid, 22, "Voce acabou de adquirir uma aura, jogador.")
end

else
doPlayerSendCancel(cid, "Voce ja possui uma aura, jogador.")
doSendMagicEffect(getPlayerPosition(cid), 2)
end

return true
end

 

Em creaturescripts.xml, adicione:

 

    <event type="think" name="aura" event="script" value="aura.lua"/>

 

Em creaturescripts/scripts, crie um arquivo chamado aura.lua e adicione:

 

function onThink(cid, interval, lastExecution)

if getPlayerStorageValue(cid, 13281) == 1 then

if getPlayerStorageValue(cid, 13282) <= os.time() then

doSendMagicEffect(getPlayerPosition(cid), getPlayerStorageValue(cid, 13301) == 1 and 47 or getPlayerStorageValue(cid, 13302) == 1 and 48 or getPlayerStorageValue(cid, 13303) == 1 and 16 or getPlayerStorageValue(cid, 13304) == 1 and 0 or getPlayerStorageValue(cid, 13305) == 1 and 11)
setPlayerStorageValue(cid, 13282, os.time() + 3)

end

end

return true
end

 

Em login.lua, adicione:

 

        registerCreatureEvent(cid, "aura")

 

PoccnnP
13 de abril de 2016 às 17:48
Em 10/04/2016 at 12:44, imarlonjr disse:

Eu peguei esse script de um OTServ 8.4, sabe me dizer se ele é compatível com o TFS 0.4 (8.6)?

No 8.4 ele funciona totalmente corretamente não tem esse problema que eu quero resolver, será alguma variavel que mudou da versão 8.4 pro TFS  0.4?

 

Obrigado.

 

Eu uso a versão 0.3.6 e dessa forma que foi feito funciona. 

O que tu precisa é de um evento login que verifique se o player tem a gem ativa para gerar o efeito sobre o mesmo.

 

Em 09/04/2016 at 17:07, imarlonjr disse:

Então no caso ficaria como brow?

 

Modificando um pouco o seu script;  ficaria assim:

Citar

local voc = getPlayerVocation (cid)

if getPlayerStorageValue(cid, gems.storage[voc]) > 0 then

    sendGemEffect(cid, gems.storage[voc], gems.interval[voc])

  end