RO

[NEW] Dice System

Por Roksas, 20 de abr. de 2013 em Actions e Talkactions

action
script
27
4.3k
GearsG
21 de abril de 2013 às 15:22

Ou, melhora a identação ai roksas, vlw

Editado Abril 21 por Gears

KyouK
21 de abril de 2013 às 15:29

Bela indentação.

Editado Abril 21 por Kyou

RoksasR
21 de abril de 2013 às 15:30

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 :)

GearsG
21 de abril de 2013 às 17:25

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.

1 mês depois...
25 de maio de 2013 às 03:13

Roksas, teria algum jeito de colocar para o jogador só poder o dado de tempo em tempo?

RoksasR
25 de maio de 2013 às 09:35

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

25 de maio de 2013 às 16:36

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.

RoksasR
25 de maio de 2013 às 16:54

Exato, não foi nada, qualquer coisa só falar :)

ThaynaT
30 de maio de 2013 às 01:51

Estou levando o seguinte erro:

 

errowg.png

 

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

RoksasR
03 de junho de 2013 às 16:08

Isso aí eh porque você não fechou corretamente alguma tag no actions.xml, poste ele aqui anexado ou por spoiler, obrigado.

ThaynaT
04 de junho de 2013 às 10:58

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

RoksasR
04 de junho de 2013 às 16:21

rsrs, boa