Register for your free account! | Forgot your password?

Go Back   elitepvpers > Popular Games > Metin2 > Metin2 Private Server
You last visited: Today at 14:46

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[Help-Costume System] I dont can remove the Costumes.

Discussion on [Help-Costume System] I dont can remove the Costumes. within the Metin2 Private Server forum part of the Metin2 category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Aug 2012
Posts: 35
Received Thanks: 0
Exclamation [Help-Costume System] I dont can remove the Costumes.

Help me please, I dont can remove the Costumes.

type=18 in item_proto, server and client.

questlib_costum.lua
Code:
function costume_system_create()
	os.execute("mysql -u root player --execute=\"INSERT INTO costume_system(pid) VALUES ('".. pc.get_player_id() .."')\"")
end

function costume_system_read(type_v)
	local mysql_read = (mysql_query("SELECT "..type_v.." as result_value from player.costume_system where pid = ('".. pc.get_player_id() .."')") or {["result_value"] = 0}) 
	return mysql_read.result_value[1]
end

function costume_system_update(type_s, value)
	if type_s == "part_main_old" then
		if value < 41002 then
			os.execute("mysql -u root player --execute=\"UPDATE costume_system SET "..type_s.." =('"..value.."') where pid = ('".. pc.get_player_id() .."')\"")
		end

	elseif type_s == "part_hair_old" then
		os.execute("mysql -u root player --execute=\"UPDATE costume_system SET "..type_s.." =('"..value.."') where pid = ('".. pc.get_player_id() .."')\"")
	end
end

mysql_query = function(query)
    if not pre then
        local rt = io.open('CONFIG', 'r'):read('*all')
        pre = string.gsub(rt, '.+PLAYER_SQL:%s(%S+)%s(%S+)%s(%S+)%s(%S+).+', '-h%1 -u%2 -p%3 -D%4')
    end

    math.randomseed(os.time())

    local fi, t, out = 'mysql_data_'..math.random(10^9)+math.random(2^4,2^10),{},{}
    os.execute('mysql '..pre..' --execute='..string.format('%q', query)..' > '..fi)

    for av in io.open(fi, 'r'):lines() do table.insert(t,split(av, '\t')) end; os.remove(fi);
    for i = 2, table.getn(t) do table.foreach(t[i],function(a, b)
        out[i-1]               = out[i-1] or {}
        out[i-1][a]            = tonumber(b) or b
        out[t[1][a]]           = out[t[1][a]] or {}
        out[t[1][a]][i-1]      = tonumber(b) or b
    end) end
    return out
end

function split(str, delim, maxNb)
    if str == nil then
		return str
	end

    if string.find(str, delim) == nil then
		return { str }
	end

    if maxNb == nil or maxNb < 1 then maxNb = 0 end

    local result = {}
    local pat = "(.-)" .. delim .. "()"
    local nb = 0
    local lastPos

    for part, pos in string.gfind(str, pat) do
        nb = nb + 1
        result[nb] = part
        lastPos = pos
        if nb == maxNb then break end
    end

    if nb ~= maxNb then result[nb + 1] = string.sub(str, lastPos)
	end
    return result
