Roll System
(essa script foi testado no alissow ots)
Comentario:
Bem, eu irei postar aqui uma action que funciona da seguinte maneira: o player compra as apostas no NPC, no caso gold ingots e gold nuggets, cada gold nugget vale 10k e cada ingot 50k, apos adquirida a aposta, o player deve colocá-la no ArrowSlot (onde ficam os bolts), feito isso ele puxa a lavanca e o dado é jogado, se ele tirar um 6 ele ganha 4 vezes o que ele apostou, cada vez que ele vai jogar é removido somente 1 item para ser a aposta, ou seja, não tem como ele apostar mais de 1 gold ingot ou nugget, depois de jogar, o player pega o que recebeu e troca no mesmo NPC para receber seu prêmio em dinheiro (Eu arrumei os preços de venda menores do que os de compra para se fazer um balanceamento nos prêmios porque senão o player levaria muita vantagem).
Então vamos ao Script:
Em data/actions/actions.xml:
<action actionid="7655" event="script" value="rolldice.lua"/>
(Eu usei o actionid 7655 na lavanca mais pode alterar a gosto.)
Com seu Map Editor crie um local parecido com este (não precisa ser idêntico, fique a vontade para alterar):
Em data/actions/scripts crie um arquivo rolldice.lua e nele cole:
function onUse(cid, item, frompos, item2, topos)
Bet = getPlayerSlotItem(cid, 10)
if Bet.itemid == 2157 then
Type = " gold nugget"
elseif Bet.itemid == 9971 then
Type = " gold ingot"
else
doPlayerSendTextMessage(cid, 25, "[Roll] Ponha seus gold nuggets ou ingots no slot Arrow para serem sua aposta.")
return 0
end
local dicepos = {x=30, y=744, z=7}
local player = getPlayerPosition(cid)
Roll = math.random(1, 6)
if Roll == 1 then
doSendAnimatedText(player, 'Number 1', 180)
doPlayerRemoveItem(cid,Bet.itemid,1)
doSendMagicEffect(dicepos, 26)
doCreateItem(5792, 1, dicepos)
doPlayerSendTextMessage(cid, 25, "[Roll] Voce perdeu.")
elseif Roll == 2 then
doSendAnimatedText(player, 'Number 2', 180)
doPlayerRemoveItem(cid,Bet.itemid,1)
doSendMagicEffect(dicepos, 26)
doCreateItem(5793, 1, dicepos)
doPlayerSendTextMessage(cid, 25, "[Roll] Voce perdeu.")
elseif Roll == 3 then
doSendAnimatedText(player, 'Number 3', 180)
doPlayerRemoveItem(cid,Bet.itemid,1)
doSendMagicEffect(dicepos, 26)
doCreateItem(5794, 1, dicepos)
doPlayerSendTextMessage(cid, 25, "[Roll] Voce perdeu.")
elseif Roll == 4 then
doSendAnimatedText(player, 'Number 4', 180)
doPlayerRemoveItem(cid,Bet.itemid,1)
doSendMagicEffect(dicepos, 26)
doCreateItem(5795, 1, dicepos)
doPlayerSendTextMessage(cid, 25, "[Roll] Voce perdeu.")
elseif Roll == 5 then
doSendAnimatedText(player, 'Number 5', 180)
doPlayerRemoveItem(cid,Bet.itemid,1)
doSendMagicEffect(dicepos, 26)
doCreateItem(5796, 1, dicepos)
doPlayerSendTextMessage(cid, 25, "[Roll] Voce perdeu.")
else
doSendAnimatedText(player, 'Number 6', 30)
doSendMagicEffect(dicepos, 26)
doCreateItem(5797, 1, dicepos)
doPlayerSendTextMessage(cid, 25, "[Roll] Voce ganhou! Premio: 4" .. Type .. "s.")
doSendMagicEffect(player, 27)
doPlayerAddItem(cid, Bet.itemid, 4)
end
end
Legenda:
Negrito: Gold Nugget ID
Itálico: Gold Ingot ID.
sublinhado Posição em que o dado será lançado. (Onde está o dado na imagem)
Vamos ao NPC:
Em data/npc crie um arquivo Robert.xml e cole:
<?xml version="1.0" encoding="UTF-8"?><npc name="Robert" script="data/npc/scripts/robert.lua" walkinterval="5000" floorchange="0" access="5" level="1" maglevel="1">
<health now="150" max="150"/>
<look type="328" head="78" body="0" legs="0" feet="114" corpse="2212"/>
<parameters>
<parameter key="message_greet" value="Bem vindo |PLAYERNAME|. Eu vendo e compro {gold nuggets} e {gold ingots} para voce fazer suas apostas e receber o seu dinheiro. Para saber as regras e informacoes sobre o Cassino use o comando {!cassino}." />
<parameter key="message_needmoremoney" value="Voce nao tem dinheiro."/>
<parameter key="message_decline" value="|TOTALCOST| Humpf!"/>
</parameters>
</npc>
Em data/npc/scripts crie o arquivo robert.lua e cole:
local keywordHandler = KeywordHandler:new()local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
function thinkCallback(cid)
local rand = math.random(1,100)
if rand == 1 then
selfSay('Compro e vendo gold nuggets e gold ingots.')
end
return true
end
function greetCallback(cid)
return true
end
local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
shopModule:addSellableItem({'gold nugget', 'gold nugget'}, 2157, 10000, 'gold nugget')
shopModule:addSellableItem({'gold ingot', 'gold ingot'}, 9971, 50000, 'gold ingot')
shopModule:addBuyableItem({'gold nugget', 'gold nugget'}, 2157, 11000, 'gold nugget')
shopModule:addBuyableItem({'gold ingot', 'gold ingot'}, 9971, 55000, 'gold ingot')
npcHandler:setCallback(CALLBACK_ONTHINK, thinkCallback)
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:addModule(FocusModule:new())
Esse será o NPC em que se compram as apostas e as trocam pelo prêmio em dinheiro.
Feito isso basta adicionar o NPC ao mapa e pronto!
Divirtam-se.
Crédito:
Criador: ChesterB
(outro forum)