Bela indentação.
- Fórum
- OTServ
- Recursos
- Scripting
- Actions e Talkactions
- [NEW] Dice System
Editado Abril 21 por Kyou
info
Grupo: Herói
Registrado: 14/12/10
Posts: 3.6k
Reputação: +846
Gênero: Masculino

Muitos me questionam pelo fato de como eu faço a identação. Faço deste jeito pois assim que acustumei, desde que li o Tutorial do SkyenHasus ![]()
info
Grupo: Banidos
Registrado: 11/01/13
Posts: 576
Reputação: +109
Char no Tibia: Darashia del Shee

Muitos me questionam pelo fato de como eu faço a identação. Faço deste jeito pois assim que acustumei, desde que li o Tutorial do SkyenHasus
Na verdade, ele ensinou de um jeito, e você identa de outro.
info
Grupo: Campones
Registrado: 30/04/13
Posts: 74
Reputação: +3
Gênero: Masculino
Char no Tibia: Riverwood

Roksas, teria algum jeito de colocar para o jogador só poder o dado de tempo em tempo?
info
Grupo: Herói
Registrado: 14/12/10
Posts: 3.6k
Reputação: +846
Gênero: Masculino

Acho que não haveria necessidade pois ele não é infinito, mas aqui está:
function onUse(cid, item, item2)
local timeAgain = 10
local cfg = {
listas = {
chance100 = {2494, 2492, 2646}, -- Demon Armor, DSA, Golden Boots
chance75 = {2400, 2472, 2470}, -- SOV, MPA, Golden Legs
chance50 = {2466, 2514, 2640}, -- Golden Armor, MMS, Soft Boots
chance30 = {2487, 2498, 2491}, -- Crown Armor, RH, Crown Helmet
chance10 = {4, 8, 10, 30, 50, 80}, -- Crystal coins (40k, 80k, 100k...)
}
}
if getPlayerFreeCap(cid) < 150 then doPlayerSendCancel(cid, "Lack cap!") return true end
if getPlayerStorageValue(cid, 9039) > os.time() then
doPlayerSendTextMessage(cid, 20, "Você só pode usar o dice a cada "..timeAgain.." segundos.")
if math.random(100) <= 10 then
doPlayerAddItem(cid, 2160, cfg.listas.chance10[math.random(1, #cfg.listas.chance10)])
doCreatureSay(cid, "Rolled [Chance 10%]", TALKTYPE_ORANGE_1)
elseif math.random(100) > 10 or math.random(100) < 30 then
doPlayerAddItem(cid, cfg.listas.chance30[math.random(1, #cfg.listas.chance30)])
doCreatureSay(cid, "Rolled [Chance 30%]", TALKTYPE_ORANGE_1)
elseif math.random(100) > 30 or math.random(100) < 50 then
doPlayerAddItem(cid, cfg.listas.chance50[math.random(1, #cfg.listas.chance50)])
doCreatureSay(cid, "Rolled [Chance 50%]", TALKTYPE_ORANGE_1)
elseif math.random(100) > 50 or math.random(100) < 75 then
doPlayerAddItem(cid, cfg.listas.chance75[math.random(1, #cfg.listas.chance75)])
doCreatureSay(cid, "Rolled [Chance 75%]", TALKTYPE_ORANGE_1)
elseif math.random(100) > 75 or math.random(100) < 100 then
doPlayerAddItem(cid, cfg.listas.chance100[math.random(1, #cfg.listas.chance100)])
doCreatureSay(cid, "Rolled [Chance 100%]", TALKTYPE_ORANGE_1)
end
setPlayerStorageValue(cid, 9039, os.time() + timeAgain)
doSendMagicEffect(getCreaturePosition(cid), 26)
doRemoveItem(item.uid, 1)
return true
end
Só configurar como desejar. Na segunda linha do código você configura a cada quantos segundos pode utiizar novamente.
Editado Maio 25 por Roksas
info
Grupo: Campones
Registrado: 30/04/13
Posts: 74
Reputação: +3
Gênero: Masculino
Char no Tibia: Riverwood

Acho que não haveria necessidade pois ele não é infinito, mas aqui está:
function onUse(cid, item, item2) local timeAgain = 10 local cfg = { listas = { chance100 = {2494, 2492, 2646}, -- Demon Armor, DSA, Golden Boots chance75 = {2400, 2472, 2470}, -- SOV, MPA, Golden Legs chance50 = {2466, 2514, 2640}, -- Golden Armor, MMS, Soft Boots chance30 = {2487, 2498, 2491}, -- Crown Armor, RH, Crown Helmet chance10 = {4, 8, 10, 30, 50, 80}, -- Crystal coins (40k, 80k, 100k...) } } if getPlayerFreeCap(cid) < 150 then doPlayerSendCancel(cid, "Lack cap!") return true end if getPlayerStorageValue(cid, 9039) > os.time() then doPlayerSendTextMessage(cid, 20, "Você só pode usar o dice a cada "..timeAgain.." segundos.") if math.random(100) <= 10 then doPlayerAddItem(cid, 2160, cfg.listas.chance10[math.random(1, #cfg.listas.chance10)]) doCreatureSay(cid, "Rolled [Chance 10%]", TALKTYPE_ORANGE_1) elseif math.random(100) > 10 or math.random(100) < 30 then doPlayerAddItem(cid, cfg.listas.chance30[math.random(1, #cfg.listas.chance30)]) doCreatureSay(cid, "Rolled [Chance 30%]", TALKTYPE_ORANGE_1) elseif math.random(100) > 30 or math.random(100) < 50 then doPlayerAddItem(cid, cfg.listas.chance50[math.random(1, #cfg.listas.chance50)]) doCreatureSay(cid, "Rolled [Chance 50%]", TALKTYPE_ORANGE_1) elseif math.random(100) > 50 or math.random(100) < 75 then doPlayerAddItem(cid, cfg.listas.chance75[math.random(1, #cfg.listas.chance75)]) doCreatureSay(cid, "Rolled [Chance 75%]", TALKTYPE_ORANGE_1) elseif math.random(100) > 75 or math.random(100) < 100 then doPlayerAddItem(cid, cfg.listas.chance100[math.random(1, #cfg.listas.chance100)]) doCreatureSay(cid, "Rolled [Chance 100%]", TALKTYPE_ORANGE_1) end setPlayerStorageValue(cid, 9039, os.time() + timeAgain) doSendMagicEffect(getCreaturePosition(cid), 26) doRemoveItem(item.uid, 1) return true end
Só configurar como desejar. Na segunda linha do código você configura a cada quantos segundos pode utiizar novamente.
Eu não sabia que não era infinito, então usa uma vez e ele some? Muito obrigado por me passa o script do tempo, me ajudou muito.
info
Grupo: Herói
Registrado: 14/12/10
Posts: 3.6k
Reputação: +846
Gênero: Masculino

Exato, não foi nada, qualquer coisa só falar ![]()
Estou levando o seguinte erro:

um detalhe que eu tinha visto é que no meu item.xml
o dice estava assim:
<item fromid="5792" toid="5797" article="a" name="dice">
<attribute key="weight" value="200" />
e no actionid.xml também estava como fromid e toid..
Editado Maio 30 por skynet2
info
Grupo: Herói
Registrado: 14/12/10
Posts: 3.6k
Reputação: +846
Gênero: Masculino

Isso aí eh porque você não fechou corretamente alguma tag no actions.xml, poste ele aqui anexado ou por spoiler, obrigado.
Isso aí eh porque você não fechou corretamente alguma tag no actions.xml, poste ele aqui anexado ou por spoiler, obrigado.
Mas esse erro só da quando adiciono a tag:
<action itemid="5792" event="script" value="dice.lua"></action>
Alterei para:
<action itemid="5792" script="dice.lua" />
e funcionou!
Editado Junho 4 por skynet2






info
Grupo: Banidos
Registrado: 11/01/13
Posts: 576
Reputação: +109
Char no Tibia: Darashia del Shee
Ou, melhora a identação ai roksas, vlw
Editado Abril 21 por Gears