Ir para conteúdo
  • Cadastre-se

[8.6][Talk] Reedem Codes [Sqlite][+Beta]


Posts Recomendados

Descrição:

 

2ZoDMkC.jpg

 

M4Ki9M9.jpg

 

 

 

 

Execute no banco de dados:

 

CREATE TABLE resgate_codes ( 
    id             INTEGER         NOT NULL,
    code           VARCHAR( 255 )  NOT NULL,
    items          VARCHAR( 500 )  NOT NULL,
    premium_points INT             NOT NULL
                                   DEFAULT 0,
    premium_days   INT             NOT NULL
                                   DEFAULT 0,
    PRIMARY KEY ( id ) 
);

 

 

Adicione na sua lib:

 

function getPremiumPoints(cid)
	local query = db.getResult("SELECT `premium_points` FROM `accounts` WHERE `id` = "..getPlayerAccountId(cid))
	return query:getDataInt("premium_points") <= 0 and 0 or query:getDataInt("premium_points")
end
function setPremiumPoints(cid, amount)
	return db.executeQuery("UPDATE `accounts` SET `premium_points` = "..amount.." WHERE `id` = "..getPlayerAccountId(cid))
end
function getCodesFromServe(p)
	local ret = db.getResult("SELECT `id` FROM `resgate_codes` WHERE `code` = "..db.escapeString(p))
	return ret:getID() ~= -1 and ret:getDataInt("id") or 0
end

 

 

Data/Talkactions

 

createcode.lua

function onSay(cid, words, param, channel)
	local param = param:lower()
	if param == "" or not param then doPlayerSendCancel(cid, "insira um codigo novo.") return true end
	local code = getCodesFromServe(param) 
	if code ~= 0 then
		doPlayerSendCancel(cid, "Your code ["..param.."] already exist.") return true
	end	
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your code ["..param.."] create sucefull, now you can add items, premium days or premium points.")
	return db.executeQuery("INSERT INTO `resgate_codes` (`code`, `items`, `premium_points`, `premium_days`) VALUES ('".. param .."', '{}', '0', '0');")
end

 

addcode.lua

function onSay(cid, words, param, channel)
	local t = string.explode(param:lower(), ",")
	if (param == "") then
		doPlayerPopupFYI(cid, "[Redeem Code System]\n\nHow Use Command?\n\nTo add rewards from code enter: /addcode,type\n\n[Types:]\n\nItems\nPremium\nPoints\n\n\Exemples:\n\n/addcode items,crystal coin, 100 --To add item from code, use item name, amount.\n\n/addcode premium,10 -- To set 10 premium days in code\n\n/addcode points,20 -- To set 20 premium points in code") return true
	end
	local code = getCodesFromServe(t[1]) 
	if code == 0 then
		doPlayerSendCancel(cid, "Code ["..t[1].."] does exist.") return true
	end
	if isInArray({"items","item","itens","iten"}, t[2]) then
		if tonumber(t[4]) ~= nil and tostring(t[3]) ~= nil then
			local itemid, amount = getItemIdByName(t[3], false), tonumber(t[4])
			if not itemid then
				doPlayerSendCancel(cid, "Sorry, this item does not exist.") return true
			end
			local d = db.getResult("SELECT `items` FROM `resgate_codes` WHERE `id` = "..code):getDataString("items")
			local y,n = {},0 
			for a,b in d:gmatch("(%d+),(%d+)") do
			n = n + 1
			y[n] = {a,b}
			end
			table.insert(y, {itemid, amount})
	local str = "{"
	for i, x in pairs(y) do
		str = str.."{".. x[1]  .. "," .. x[2] .. "}"
		if i ~= table.maxn(y) then str = str .. ',' else str = str .. '}' end
	end
	db.executeQuery("UPDATE `resgate_codes` SET `items` = "..db.escapeString(str).." WHERE `id` = "..code)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You Added "..amount.." "..t[3].." from code ["..t[1].."].")
            return true
		else
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need to enter the item name, amount.")return true
		end
	elseif isInArray({"pa","premium","premmy","premiun"}, t[2]) then
		local min, max = 1, 999
		if not tonumber(t[3]) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, only number.") return true
		elseif tonumber(t[3]) < min or tonumber(t[3]) > max then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, Min "..min.." and Max "..max.." points.") return true
		end
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Now the code receives total "..t[3].." premium days.")
		db.executeQuery("UPDATE `resgate_codes` SET `premium_days` = "..t[3].." WHERE `id` = "..code) return true
	elseif isInArray({"points","pp","point","pontos"}, t[2]) then
		local min, max = 1, 999
		if not tonumber(t[3]) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, only number.") return true
		elseif tonumber(t[3]) < min or tonumber(t[3]) > max then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, Min "..min.." and Max "..max.." points.") return true
		end
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Now the code receives total "..t[3].." premium days.")
		db.executeQuery("UPDATE `resgate_codes` SET `premium_points` = "..t[3].." WHERE `id` = "..code) return true
	end
	return true