end
costume_system.quest
Code:
quest costume_system begin
	state start begin
		function get_real_hair_id(id)
			return ({
				[45001] = 5001,
				[45002] = 5001,
				[45003] = 5002,
				[45004] = 5002,
				[45005] = 5003,
				[45006] = 5003,
				[45007] = 5004,
				[45008] = 5004,
				[45009] = 5005,
				[45010] = 5005,
				[45011] = 5008,
				[45012] = 5009,
				[45013] = 5010,
				[45014] = 5011,
				[45015] = 5012,
				[45016] = 5013,
				[45017] = 5014,
				[45018] = 5015,
				[45019] = 5016,
				[45020] = 5017,
				[45021] = 5018,
				[45022] = 5019,
				[45023] = 5020,
				[45024] = 5021,
				[45025] = 5022,
				[45026] = 5023,
				[45027] = 5024,
				[45028] = 5025,
				[45029] = 5026,
				[45030] = 5027,
				[45031] = 5028,
				[45032] = 5029,
				[45033] = 5030,
				[45034] = 5031,
				[45035] = 5032,
				[45036] = 5033,
				[45037] = 5034,
				[45038] = 5035,
				[45039] = 5036,
				[45040] = 5037,
				[45041] = 5038,
				[45042] = 5039,
				[45043] = 5040,
				[45044] = 5041,
				[45045] = 5042,
				[45046] = 5043,
				[45047] = 5044,
				[45048] = 5045,
				[45049] = 5046,
				[45050] = 5047,
				[45053] = 5048,
				[45054] = 5049,
				[45055] = 5050,
				[45056] = 5051,
				[45057] = 5052,
				[45058] = 5053,
				[45061] = 5054,
				[45062] = 5055,
				[45065] = 5056,
				[45066] = 5057,
				[45067] = 5058,
				[45068] = 5059,
				[45069] = 5060,
				[45070] = 5061,
				[45073] = 5062,
				[45074] = 5063,
				[45075] = 5064,
				[45076] = 5065,
				[45077] = 5066,
				[45078] = 5067,
				[45079] = 5068,
				[45080] = 5069,
				[45081] = 5070,
				[45082] = 5071,
				[45083] = 5072,
				[45084] = 5073,
				[45085] = 5006,
				[45086] = 5007,
			})[id] or 0
		end

		when login begin
			loop_timer('costume_system_check', 0.3)

			if pc.getqf('costume_system_main_active') == 1 then
				costume_system_update("part_main_old", pc.get_part(PART_MAIN))

				pc.set_part(PART_MAIN, pc.getqf('costume_system_main_vnum'))
				cmdchat("CostumeMain "..pc.getqf('costume_system_main_vnum').."")
			end

			if pc.getqf('costume_system_hair_active') == 1 then
				costume_system_update("part_hair_old", pc.get_part(PART_HAIR))

				pc.set_part(PART_MAIN, pc.getqf('costume_system_hair_vnum'))
				cmdchat("CostumeHair "..pc.getqf('costume_system_hair_vnum').."")
			end

			if pc.getqf('costume_system') == 1 then
				return

			elseif pc.getqf('costume_system') ~= 1 then
				costume_system_create()

				pc.setqf('costume_system', 1)
			end
		end
		
		when costume_system_check.timer begin
			if pc.getqf('costume_system_main_active') == 1 and pc.get_part(PART_MAIN) ~= pc.getqf('costume_system_main_vnum') then
				pc.set_part(PART_MAIN, pc.getqf('costume_system_main_vnum'))
			end

			if pc.getqf('costume_system_hair_active') == 1 and pc.get_part(PART_HAIR) ~= pc.getqf('costume_system_hair_vnum') then
				pc.set_part(PART_HAIR, pc.getqf('costume_system_hair_vnum'))
			end
		end
		
		when 41001.use or
			 41002.use or
			 41003.use or
			 41004.use or
			 41005.use or
			 41006.use or
			 41007.use or
			 41008.use or
			 41009.use or
			 41010.use or
			 41011.use or
			 41012.use or
			 41013.use or
			 41014.use or
			 41015.use or
			 41016.use or
			 41017.use or
			 41018.use or
			 41019.use or
			 41020.use or
			 41021.use or
			 41022.use or
			 41023.use or
			 41024.use or
			 41025.use or
			 41026.use or
			 41027.use or
			 41028.use or
			 41029.use or
			 41030.use or
			 41031.use or
			 41032.use or
			 41033.use or
			 41034.use or
			 41035.use or
			 41036.use or
			 41037.use or
			 41038.use or
			 41039.use or
			 41040.use or
			 41041.use or
			 41042.use or
			 41043.use or
			 41044.use or
			 41045.use or
			 41046.use or
			 41047.use or
			 41048.use or
			 41049.use or
			 41050.use or
			 41051.use or
			 41052.use or
			 41053.use or
			 41054.use or
			 41055.use or
			 41056.use or
			 41057.use or
			 41058.use or
			 41059.use or
			 41060.use or
			 41061.use or
			 41062.use or
			 41063.use or
			 41064.use or
			 41065.use or
			 41066.use or
			 41067.use or
			 41068.use or
			 41069.use or
			 41070.use or
			 41071.use or
			 41072.use or
			 41073.use or
			 41074.use or
			 41075.use or
			 41076.use or
			 41077.use or
			 41078.use or
			 41079.use or
			 41080.use or
			 41081.use or
			 41082.use or
			 41083.use or
			 41084.use or
			 41085.use or
			 41086.use or
			 41087.use or
			 41088.use or
			 41089.use or
			 41090.use or
			 41091.use or
			 41092.use or
			 41093.use or
			 41094.use or
			 41095.use or
			 41096.use or
			 41097.use or
			 41098.use or
			 41099.use or
			 41100.use or
			 41101.use or
			 41102.use or
			 41103.use or
			 41104.use or
			 41105.use or
			 41106.use or
			 41107.use or
			 41108.use or
			 41109.use or
			 41110.use or
			 41111.use or
			 41112.use or
			 41113.use or
			 41114.use or
			 41117.use or
			 41118.use or
			 41119.use or
			 41120.use or
			 41121.use or
			 41122.use or
			 41125.use or
			 41126.use or
			 41129.use or
			 41130.use or
			 41131.use or
			 41132.use or
			 41133.use or
			 41134.use or
			 41135.use or
			 41136.use or
			 41137.use or
			 41138.use or
			 41139.use or
			 41140.use or
			 41141.use or
			 41142.use or
			 41143.use or
			 41144.use or
			 41145.use or
			 41146.use or
			 41147.use or
			 41148.use or
			 41149.use or
			 41150.use or
			 41151.use or
			 41152.use or
			 45003.use or
			 45004.use or
			 45005.use or
			 45006.use or
			 45007.use or
			 45008.use or
			 45009.use or
			 45010.use or
			 45011.use or
			 45012.use or
			 45013.use or
			 45014.use or
			 45015.use or
			 45016.use or
			 45017.use or
			 45018.use or
			 45019.use or
			 45020.use or
			 45021.use or
			 45022.use or
			 45023.use or
			 45024.use or
			 45025.use or
			 45026.use or
			 45027.use or
			 45028.use or
			 45029.use or
			 45030.use or
			 45031.use or
			 45032.use or
			 45033.use or
			 45034.use or
			 45035.use or
			 45036.use or
			 45037.use or
			 45038.use or
			 45039.use or
			 45040.use or
			 45041.use or
			 45042.use or
			 45043.use or
			 45044.use or
			 45045.use or
			 45046.use or
			 45047.use or
			 45048.use or
			 45049.use or
			 45050.use or
			 45053.use or
			 45054.use or
			 45055.use or
			 45056.use or
			 45057.use or
			 45058.use or
			 45061.use or
			 45062.use or
			 45065.use or
			 45066.use or
			 45067.use or
			 45068.use or
			 45069.use or
			 45070.use or
			 45073.use or
			 45074.use or
			 45075.use or
			 45076.use or
			 45077.use or
			 45078.use or
			 45079.use or
			 45080.use or
			 45081.use or
			 45082.use or
			 45083.use or
			 45084.use or
			 45085.use or
			 45086.use begin

			local vnum = item.get_vnum()
			local hair_vnum = costume_system.get_real_hair_id(vnum)

			if tonumber(vnum) > 41000 and tonumber(vnum) < 41153 then
				if pc.get_part(PART_MAIN) == vnum and pc.getqf('costume_system_main_active') == 1 then
					pc.set_part(PART_MAIN, (tonumber(costume_system_read("part_main_old"))))
					pc.setqf('costume_system_main_active', 0)
					pc.setqf('costume_system_main_vnum', 0)
					cmdchat("CostumeMain "..vnum.."")
				else
					costume_system_update("part_main_old", pc.get_armor())

					pc.set_part(PART_MAIN, vnum)
					pc.setqf('costume_system_main_active', 1)
					pc.setqf('costume_system_main_vnum', vnum)
					cmdchat("CostumeMain "..vnum.."")
				end

			elseif tonumber(vnum) > 45000 and tonumber(vnum) < 45087 then
				if pc.getqf('costume_system_hair_active') == 1 and pc.get_part(PART_HAIR) == hair_vnum then
					pc.set_part(PART_HAIR, (tonumber(costume_system_read("part_hair_old"))))
					chat((tonumber(costume_system_read("part_hair_old"))))
					pc.setqf('costume_system_hair_active', 0)
					pc.setqf('costume_system_hair_vnum', 0)
					cmdchat("CostumeHair "..vnum.."")

				elseif pc.get_part(PART_HAIR) ~= hair_vnum and pc.getqf('costume_system_hair_active') == 1 then
					pc.set_part(PART_HAIR, hair_vnum)
					pc.setqf('costume_system_hair_vnum', hair_vnum)
					cmdchat("CostumeHair "..vnum.."")
				else
					costume_system_update("part_hair_old", pc.get_part(PART_HAIR))

					pc.set_part(PART_HAIR, hair_vnum)
					pc.setqf('costume_system_hair_active', 1)
					pc.setqf('costume_system_hair_vnum', vnum)
					cmdchat("CostumeHair "..vnum.."")
				end
			end
		end
	end
