Jump to content

Recommended Posts

Bom resolvi fazer este tutorial por que eu procurava muito ate que baixei um ot e nele contia a sistema inteiro bom ele e comprido então vamos começar!

 

Vá na pasta do seu ot entre em data/lib copie e cole qualquer arquivo .lua e renomeie ele para

gems.lua

 

dentro adicione isto:

 

function onUse(cid, item, fromPosition, itemEx, toPosition)
 gem = gems.id[getPlayerVocation(cid)]
 if item.itemid == gem then
doUseGem(cid, item, getPlayerVocation(cid))
 end
 return TRUE
end

 

ainda na pasta lib copie e cole outro arquivo .lua e renomeie para pivi.lua

 

dentro adicione isto:

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.colorElderDruid)]
elseif voc == 2 then
 color = gemMsg.colorSorcerer[math.random(1,#gemMsg.colorMasterSorcerer)]
elseif voc == 3 then
 color = gemMsg.colorPaladin[math.random(1,#gemMsg.colorRoyalPaladin)]
elseif voc == 4 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[i], 0)
 end
 return TRUE
function isGemActivated(cid)
if getPlayerStorageValue(cid, gems.storage[getPlayerVocation(cid)]) > 0 then
 return TRUE
 end
 return FALSE
end

Ainda em lib copie otro arquivo cole e renomeie ele para pivi_const.lua

 

detro adicione isto:

gems = {
id = {2156, 2155, 2158, 2154, 2156, 2155, 2158, 2154},
storage = {5001, 5002, 5003, 5004, 5005, 5006, 5007, 5008},
interval = {750, 750, 750, 750, 750, 750, 750, 750}, -- Intervalo dos efeitos
}
gemMsg = {
rnd = {"´ .	,", ".	´ ,", "`  .  ,", ",	` ."},
colorDruid = {180,180},
colorSorcerer = {30,215},
colorPaladin = {251,10},
colorKnight = {204,212},
colorElderDruid = {180,180},
colorMasterSorcerer = {30,215},
colorRoyalPaladin = {251,10},
colorEliteKnight = {204,212}
}

 

pronto agora vamos na pasta data/actions/scripte

copie e cole qualquer arquivo.lua e renomeie ele para gems.lua

 

adicione isto dentro:

local config =
{
minLevel = 200, -- Level mínimo para adquirir a gema.
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
if getPlayerLevel(cid) >= config.minLevel then
 gem = gems.id[getPlayerVocation(cid)]
 if item.itemid == gem then
doUseGem(cid, item, getPlayerVocation(cid))
 doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Você adquiriu uma gema espíritual.")
  doSendMagicEffect(getCreaturePosition(cid), 65)
 end
else
  doPlayerSendCancel(cid, "Voc\ê precisa ser level "..config.minLevel.." para adquirir a gema esp\íritual.")
 end
 return TRUE
end

 

feito isto va no seu actions.xml e adicione os seguintes tags :

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

 

feche e salve. Agora vamos na pasta data\creaturescripts\scripts

copie e cole qualquer arquivo lua renomeie para logingema.lua dentro adicione isto:

function onLogin(cid)
setPlayerStorageValue(cid, 47112120, 2)
local voc = getPlayerVocation(cid)
if getPlayerStorageValue(cid, gems.storage[getPlayerVocation(cid)]) > 0 then
sendGemEffect(cid, gems.storage[voc], gems.interval[voc])
end
return TRUE
end

 

feito isto abra o creaturescripts.xml e adicione este tag:

<event value="logingema.lua" event="script" name="gema" type="login"/>

 

agora na ultima parte va na pasta data/talkactions/scripts copie e cole qualquer arquivo lua e renomeie para gemasorc.lua

 

dentro adicione isto:

function onSay(cid, words, param)
if(words == "!buygemasorcerer") then
if(doPlayerRemoveMoney(cid, 1000000) == TRUE) then
doPlayerAddItem(cid,2156,1)
doSendMagicEffect(getCreaturePosition(cid),tmp, CONST_ME_MAGIC_RED)
else
doPlayerSendCancel(cid, "Você não tem o dinheiro suficiente.")
return TRUE
end

elseif(words == "!sellaol") then
if doPlayerRemoveItem(cid,2173,1) == TRUE then
doPlayerAddMoney(cid, 10000)
doSendMagicEffect(getCreaturePosition(cid),tmp, CONST_ME_MAGIC_RED)
else
doPlayerSendCancel(cid, "Você não tem o Amulet of Loss(AoL)")
end
end
return TRUE
end

 

ainda em scripts copie e cole otro arquivo.lua e renomeie para gemapally.lua

 

dentro adicione isto:

function onSay(cid, words, param)
if(words == "!buygemapally") then
if(doPlayerRemoveMoney(cid, 1000000) == TRUE) then
doPlayerAddItem(cid,2158,1)
doSendMagicEffect(getCreaturePosition(cid),tmp, CONST_ME_MAGIC_RED)
else
doPlayerSendCancel(cid, "Você não tem o dinheiro suficiente.")
return TRUE
end

elseif(words == "!sellaol") then
if doPlayerRemoveItem(cid,2173,1) == TRUE then
doPlayerAddMoney(cid, 10000)
doSendMagicEffect(getCreaturePosition(cid),tmp, CONST_ME_MAGIC_RED)
else
doPlayerSendCancel(cid, "Você não tem o Amulet of Loss(AoL)")
end
end
return TRUE
end

 

copie e cole qualquer arquivo.lua e renomeie para gemakina.lua

 

dentro adicione isto:

function onSay(cid, words, param)
if(words == "!buygemakina") then
if(doPlayerRemoveMoney(cid, 1000000) == TRUE) then
doPlayerAddItem(cid,2154,1)
doSendMagicEffect(getCreaturePosition(cid),tmp, CONST_ME_MAGIC_RED)
else
doPlayerSendCancel(cid, "Você não tem o dinheiro suficiente.")
return TRUE
end

elseif(words == "!sellaol") then
if doPlayerRemoveItem(cid,2173,1) == TRUE then
doPlayerAddMoney(cid, 10000)
doSendMagicEffect(getCreaturePosition(cid),tmp, CONST_ME_MAGIC_RED)
else
doPlayerSendCancel(cid, "Você não tem o Amulet of Loss(AoL)")
end
end
return TRUE
end

 

ainda em scripts copie e cole qualquer arquivo.lua e renomeie para gemadruid.lua

 

dentro adicione isto:

function onSay(cid, words, param)
if(words == "!buygemadruid") then
if(doPlayerRemoveMoney(cid, 1000000) == TRUE) then
doPlayerAddItem(cid,2155,1)
doSendMagicEffect(getCreaturePosition(cid),tmp, CONST_ME_MAGIC_RED)
else
doPlayerSendCancel(cid, "Você não tem o dinheiro suficiente.")
return TRUE
end

elseif(words == "!sellaol") then
if doPlayerRemoveItem(cid,2173,1) == TRUE then
doPlayerAddMoney(cid, 10000)
doSendMagicEffect(getCreaturePosition(cid),tmp, CONST_ME_MAGIC_RED)
else
doPlayerSendCancel(cid, "Você não tem o Amulet of Loss(AoL)")
end
end
return TRUE
end

 

agora para finalizar va no se talkactions.xml e adicione estas tags:

		<talkaction words="!buygemasorcerer" script="gemasorc.lua"/>
	<talkaction words="!buygemapally" script="gemapally.lua"/>
	<talkaction words="!buygemadruid" script="gemadruid.lua"/>
	<talkaction words="!buygemakina" script="gemakina.lua"/>

 

e pronto e so vc ter 1kk ser level 200 e falar !buygema e sua vocaçao

e voce ganhara uma gema ai e so clicar com o botao direito e vc vai começar a brilhar

 

é isso pessoal caso ajudei rep+ se tiverem duvidas postem aqui que eu ajudo

 

 

Editado e pronto para usar vlw por reportarem ^^

Edited by baiakizicksz
  • 5 weeks later...
  • 1 month later...

Muito bom cara, da uma revisada em alguns codes que estão bugados, e outra seria bem mais aproveitador ter postado esse sistema na sessão scripts, Abraços.

Aprovado, Parabéns, Continue Assim!

Mostrou um bom conteúdo, que, com certeza, deverá ajudar muita gente.

 

Movido para a Seção Correta!

@baiakizicksz,

como o Beeki disse, bom script, mas precisa de revisão, (Toda vez que o players desloga tem muitos erros), to meio sem tempo agora para arrumar esses erros, se você puder arrumar a comunidade agradeceria.

 

Sei que você copiou do seu OT, mas identação e bom né.

 

Fora isso, Muito bom script!

 

EDITED:

 

Errado

if voc == 1 then
 color = gemMsg.colorDruid[math.random(1,#gemMsg.colorElderDruid)]
elseif voc == 2 then
 color = gemMsg.colorSorcerer[math.random(1,#gemMsg.colorMasterSorcerer)]
elseif voc == 3 then
 color = gemMsg.colorPaladin[math.random(1,#gemMsg.colorRoyalPaladin)]
elseif voc == 4 then
 color = gemMsg.colorKnight[math.random(1,#gemMsg.colorEliteKnight)]
end

 

Certo

if voc == 1 or voc == 5 then
 color = gemMsg.colorSorcerer[math.random(1,#gemMsg.colorMasterSorcerer)]
elseif voc == 2 voc == 6 then
 color = gemMsg.colorDruid[math.random(1,#gemMsg.colorElderDruid)]
elseif voc == 3 voc == 7 then
 color = gemMsg.colorPaladin[math.random(1,#gemMsg.colorRoyalPaladin)]
elseif voc == 4 voc == 8then
 color = gemMsg.colorKnight[math.random(1,#gemMsg.colorEliteKnight)]
end

 

e apos isto mude as cores do efeito ao seu gosto em pivi_const

Edited by Sofft

@baiakizicksz,

arrumei todos os bugs, menos o bug quando o player desloga, porque, antes do player deslogar já foi criado um Event que ainda vai acontecer.

provavelmente terá que ser feito um onPlayerLogout... não estou conseguindo, por favor ajude.

@baiakizicksz,

testarei, jaja edito

 

EDITED:

 

A função PIVI ta faltando um end, o certo seria assim:

 

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.colorElderDruid)]
elseif voc == 2 then
 color = gemMsg.colorSorcerer[math.random(1,#gemMsg.colorMasterSorcerer)]
elseif voc == 3 then
 color = gemMsg.colorPaladin[math.random(1,#gemMsg.colorRoyalPaladin)]
elseif voc == 4 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[i], 0)
 end
 return TRUE
end
function isGemActivated(cid)
if getPlayerStorageValue(cid, gems.storage[getPlayerVocation(cid)]) > 0 then
 return TRUE
 end
 return FALSE
end

 

e continua dando erros apos o player deslogar, mas nada que atrapalhe o server, (somente porque o avento ocorre em um player que não está mais online).

Edited by Sofft

Vou postar aqui minha versão desse script, eu peguei aqui com o baiakizicksz e editei, os créditos são do criador do script, que até então não conheço.

 

Esta versão é usado no meu otserv da seguinte forma, player colocou vip ele brilha acabou a vip para de brilhar.=/

GEMS BY VIP.

 

Pasta Lib {

 

gems.lua

function onUse(cid, item, fromPosition, itemEx, toPosition)
 gem = gems.id[getPlayerVocation(cid)]
 if item.itemid == gem then
	doUseGem(cid, item, getPlayerVocation(cid))
 end
 return TRUE
end

 

pivi.lua

 

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 == 9 then
 color = gemMsg.colorSorcerer[math.random(1,#gemMsg.colorMasterSorcerer)]
elseif voc == 10 then
 color = gemMsg.colorDruid[math.random(1,#gemMsg.colorElderDruid)]
elseif voc == 11 then
 color = gemMsg.colorPaladin[math.random(1,#gemMsg.colorRoyalPaladin)]
elseif voc == 12 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[i], 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

 

gems = {
id = {2156, 2155, 2158, 2154, 2156, 2155, 2158, 2154},
storage = {5001, 5002, 5003, 5004, 5005, 5006, 5007, 5008},
interval = {750, 750, 750, 750, 750, 750, 750, 750}, -- Intervalo dos efeitos
}
gemMsg = {
rnd = {"´ .	,", ".	´ ,", "`  .  ,", ",	` ."},
colorDruid = {30,215},
colorSorcerer = {180,200},
colorPaladin = {251,10},
colorKnight = {204,212},
colorElderDruid = {30,215},
colorMasterSorcerer = {180,200},
colorRoyalPaladin = {251,10},
colorEliteKnight = {204,212}
}

}

 

Pasta CreatureScripts {

 

abra o arquivo login.lua, e antes do ultimo Return TRUE adicione isso:

if (vip.hasVip(cid) == TRUE) then
setPlayerStorageValue(cid, gems.storage[getPlayerVocation(cid)], 1)
sendGemEffect(cid, gems.storage[getPlayerVocation(cid)], 750)
end

}

Edited by Sofft
  • 5 months later...

poo, to dando use na gema e nao ta funfando, até pede lvl 200.. mais n ta funfando. tb pra comprar n funfou, fiz direitinho pa.. estranho isso.. preciso desse script aqui no meu ot.. n sei pq n ta funfando, e por incrivel que pareça nao tem nenhum bug no distro!

  • 7 years later...
×
×
  • Create New...