Aller au contenu
Top-Metin2.org - Vous êtes à la recherche d'un serveur Metin 2 ? ×
×
×
  • Créer...

[Système] Vote Coins Shop


herostar34

Messages recommandés

  • Retraité

Centre de Téléchargement

Hidden Content

    Give reaction to this post to see the hidden content.
( Interne )

Bonsoir à tous !

 

Citation

Un joueur ayant voté de nombreuses fois, obtient beaucoup de monnaies en retour.

Avec ces monnaies, il pourra accéder à un shop sur le jeu, sur lequel seront répertoriées les items qu'ils souhaitent acheter.

 

Rassurez vous, tout est fournit ! Le questlib.lua ( des lignes à copier dans le votre ) , le vote_shop.sql, ainsi que la quête /

 

 

A mettre dans le questlib.lua

function GetVoteCoins()
return mysql_query("SELECT vote_coins FROM account.account WHERE id = "..pc.get_account_id().." LIMIT 1;")[1][1]
end

function SetVoteCoins(sum)
if mysql_query("UPDATE account.account SET vote_coins = vote_coins+"..sum.." WHERE id = "..pc.get_account_id().." LIMIT 1;") then
	return true
else
	return false
end
end

function LoadVoteShopCat()
local a_b = {}
local query = mysql_query("SELECT kat, name FROM account.vote_shop_cat ORDER by kat;")
for a = 1, table.getn(query) do
	table.insert(a_b, query[a][2])
end
table.insert(a_b, "Abandon")
return a_b
end

function select2(tab,...)
arg.n = nil
if type(tab) ~= "table" and type(tab) == 'number' then
	table.insert(arg,1,tab)
	tab = arg
elseif type(tab) ~= "table" and type(tab) == 'string' then
	table.insert(arg,1,tab)
	table.insert(arg,1,8)
	tab = arg
elseif type(tab) == "table" and type(tab[1]) == 'string' then
	table.insert(tab,1,8)
end
local max = tab[1]; table.remove(tab,1)
local tablen,outputstr,outputcount,nextc,incit = table.getn(tab),"",0,0,0
table.foreach(tab,
	function(i,l)
		outputcount = outputcount + 1
		if outputcount == 1 then
			outputstr=outputstr..'sel = select("'..l..'"'
		elseif outputcount == max and tablen > outputcount+incit  then
			if tablen ~= outputcount+incit+1 then
				outputstr=outputstr..',"'..l..'","Page suivante") + '..incit..' '
				if nextc > 0 then
					outputstr = outputstr..'end '
				end
				outputstr=outputstr..'; if sel == '..(incit+max+1)..' then '        
				nextc, outputcount, incit= nextc+1,0,incit+max
			else
				outputstr=outputstr..',"'..l..'"'
			end
		else
			outputstr=outputstr..',"'..l..'"'
		end
	end
)
outputstr = outputstr..') + '..incit
if nextc > 0 then
	outputstr = outputstr..' end'
end
outputstr= outputstr.. '; return sel'
print(outputstr)
local sel = assert(loadstring(outputstr))()
tablen,outputstr,outputcount,nextc,incit = nil,nil,nil,nil,nil 
return sel
end
 

 

 

La quête:

quest user_vote_shop begin
state start begin
	when 9005.chat."Ingame Vote-Shop" begin
		say_title(string.format("Vote-Shop(%d Coins)", GetVoteCoins()))
		say()
		say("Que voulez vous m'acheter?")
		say()
		local a = select_table(LoadVoteShopCat())
		if a == table.getn(LoadVoteShopCat()) then return end
		local tab_items, tab_price = {5}, {}
		local query01 = mysql_query("SELECT vnum, price FROM account.vote_shop WHERE art= "..a..";")
		for b = 1, table.getn(query01) do
			table.insert(tab_items, tostring(item_name(query01[b][1]).." Preis("..query01[b][2]..")"))
		end
		table.insert(tab_items, "Abbrechen")
		say_title(string.format("Vote-Shop(%d Coins)", GetVoteCoins()))
		say()
		say("Veuillez selectionner un item:")
		say()
		local c = select2(tab_items)
		if c == table.getn(tab_items) then return end
		say_title(string.format("Vote-Shop(%d Coins)", GetVoteCoins()))
		say()
		say("Vous voulez donc ceci:")
		say_item_vnum(query01[c][1])
		say()
		say()
		if select("Je confirme "..query01[c][2], "Abandonner") == 2 then return end
		if GetVoteCoins() < query01[c][2] then return chat("Vous n'avez pas assez de points de vote!") end
		SetVoteCoins(-query01[c][2])
		pc.give_item2(query01[c][1])
	end
end
end
 

 

 

Le SQL à mettre dans account :

CREATE TABLE `vote_shop` (
 `id` int(10) NOT NULL DEFAULT '0',
 `vnum` int(10) NOT NULL,
 `price` int(10) NOT NULL,
 `art` int(10) NOT NULL,
 PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE `vote_shop_cat` (
 `id` int(10) NOT NULL DEFAULT '0',
 `kat` int(10) NOT NULL,
 `name` varchar(20) NOT NULL,
 PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

 

 

*epvp

  • Metin2 Dev 1
  • Good 1
Lien vers le commentaire
Partager sur d’autres sites

  • Réponses 2
  • Créé
  • Dernière réponse

Meilleurs contributeurs dans ce sujet

  • 4 ans après...


  • brilliantdiscord_widget
  • Flux d'Activité

    1. 37
    2. 21

      Metin2 en 2020 peut-on en parler?

    3. 0

      METIN2Project

    4. 3

      Ressources - UnPack - Metin2 Client - Officiel

    5. 0

      Barre des tâches d'argent étendue

    6. 16

      Redémarrage automatique des channels

    7. 16

      Multi Logo GM / SGM / GA

  • En ligne récemment

    • Aucun utilisateur enregistré regarde cette page.

Information importante

Conditions d’utilisation / Politique de confidentialité / Règles / Nous avons placé des cookies sur votre appareil pour aider à améliorer ce site. Vous pouvez choisir d’ajuster vos paramètres de cookie, sinon nous supposerons que vous êtes d’accord pour continuer.