Bela indentação.
- Forums
- OTServ
- Recursos
- Scripting
- Actions e Talkactions
- [NEW] Dice System
Edited Abril 21 by Kyou
info
Group: Herói
Joined: 14/12/10
Posts: 3.6k
Reputation: +846
Gender: 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
Group: Banidos
Joined: 11/01/13
Posts: 576
Reputation: +109
Tibia Character: 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
Group: Campones
Joined: 30/04/13
Posts: 74
Reputation: +3
Gender: Masculino
Tibia Character: Riverwood

Roksas, teria algum jeito de colocar para o jogador só poder o dado de tempo em tempo?
info
Group: Herói
Joined: 14/12/10
Posts: 3.6k
Reputation: +846
Gender: 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.
Edited Maio 25 by Roksas
info
Group: Campones
Joined: 30/04/13
Posts: 74
Reputation: +3
Gender: Masculino
Tibia Character: 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
Group: Herói
Joined: 14/12/10
Posts: 3.6k
Reputation: +846
Gender: 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..
Edited Maio 30 by skynet2
info
Group: Herói
Joined: 14/12/10
Posts: 3.6k
Reputation: +846
Gender: 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!
Edited Junho 4 by skynet2






info
Group: Banidos
Joined: 11/01/13
Posts: 576
Reputation: +109
Tibia Character: Darashia del Shee
Ou, melhora a identação ai roksas, vlw
Edited Abril 21 by Gears