end
questlib.lua
Code:
dofile("locale/germany/quest/questlib_costum.lua")


function costume_system_create()
    os.execute("mysql -u root player --execute=\"INSERT INTO costume_system(pid) VALUES ('".. pc.get_player_id() .."')\"")
end


function costume_system_read(type_v)
    local mysql_read = (mysql_query("SELECT "..type_v.." as result_value from player.costume_system where pid = ('".. pc.get_player_id() .."')") or {["result_value"] = 0}) 
    return mysql_read.result_value[1]
end


function costume_system_update(type_s, value)
    if type_s == "part_main_old" then
        if value < 41002 then
            os.execute("mysql -u root player --execute=\"UPDATE costume_system SET "..type_s.." =('"..value.."') where pid = ('".. pc.get_player_id() .."')\"")
        end


    elseif type_s == "part_hair_old" then
        os.execute("mysql -u root player --execute=\"UPDATE costume_system SET "..type_s.." =('"..value.."') where pid = ('".. pc.get_player_id() .."')\"")
    end
end


mysql_query = function(query)
    if not pre then
        local rt = io.open('CONFIG', 'r'):read('*all')
        pre = string.gsub(rt, '.+PLAYER_SQL:%s(%S+)%s(%S+)%s(%S+)%s(%S+).+', '-h%1 -u%2 -p%3 -D%4')
    end


    math.randomseed(os.time())


    local fi, t, out = 'mysql_data_'..math.random(10^9)+math.random(2^4,2  ^10),{},{}
    os.execute('mysql '..pre..' --execute='..string.format('%q', query)..' > '..fi)


    for av in io.open(fi, 'r'):lines() do table.insert(t,split(av, '\t')) end; os.remove(fi);
    for i = 2, table.getn(t) do table.foreach(t[i],function(a, b)
        out[i-1]               = out[i-1] or {}
        out[i-1][a]            = tonumber(b) or b
        out[t[1][a]]           = out[t[1][a]] or {}
        out[t[1][a]][i-1]      = tonumber(b) or b
    end) end
    return out