end

 

codes.lua

function onSay(cid, words, param, channel)
	local param,str = param:lower(),''
	if not param then return true end
	local code = getCodesFromServe(param) 
	if code == 0 then
		doPlayerSendCancel(cid, "Your code ["..param.."] does exist or Already used.") return true
	end
	local info = db.getResult("SELECT * FROM `resgate_codes` WHERE `id` = "..code)
	local d,k,p = info:getDataString("items"),info:getDataInt("premium_points"),info:getDataInt("premium_days")
	local t,n = {},0 
	for a,b in d:gmatch("(%d+),(%d+)") do
		n = n + 1
		t[n] = {a,b}
	end
	if #t > 0 then
		local backpack = doPlayerAddItem(cid, 1999, 1)
		for _, i_i in ipairs(t) do
			local item, amount = i_i[1],i_i[2]
			if isItemStackable(item) or amount == 1 then
				doAddContainerItem(backpack, item, amount)
			else
				for i = 1, amount do
					doAddContainerItem(backpack, item, 1)
				end
			end
		end
		str = str.."".. (str == "" and "" or ", ") ..""..getItemsFromList(t) 
	end
	if p > 0 then
		doPlayerAddPremiumDays(cid, p)
		str = str.."".. (str == "" and "" or ", ") .." "..p.." premium days" 
	end
		if k > 0 then
		local total = (getPremiumPoints(cid)+k)
		setPremiumPoints(cid, total)
		str = str.."".. (str == "" and "" or ", ") .." "..k.." premium points" 
	end
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You successfully redeemed the code ["..param.."]! Reward(s):\n"..str)
	return db.executeQuery("DELETE FROM `resgate_codes` WHERE `id` = "..code)
end

 

talkactions.xml

<talkaction words="/resgatecode;!resgatecode" event="script" value="codes.lua"/>
<talkaction words="!createcode;/createcode" access="5" event="script" value="createcode.lua"/>
<talkaction words="!addcode;/addcode" access="5" event="script" value="addcode.lua"/>

 

 

Observações:

 

* Testado somente em servidores com SQLITE

* Futuramente estarei acrescentando e modificando o código para melhorias

* Em breve um comando especial "/generate codes" para gerar códigos com itens randômicos(com chances)

* Quem tiver alguma ideia ou querer passar para servidores com site estarei dando auxilia no tópico.

vodkart_logo.png

[*Ninguém será digno do sucesso se não usar suas derrotas para conquistá-lo.*]

 

DISCORDvodkart#6090

 

Link para o post
Compartilhar em outros sites
Agora, PsyMcKenzie disse:

Achei bem interessante, mas não consegui entender direito o objetivo!
Mas parabéns, como sempre ótimos sistemas!

 

Sistema para distribuir como recompensar em alguns eventos, sites, facebook, etc...

 

o GOD cria um comando e vai adicionando rewards, ai o player só vai lá e resgata o código, igual tem em vários jogos por aí.

vodkart_logo.png

[*Ninguém será digno do sucesso se não usar suas derrotas para conquistá-lo.*]

 

DISCORDvodkart#6090

 

Link para o post
Compartilhar em outros sites
2 minutos atrás, Vodkart disse:

 

Sistema para distribuir como recompensar em alguns eventos, sites, facebook, etc...

 

o GOD cria um comando e vai adicionando rewards, ai o player só vai lá e resgata o código, igual tem em vários jogos por aí.

 

Ahh, agora eu entendi!
Que foda cara!!

Link para o post
Compartilhar em outros sites

Muito Bom! Já pensei em algo do tipo, mas tinha um limite x de pessoas que podiam gerar o código.

ou, gerava um código automático quando a pessoa apertasse em um link (ou botão) e aparecia um código(único) para usar e receber o premio... assim evitaria que players passasse o código sem precisar realizar tal ação... enfim, muito bom... fica como uma ideia kk

Scriptszinhos:

 

Não abandone seu tópico, quando você tiver a dúvida resolvida sozinho tente ensinar aos outros como resolve-la (você pode não ser o único com o problema) e quando ela for resolvida por outra pessoa não se esqueça de marcar como melhor resposta e deixar o gostei.

Link para o post
Compartilhar em outros sites
11 horas atrás, pablobion disse:

Muito Bom! Já pensei em algo do tipo, mas tinha um limite x de pessoas que podiam gerar o código.

