Postado Setembro 3, 2014 10 anos Olá pessoal, como eu não tinha nada pra fazer resolvi criar este sistema que será bem útil para usar como premiações.Como funciona? - Simplesmente você clica em um item chamado ticket medal e em seguida você receberá uma quantia em medalhas mas esta quantia será aleatória.Tabela de porcentagem abaixo : 49% == chances de cair nada. 20% == chances de cair 3 medalhas. 15% == chances de cair 5 medalhas. 10% == chances de cair 7 medalhas. 5% == chances de cair 10 medalhas. 1% == chances de cair 25 medalhas. vamos instalar o sistema [..] 1º - execute este código em sua database : ALTER TABLE `players` ADD medals INT(11) NOT NULL DEFAULT 0; 2º - crie um arquivo lua chamado 016-ticket na pasta data/lib e insira o seguinte código : --[[ functions by Ladyazaleia with love. ]]-- function getPlayerMedals(cid) -- function get medals. local qr = db.getResult("SELECT `medals` FROM `players` WHERE `id`= "..getPlayerGUID(cid)..";") medals = qr:getDataInt("medals", getPlayerGUID(cid)) if medals < 0 then medals = 0 end return medals end function doPlayerRemoveMedals(cid, count) -- function remove medals. if getPlayerMedals(cid) < count then return false else return db.query("UPDATE `players` SET `medals` = "..getPlayerMedals(cid)-count.." WHERE `players`.`id`= "..getPlayerGUID(cid)..";") end return true end function getTableWild() -- function get percent in randomtable. tablewild = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -- 49 % 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, -- 20 % 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, -- 15 % 7,7,7,7,7,7,7,7,7,7, -- 10 % 10,10,10,10,10, -- 5 % 25, -- 1 % } return tablewild end 3º - abra o seu items.xml e adicione esta tag la no final : <item id="12427" article="a" name="ticket medal" plural="ticket medals"> <attribute key="weight" value="10" /> <attribute key="description" value="ticket medal is an item that when used will become worthless random medals that can be used to purchase items." /> </item> 4º - abra o seu actions.xml e insira esta tag : <action itemid="12427" event="script" value="ticket.lua"/> 5º - crie um arquivo lua chamado ticket na pasta data/actions/scripts e insira o seguinte código : --[[ script by Ladyazaleia with love. ]]-- function onUse(cid, item, fromPosition, itemEx, toPosition) rand = math.random(1, #getTableWild()) query = 'UPDATE `players` SET `medals` = '..getPlayerMedals(cid)+getTableWild()[rand]..' WHERE `players`.`id`= '..getPlayerGUID(cid)..';' if doPlayerRemoveItem(cid, 12427, 1) then db.query(query) doSendMagicEffect(getThingPos(cid), 13) doPlayerPopupFYI(cid, 'You received : ['..getTableWild()[rand]..'] medal coins.\n\nTo learn more about the system, type /medals.') end return true end 6º - abra o seu talkactions.xml e adicione esta tag la no final : <talkaction words="!medals;/medals" event="script" value="ticket.lua"/> 7º - crie um arquivo lua chamado ticket na pasta data/talkactions/scripts e insira o seguinte código : --[[ script by Ladyazaleia with love. ]]-- function onSay(cid) doPlayerPopupFYI(cid, 'Ticket medal is an item that promises to present you with medals\nfor you to purchase items available in the store medals.\n\nYou have ['..getPlayerMedals(cid)..'] medals coins.') return true end Observações : Caso você queira mudar as porcentagens, checar o arquivo 016-ticket.lua na pasta data/lib e fazer as alterações na tabela, só faça se souber. Se o item 12427 já estiver registrado, mude-o! mas se não estiver registrado meu conselho é : "deixe tudo do jeito que está". Você poderá usar as funções : getPlayerMedals(cid) para pegar o valor de medalhas do player & doPlayerRemoveMedals(cid, count) para remover uma quantidade de medalhas do player, count é a quantidade. Desculpe pela tabela constrangedora, só consegui porcentar assim. exemplo de uso : function onSay(cid, words, param) local count = 10 if doPlayerRemoveMedals(cid, count) then doPlayerAddItem(cid, 2160, 100) doSendMagicEffect(getThingPos(cid), 12) else doPlayerPopupFYI(cid, 'Você não possui '..count..' medal coins.') end return true end este exemplo faz com que o player possa comprar 100 crystal coins se ele tiver 10 medal coins. até mais pessoal, um grande abraço e se gostou, rep+ créditos : Halls Santos or Ladyazaleia. Editado Setembro 5, 2014 10 anos por HallsSantos (veja o histórico de edições)
Postado Setembro 4, 2014 10 anos Muito foda *------* nota 10 man Baixe um tibia loader de confiável e de um lugar confiável, otserv list. <a href="http://otservlist.org/ipc/327721">DownloadTibia Loader!</a>
Postado Setembro 4, 2014 10 anos gostei, no início achei que daria itens aleatórios, mas é como se fosse um status. reputado Ot Design: https://discord.gg/VgtVRNmCD7
Postado Setembro 4, 2014 10 anos Autor gostei, no início achei que daria itens aleatórios, mas é como se fosse um status. reputado Obrigado man, fico feliz com a sua opinião, sou seu fã! *-* Muito foda *------* nota 10 man Haha! valeu parça
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.