end


function split(str, delim, maxNb)
    if str == nil then
        return str
    end


    if string.find(str, delim) == nil then
        return { str }
    end


    if maxNb == nil or maxNb < 1 then maxNb = 0 end


    local result = {}
    local pat = "(.-)" .. delim .. "()"
    local nb = 0
    local lastPos


    for part, pos in string.gfind(str, pat) do
        nb = nb + 1
        result[nb] = part
        lastPos = pos
        if nb == maxNb then break end
    end


    if nb ~= maxNb then result[nb + 1] = string.sub(str, lastPos)
    end
    return result
end
Slabon is offline  
Old 01/07/2013, 06:36   #2
 
nostradame37's Avatar
 
elite*gold: 0
Join Date: Jan 2011
Posts: 2,504
Received Thanks: 870
You hafe to Klick on the kostume in your inventar to remove the costume
nostradame37 is offline  
Old 01/07/2013, 07:17   #3
 
elite*gold: 0
Join Date: Aug 2012
Posts: 35
Received Thanks: 0
Quote:
Originally Posted by nostradame37 View Post
You hafe to Klick on the kostume in your inventar to remove the costume
that's what I do but not removed and every time I try to remove it lost the connection between client and server, without giving any syserr.txt
Slabon is offline  
Old 01/08/2013, 08:07   #4
 
elite*gold: 0
Join Date: Aug 2012
Posts: 35
Received Thanks: 0
help me please
Slabon is offline  
Old 01/09/2013, 17:30   #5
 
elite*gold: 0
Join Date: Aug 2012
Posts: 35
Received Thanks: 0
help me please
Slabon is offline  
Reply




All times are GMT +1. The time now is 14:52.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.