ou, gerava um código automático quando a pessoa apertasse em um link (ou botão) e aparecia um código(único) para usar e receber o premio... assim evitaria que players passasse o código sem precisar realizar tal ação... enfim, muito bom... fica como uma ideia kk

 

Mas é logico que tem limite de uso, você usa o código só 1x e ele é deletado do servidor.

 

Como já disse, posso criar um comando que gere códigos com itens e prêmios diferentes(com chance)

vodkart_logo.png

[*Ninguém será digno do sucesso se não usar suas derrotas para conquistá-lo.*]

 

DISCORDvodkart#6090

 

Link para o post
Compartilhar em outros sites

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.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

  • Conteúdo Similar

    • Por Kiman174
      GRIMHAVEN SEASON 4
      LAUNCHING APRIL 18TH 19:00 CEST
       
      Join our community and stay up to date:
      Official Discord Server
       
       
       
       
       
      Step into a world where passion meets innovation—welcome to Grimhaven MMORPG! Born from a heartfelt passion project, Grimhaven has evolved into an extraordinary realm where every pixel on our meticulously crafted Real Map tells a story. Leveraging the classic legacy of version 8.6 and elevated by inventive custom content, our server transcends traditional gameplay, inviting you into a living, breathing adventure at every turn.
       
       
      Explore sprawling landscapes, battle formidable foes, and uncover hidden lore as you journey through environments that blend classic mechanics with innovative systems. Every corner of Grimhaven pulses with life and mystery, inviting you to forge alliances, challenge epic quests, and redefine what you thought possible in an open Tibia server. With each update, our dedicated team pushes the envelope, ensuring that every raid, dungeon, and social encounter feels fresh and electrifying.
       
       
      Whether you're a seasoned adventurer or new to the realm, Grimhaven offers a thrilling escape into a world where the spirit of discovery and the thrill of combat come together in perfect harmony. Embrace the extraordinary—your adventure begins now in Grimhaven MMORPG!
       
       
      What Makes Grimhaven Stand Out?
       
      With over thousands of hours of development and 4000+ commits, Grimhaven stands out with its unique blend of classic and innovative MMORPG features. Built on an authentic Real Map with 8.6 mechanics and expanded with carefully designed custom content, the experience is unmatched. The server offers rates starting from 12x, stunning HD visuals, and intricately scripted quests that immerse you in a dynamic narrative. From challenging custom raid bosses to a refined item system inspired by classic action RPGs, every element is thoughtfully crafted to deliver an engaging and ever-evolving adventure, all backed by a dedicated team ensuring a top-tier gaming experience.
       
       
       
      Custom Zones :
      Explore meticulously designed zones that promise unique challenges and unparalleled rewards.
       

       
       
       
      Unique Randomly Generated Dungeons :
      As if that's not enough, brace yourselves for our unique dungeons. Each one is randomly generated, ensuring that no adventure is ever the same. The thrill of exploring the unknown awaits you in every twist and turn.
       


       

       
       


       
       
       
      Scripted and Mechanically Challenging Quests:
      Immerse yourself in intricately designed quests that push your strategic prowess and combat skills, all brought to life by the remarkable creativity of our quest designer and mapper.
       

       

       


       
       
      Mighty Bosses:
      Confront colossal adversaries, each boasting unique abilities and intricate mechanics that challenge your tactics and teamwork, turning every encounter into an unforgettable battle.
       


       
       
       
      Ancient and Mythic Monsters:
      Encounter legendary beasts, ancient guardians, and mythical creatures that not only test your skills and courage but also offer tougher challenges, richer loot drops, and enhanced experience rewards.
       

       
       
       
      Magical Attributes & Crafting:
      Discover a world of enchantment where magical items not only have a chance to drop in the wild, but can also be expertly crafted to bestow unique and powerful attributes on your gear.
       
       

       

       
       
       
      Custom Events :
      We keep the excitement rolling with unique, server-wide events that'll keep you on the edge of your seat. Expect the unexpected!
       
       



       
       
       
      This glimpse barely scratches the surface—there's a TON more content that would overwhelm this thread! To dive even deeper, visit our official wiki at Grimhaven Wiki (https://wiki.grimhaven.net) and create your account today at Latestnews - Grimhaven (https://www.grimhaven.net/) .   
       
      Gear up for an unforgettable adventure starting April 18th 19:00 CEST.
      Dive into a realm of epic rewards, heart-pounding quests, and intense PVP battles where you'll test your skills against others.
      Join a vibrant community of adventurers, embrace the thrill of discovery, and answer the call to glory on the battlefield!
    • Por Veigh
      IP: HYPEOT.COM (Versão 8.60) Por que jogar no HYPEOT? Confira nossos diferenciais: Sistema de Reset 180+ Montarias 65+ Outfits Sistema de Stage Sistema de Pesca Sistema de Refinamento Sistema de Aura Sistema de Mineração Sistema de Woodcut Sistema de Dungeons Sistema de Survival Mais de 30 Bosses de Alavancas +10 Eventos Automáticos Mais de 5 anos online com apenas 2 resets. Agora estamos de volta com força total desde 05/12! O que você está esperando? Junte-se à aventura e faça parte dessa jornada épica! Conecte-se agora mesmo e não fique de fora!
    • Por Thiagodsw
      Olá galera do Tibia King !
      Venho por meio deste tópico, publicar a ultima versão do meu servidor derivado de Tibia NTO Battle.
       
      deixei para brincarem e verem sistemas, as sources não disponibilizarei nem o site. afinal é um projeto que fiz com carinho e está a venda as sources. Thogo#9713
       
      O que tem de diferente no NTO Battle ? 
       
      Aura System e Wings Healthbar Monster Bar Healthbar vocation Sistema Raridade Shaders Dungeons e Tasks Game Shop Entre outros Veja algumas Imagens !
       
       
      O que tem nesse Pacote de Arquivos NTO Battle? 
       
      Datapack mais recente e completa do servidor. ( compilada pra windows Client Compilado SQL
      ACC GOD - god/god


      QUALQUER MSG NO DISCORD Thogo#9713
      -source client e otserv e site.
       
      DOWNLOAD  &  SCAN


       
      Client:
      https://mega.nz/file/hbgnSDRJ#xQT-qQHWLUV2Dn8jalwMGblCWnmL0_s3rZfqbxO7znw
      Server:
      https://mega.nz/file/sSZXlZ6a#gow-Db6diNVrnnPIH7qyBqP8WmVLFxWy85-yub_f32Y


       
      Scan
      Client
      https://www.virustotal.com/gui/file/86da72135d75d826c2665bb572084c30288eea843c2cfe2f7a405cfe1ea2f59c/detection
      Servidor
      https://www.virustotal.com/gui/file/cfa4d83c8b6c12fa0daf28cefd6762a053aee7245e6be8f5c02594825a2e2c1e?nocache=1
    • Por Ocrux
      Procuro equipe pra abrir um OT Rookgaard. 
      To terminando o mapa, acho que ta bonito e pouco grandinho.
       
      RookSmart
      Continente único, na base de Rookgaard & com cidades de referencias as do Tibia.
      Por hora tem 4 cidades Prontas: Rookgaard, Carlore, Liadahar e Akuahmun.
      Estou terminando a 5ª cidade: Dahlia (de gelo) & já to achando uma boa ideia colocar Roshamuul (já providenciei).
      O servidor ta em TFS 0.4, com sources & na versão 8.6 (creio eu que parado no tempo).
       
      Quem quiser formar uma equipe pra botar on & terminar o que falta, whatsapp: 15 935001689

      Mapa Mundi
       
       
    • Por Fir3element
      Reporte qualquer bug encontrado.
       
      - Mudanças:
      * opcode adicionado
      * Monstros andando em cima de corpos
      * War system arrumado
      * Anti-divulgação melhorado
      * Cast system arrumado
      * Crash bugs arrumados
      * Adicionado exhaust ao comprar/vender items
      * Account manager com opção para cidades
      * /ghost stacking arrumado
      * !disband arrumado
      * Erros no linux arrumado
      * Aleta som arrumado
      * Bug nos rings arrumado
      * Adicionado suporte para Visual Studio
      * Remover battle ao entrar em PZ
      * Não pode jogar lixo em casas
      * Salt removido
       
      - Downloads:
      * Distro (x32): https://github.com/Fir3element/binaries/raw/master/x32-windows.zip
      * Distro (x64): https://github.com/Fir3element/binaries/raw/master/x64-windows.zip
      * Requisitos: Microsoft Visual C++ Redistributable Package
      * Source + datapack: https://github.com/Fir3element/3777/archive/refs/heads/main.zip
       
      - Scans:
      * Distro (x32): https://virustotal.com/pt/file/6683a91273b848a39ac21288da9d3abde341436744d6846e35a477c8e7c8f5f7/analysis/1480675335/
      * Distro (x64): https://virustotal.com/pt/file/21028857bb1124f19e0353e7f5775c8f66afc4f87f29df9cf4ab8ca1a046b816/analysis/1480675394/
      * Source + datapack: https://virustotal.com/pt/file/3761b48ee19f3f540d4c4a48c35c73c89a85615876307073494b1dcfed464d36/analysis/1480675473/
×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo