Jump to content
×
×
  • Create New...

[Système] Vote Coins Shop


herostar34
 Share

Recommended Posts

  • 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

  • Funky Emulation 1
Link to comment
Share on other sites

  • 4 years later...
 Share



Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.