Habe es eigentlich so gut wie geschaft, das Kostum System bei mir einzufügen, aber leider gibt es noch 1 Fehler, die ich nicht schaffe zu beheben.
Hier erst mal die Quest:
HTML Code:
----------------------------------------------
-- Datei: costume_system.quest
-- Dateiversion: 1.0.0.0
-- Erstellt von: Paylasici
-- Aktualisiert von: Clad3815
----------------------------------------------
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] = 5006,
[45012] = 5006,
[45013] = 5007,
[45014] = 5007,
[45015] = 5008,
[45016] = 5008,
[45017] = 5009,
[45018] = 5009,
[45019] = 5010,
[45020] = 5011,
[45021] = 5012,
[45022] = 5013,
[45023] = 5014,
[45024] = 5014
})[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_HAIR, pc.getqf('costume_system_hair_vnum'))
cmdchat("CostumeHair "..pc.getqf('costume_system_real_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
45001.use or
45002.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 begin
local vnum = item.get_vnum()
local hair_vnum = costume_system.get_real_hair_id(vnum)
if tonumber(vnum) > 41000 and tonumber(vnum) < 41027 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) < 45025 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)
pc.setqf('costume_system_real_hair_vnum', vnum)
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)
pc.setqf('costume_system_real_hair_vnum', 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', hair_vnum)
pc.setqf('costume_system_real_hair_vnum', vnum)
cmdchat("CostumeHair "..vnum.."")
end
end
end
end
end
HTML Code:
function costume_system_create()
os.execute("mysql -u root2 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 < 41000 then
os.execute("mysql -u root2 player --execute=\"UPDATE costume_system SET "..type_s.." =('"..value.."') where pid = ('".. pc.get_player_id() .."')\"")
end
elseif type_s == "part_hair_old" then
if value < 5000 then
os.execute("mysql -u root2 player --execute=\"UPDATE costume_system SET "..type_s.." =('"..value.."') where pid = ('".. pc.get_player_id() .."')\"")
end
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..' --e='..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
Weiß nicht wirklich ob das am Kostümsystem liegt, oder am meinen Client, aber wen ich das Hasenkostüm (ID=41001 und 41002), oder das Wüstenkostüm (ID=41003, und 41004), oder das Musketierköstum (ID=41005 und 41006) anziehe, wird keine Waffe mehr angezeigt. Mein Char kämpft dan mit der Faust, obwohl ich im Inventar die Waffe anhabe. Bei den restlichen Kostümen ist das nicht so.
Wäre sehr nett wen ihr mir bei diesen Fehler helfen könntet. Komme einfach nicht mehr weiter
MfG
Kriegergeist^^







