Some time ago I started my adventure with metin files. I am currently running on Ulthar SF V2 (TMP4 Base) files . I have a problem with the pet system.
I created a starter crate quest that assigns players to the appropriate items
apprentice_chest.quest
Spoiler
quest apprentice_chest begin
state start begin
function job_chest (job)if job ==0thenreturn{{id=16,count=1},{id=3006,count=1},{id=11206,count=1},{id=12206,count=1}}elseif job ==1thenreturn{{id=16,count=1},{id=1006,count=1},{id=2006,count=1},{id=11406,count=1},{id=12346,count=1}}elseif job ==2thenreturn{{id=16,count=1},{id=11606,count=1},{id=12486,count=1}}elseif job ==3thenreturn{{id=7006,count=1},{id=5006,count=1},{id=11800,count=1},{id=12626,count=1}}endendfunction level_chest( vnum, job )
chests ={[50187]={1,{{id=50188,count=1},{id=71124,count=1},{id=39040,count=1},{id=39037,count=1},{id=39024,count=5},{id=39025,count=5},{id=13006,count=1},{id=15006,count=1},{id=16006,count=1},{id=17006,count=1},{id=14006,count=1},{id=76024,count=5},{id=76023,count=5},{id=39006,count=50}},apprentice_chest.job_chest(job)},[50188]={10,{{id=39024,count=5},{id=39025,count=5},{id=13006,count=1},{id=15006,count=1},{id=16006,count=1},{id=17006,count=1},{id=14006,count=1},{id=76024,count=5},{id=76023,count=5},{id=39006,count=50}},{}},}return chests[vnum]end
when login begin
if pc.getqf("starting_quest")==0then
pc.setqf("starting_quest",1)if pc.countitem(item)==0and pc.weapon != item then
pc.give_item2(50187)endendend
when 50187.use or50188.use begin
chest = apprentice_chest.level_chest(item.vnum,pc.job)
itemId = item.vnum
if chest ~=nilthen
level = chest[1]if level ==1then
pc.give_item2(53001)if pc.get_sex()==0then
pc.give_item2(41003,1)
pc.give_item2(45003,1)else
pc.give_item2(41004,1)
pc.give_item2(45004,1)endend
items = chest[2]
job_items = chest[3]if job_items ~=nilthenfor itemIndex in job_items do
item = job_items[itemIndex]
pc.give_item2(item.id,item.count )endendif items ~=nilthenfor itemIndex in items do
item = items[itemIndex]
pc.give_item2(item.id,item.count )endend
pc.remove_item(itemId,1)endreturnendendend
On the other hand, for some reason my pet system is not working properly. After the player opens the crate, the pet seal "53001" does not work.
Only a complete restart of the server or calling the /reload q command helps.
Spoiler
quest pet_system begin
state start begin
function get_pet_info(itemVnum)
pet_info_map = {
[53001] = {34001, "Ognisty Feniks", 1},
[53002] = {34002, "Lodowy Feniks", 1},
}
itemVnum = tonumber(itemVnum)
return pet_info_map[itemVnum]
end
function get_pet_skin(mobSkin)
local pet_skin_table = {
[34010] = "Bambi",
[34004] = "Azraelus",
}
return pet_skin_table[mobSkin]
end
function get_pet_effect(idx, mobVnum)
effect_table = {
[0] = nil,
[1] = "d:/ymir work/effect/etc/appear_die/npc2_appear.mse",
}
if effect_table[idx] != nil then
pet.spawn_effect(mobVnum, effect_table[idx])
end
end
function insert_pet_to_table()
if pc.getqf("flag_insert_pet_to_table") == 0 then
pc.setqf("flag_insert_pet_to_table", 1)
mysql_direct_query("INSERT INTO player.pet_system SET player_id='"..pc.get_player_id().."', pet_level='1', pet_exp='0', pet_alignment='0'")
end
end
function spawn_character_pet(itemVnum,reload)
if pc.getqf("pet_last_spawn") > get_time() then
chat("|cFFc9a361|h[Zwierzaczek]|h|r Musisz odczekać chwile nim użyjesz ponownie przywołania.")
return
end
local pet_info = pet_system.get_pet_info(itemVnum)
local mobVnum, petName = nil
local mobSkin = pc.getqf("mobSkin")
if mobSkin == 0 then
mobVnum = pet_info[1]
petName = pet_info[2]
else
mobVnum = mobSkin
petName = pet_system.get_pet_skin(mobSkin)
end
if pet.is_summon(pc.getqf("petVnum")) == true then
pc.delqf("petSummoned")
pc.delqf("petItemID")
pet_system.get_pet_effect(pet_info[3], mobVnum)
if reload then
pet_system.get_summoned_pet_info(mobVnum)
end
pet.unsummon(pc.getqf("petVnum"))
pc.delqf("petVnum")
item.select(pc.getqf("petItemVID"))
item.set_socket(1, 0)
else
if pet.count_summoned() < 1 then
pc.setqf("petSummoned", 1)
pc.setqf("petVnum", mobVnum)
if reload then
pet_system.get_summoned_pet_info(mobVnum)
end
pet.summon(mobVnum, petName.." - "..pc.get_name().."", false)
pet_system.get_pet_effect(pet_info[3], mobVnum)
item.select(pc.getqf("petItemVID"))
item.set_socket(1, 1)
else
chat("|cFFc9a361|h[Zwierzaczek]|h|r Nie możesz przywołać więcej niż jednego zwierzaczka.")
end
end
-- pc.setqf("pet_last_spawn", get_time() + 3)
end
function get_pet_new_look()
pet_system.spawn_character_pet(pc.getqf("petItem"),false)
pet_system.spawn_character_pet(pc.getqf("petItem"),true)
end
function get_summoned_pet_skill_level()
local skillLevel = {}
for i = 200, 209 do
table.insert(skillLevel, pc.get_skill_level(i))
end
cmdchat(string.format("PetUpdateWindow SKILL_LEVEL|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s", skillLevel[1], skillLevel[2], skillLevel[3], skillLevel[4], skillLevel[5], skillLevel[6], skillLevel[7], skillLevel[8], skillLevel[9], skillLevel[10]))
end
function get_summoned_pet_info(mobVnum)
local petSummoned = pc.getqf("petSummoned")
if petSummoned == 0 then
cmdchat("PetHideWindow")
pc.delqf("petLevel")
else
local row, data = mysql_direct_query("SELECT pet_level, pet_exp, pet_alignment, skill_points FROM player.pet_system WHERE player_id='"..pc.get_player_id().."';")
local requiredExp = pet_exp_table[data[1].pet_level]
cmdchat(string.format("PetUpdateWindow ALL|%s|%s|%s|%s|%s|%s|%s", petSummoned, mobVnum, data[1].pet_level, data[1].pet_exp, requiredExp, data[1].pet_alignment,data[1].skill_points))
pet_system.get_summoned_pet_skill_level()
pc.setqf("petLevel", data[1].pet_level)
end
end
function pet_resummon_after_login()
item.select(pc.getqf("petItemVID"))
local pet_info = pet_system.get_pet_info(item.get_vnum())
local mobVnum, petName = nil
local mobSkin = pc.getqf("mobSkin")
if mobSkin == 0 then
mobVnum = pet_info[1]
petName = pet_info[2]
else
mobVnum = mobSkin
petName = pet_system.get_pet_skin(mobSkin)
end
pet.summon(mobVnum, petName.." - "..pc.get_name().."", false)
pet_system.get_summoned_pet_info(mobVnum)
end
function learn_pet_skill(bookID)
if pet.count_summoned() == 0 then
syschat("Aby przystąpić do szkolenia umiejętności zwierzaczka musisz go najpierw przywołać.")
return
end
local petLevel = pet.get_information(0)
local petAlignment = pet.get_information(1)
local skillLevel_min = pet.get_skill_information(0)
local skillLevel_max = pet.get_skill_information(1)
local skillLevel_get = pet.get_skill_information(2)
local skillAlignment_min = 150
local skillAlignment_max = 300
if petLevel < skillLevel_min then
syschat("Twój zwierzaczek posiada za mały poziom aby szkolić tą umiejętność.")
return
end
if skillLevel_get == skillLevel_max then
syschat("Ta umiejętność zwierzaczka została wyszkolona już na maksymalny poziom.")
return
end
if !pc.is_skill_book_no_delay() then
if pc.getqf("pet_book_"..bookID.."_cooltime") > get_time() then
local duration = (pc.getqf("pet_book_"..bookID.."_cooltime") - get_time())/3600
local h = math.floor(duration)
local min = (duration)*60-(h*60)
local m = math.floor(min)
if h >= 1 then
if m == 0 then
syschat("Zwierzak musi trochę odpocząć.. do następnego treningu pozostało: "..h.." godz.")
else
syschat("Zwierzak musi trochę odpocząć.. do następnego treningu pozostało: "..h.." godz. "..m.." min.")
end
else
syschat("Zwierzak musi trochę odpocząć.. do następnego treningu pozostało: "..m.." min.")
end
return
end
end
if skillLevel_get > 1 then
skillAlignment_min = skillAlignment_min * skillLevel_get
skillAlignment_max = skillAlignment_max * skillLevel_get
end
local skillAlignment_remove = math.random(skillAlignment_min, skillAlignment_max)
say_title("Szkolenie umiejętności zwierzaczka:")
say("Zdobywanie nowej wiedzy to bardzo energochłonny")
say("dla Twojego pupila proces. Podczas szkolenia")
say("Twój zwierzak straci od "..skillAlignment_min.." do "..skillAlignment_max.." punktów.")
say("")
local s = select ("Go on", "Cancel")
if s == 1 then
if petAlignment < skillAlignment_remove then
say_title("Szkolenie umiejętności zwierzaczka:")
say("Niestety pupil nie posiada odpowiedniej ilości")
say("punktów odwagi by rozpocząć trening zwierzaka.")
say("")
else
if math.random(1, 100) <= 38 then
say_title("Szkolenie umiejętności zwierzaczka:")
say("Trening umiejętności odbył się pomyślnie.")
say("")
pet.increase_skill_level(pet.get_skill_information(3))
pet_system.get_summoned_pet_skill_level()
else
say_title("Szkolenie umiejętności zwierzaczka:")
say("Niestety.. szkolenie umiejętności nie powiodło się ")
say("")
end
if pc.is_skill_book_no_delay() then
pc.remove_skill_book_no_delay()
end
pc.remove_item(bookID, 1)
pet.refresh_alignment(skillAlignment_remove)
pc.setqf("pet_book_"..bookID.."_cooltime", get_time() + 60*60*2)
end
end
end
when login with pc.getqf("petVnum") != 0 begin
pet_system.pet_resummon_after_login()
end
when 53001.use or 53002.use begin
pc.setqf("petItemID", item.get_id())
pc.setqf("petItemVID", item.get_id())
pc.setqf("petItem", item.vnum)
pet_system.insert_pet_to_table()
pet_system.spawn_character_pet(item.vnum, true)
end
when ID_KSIEGI_01.use or ID_KSIEGI_02.use or ID_KSIEGI_03.use or ID_KSIEGI_04.use or ID_KSIEGI_05.use or ID_KSIEGI_06.use or ID_KSIEGI_07.use or ID_KSIEGI_08.use or ID_KSIEGI_09.use or ID_KSIEGI_10.use begin
pet_system.learn_pet_skill(item.vnum)
end
when 53005.use begin
pet_system.get_pet_new_look()
end
end
end
syserror
SYSERR: Mar 14 13:19:51 :: RunState: LUA_ERROR: [string "pet_system"]:1: attempt to call field `get_id' (a nil value)
SYSERR: Mar 14 13:19:51 :: WriteRunningStateToSyserr: LUA_ERROR: quest pet_system.start enter
SYSERR: Mar 14 13:19:51 :: RunState: LUA_ERROR: [string "pet_system"]:1: attempt to call field `get_id' (a nil value)
SYSERR: Mar 14 13:19:51 :: WriteRunningStateToSyserr: LUA_ERROR: quest pet_system.start enter
SYSERR: Mar 14 13:19:51 :: RunState: LUA_ERROR: [string "pet_system"]:1: attempt to call field `get_id' (a nil value)
SYSERR: Mar 14 13:19:51 :: WriteRunningStateToSyserr: LUA_ERROR: quest pet_system.start enter
Problem with PetSystem
in Community Support - Questions & Answers
Posted
Hello Everyone,
Some time ago I started my adventure with metin files. I am currently running on Ulthar SF V2 (TMP4 Base) files . I have a problem with the pet system.
I created a starter crate quest that assigns players to the appropriate items
apprentice_chest.quest
On the other hand, for some reason my pet system is not working properly. After the player opens the crate, the pet seal "53001" does not work.
Only a complete restart of the server or calling the /reload q command helps.
quest pet_system begin state start begin function get_pet_info(itemVnum) pet_info_map = { [53001] = {34001, "Ognisty Feniks", 1}, [53002] = {34002, "Lodowy Feniks", 1}, } itemVnum = tonumber(itemVnum) return pet_info_map[itemVnum] end function get_pet_skin(mobSkin) local pet_skin_table = { [34010] = "Bambi", [34004] = "Azraelus", } return pet_skin_table[mobSkin] end function get_pet_effect(idx, mobVnum) effect_table = { [0] = nil, [1] = "d:/ymir work/effect/etc/appear_die/npc2_appear.mse", } if effect_table[idx] != nil then pet.spawn_effect(mobVnum, effect_table[idx]) end end function insert_pet_to_table() if pc.getqf("flag_insert_pet_to_table") == 0 then pc.setqf("flag_insert_pet_to_table", 1) mysql_direct_query("INSERT INTO player.pet_system SET player_id='"..pc.get_player_id().."', pet_level='1', pet_exp='0', pet_alignment='0'") end end function spawn_character_pet(itemVnum,reload) if pc.getqf("pet_last_spawn") > get_time() then chat("|cFFc9a361|h[Zwierzaczek]|h|r Musisz odczekać chwile nim użyjesz ponownie przywołania.") return end local pet_info = pet_system.get_pet_info(itemVnum) local mobVnum, petName = nil local mobSkin = pc.getqf("mobSkin") if mobSkin == 0 then mobVnum = pet_info[1] petName = pet_info[2] else mobVnum = mobSkin petName = pet_system.get_pet_skin(mobSkin) end if pet.is_summon(pc.getqf("petVnum")) == true then pc.delqf("petSummoned") pc.delqf("petItemID") pet_system.get_pet_effect(pet_info[3], mobVnum) if reload then pet_system.get_summoned_pet_info(mobVnum) end pet.unsummon(pc.getqf("petVnum")) pc.delqf("petVnum") item.select(pc.getqf("petItemVID")) item.set_socket(1, 0) else if pet.count_summoned() < 1 then pc.setqf("petSummoned", 1) pc.setqf("petVnum", mobVnum) if reload then pet_system.get_summoned_pet_info(mobVnum) end pet.summon(mobVnum, petName.." - "..pc.get_name().."", false) pet_system.get_pet_effect(pet_info[3], mobVnum) item.select(pc.getqf("petItemVID")) item.set_socket(1, 1) else chat("|cFFc9a361|h[Zwierzaczek]|h|r Nie możesz przywołać więcej niż jednego zwierzaczka.") end end -- pc.setqf("pet_last_spawn", get_time() + 3) end function get_pet_new_look() pet_system.spawn_character_pet(pc.getqf("petItem"),false) pet_system.spawn_character_pet(pc.getqf("petItem"),true) end function get_summoned_pet_skill_level() local skillLevel = {} for i = 200, 209 do table.insert(skillLevel, pc.get_skill_level(i)) end cmdchat(string.format("PetUpdateWindow SKILL_LEVEL|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s", skillLevel[1], skillLevel[2], skillLevel[3], skillLevel[4], skillLevel[5], skillLevel[6], skillLevel[7], skillLevel[8], skillLevel[9], skillLevel[10])) end function get_summoned_pet_info(mobVnum) local petSummoned = pc.getqf("petSummoned") if petSummoned == 0 then cmdchat("PetHideWindow") pc.delqf("petLevel") else local row, data = mysql_direct_query("SELECT pet_level, pet_exp, pet_alignment, skill_points FROM player.pet_system WHERE player_id='"..pc.get_player_id().."';") local requiredExp = pet_exp_table[data[1].pet_level] cmdchat(string.format("PetUpdateWindow ALL|%s|%s|%s|%s|%s|%s|%s", petSummoned, mobVnum, data[1].pet_level, data[1].pet_exp, requiredExp, data[1].pet_alignment,data[1].skill_points)) pet_system.get_summoned_pet_skill_level() pc.setqf("petLevel", data[1].pet_level) end end function pet_resummon_after_login() item.select(pc.getqf("petItemVID")) local pet_info = pet_system.get_pet_info(item.get_vnum()) local mobVnum, petName = nil local mobSkin = pc.getqf("mobSkin") if mobSkin == 0 then mobVnum = pet_info[1] petName = pet_info[2] else mobVnum = mobSkin petName = pet_system.get_pet_skin(mobSkin) end pet.summon(mobVnum, petName.." - "..pc.get_name().."", false) pet_system.get_summoned_pet_info(mobVnum) end function learn_pet_skill(bookID) if pet.count_summoned() == 0 then syschat("Aby przystąpić do szkolenia umiejętności zwierzaczka musisz go najpierw przywołać.") return end local petLevel = pet.get_information(0) local petAlignment = pet.get_information(1) local skillLevel_min = pet.get_skill_information(0) local skillLevel_max = pet.get_skill_information(1) local skillLevel_get = pet.get_skill_information(2) local skillAlignment_min = 150 local skillAlignment_max = 300 if petLevel < skillLevel_min then syschat("Twój zwierzaczek posiada za mały poziom aby szkolić tą umiejętność.") return end if skillLevel_get == skillLevel_max then syschat("Ta umiejętność zwierzaczka została wyszkolona już na maksymalny poziom.") return end if !pc.is_skill_book_no_delay() then if pc.getqf("pet_book_"..bookID.."_cooltime") > get_time() then local duration = (pc.getqf("pet_book_"..bookID.."_cooltime") - get_time())/3600 local h = math.floor(duration) local min = (duration)*60-(h*60) local m = math.floor(min) if h >= 1 then if m == 0 then syschat("Zwierzak musi trochę odpocząć.. do następnego treningu pozostało: "..h.." godz.") else syschat("Zwierzak musi trochę odpocząć.. do następnego treningu pozostało: "..h.." godz. "..m.." min.") end else syschat("Zwierzak musi trochę odpocząć.. do następnego treningu pozostało: "..m.." min.") end return end end if skillLevel_get > 1 then skillAlignment_min = skillAlignment_min * skillLevel_get skillAlignment_max = skillAlignment_max * skillLevel_get end local skillAlignment_remove = math.random(skillAlignment_min, skillAlignment_max) say_title("Szkolenie umiejętności zwierzaczka:") say("Zdobywanie nowej wiedzy to bardzo energochłonny") say("dla Twojego pupila proces. Podczas szkolenia") say("Twój zwierzak straci od "..skillAlignment_min.." do "..skillAlignment_max.." punktów.") say("") local s = select ("Go on", "Cancel") if s == 1 then if petAlignment < skillAlignment_remove then say_title("Szkolenie umiejętności zwierzaczka:") say("Niestety pupil nie posiada odpowiedniej ilości") say("punktów odwagi by rozpocząć trening zwierzaka.") say("") else if math.random(1, 100) <= 38 then say_title("Szkolenie umiejętności zwierzaczka:") say("Trening umiejętności odbył się pomyślnie.") say("") pet.increase_skill_level(pet.get_skill_information(3)) pet_system.get_summoned_pet_skill_level() else say_title("Szkolenie umiejętności zwierzaczka:") say("Niestety.. szkolenie umiejętności nie powiodło się ") say("") end if pc.is_skill_book_no_delay() then pc.remove_skill_book_no_delay() end pc.remove_item(bookID, 1) pet.refresh_alignment(skillAlignment_remove) pc.setqf("pet_book_"..bookID.."_cooltime", get_time() + 60*60*2) end end end when login with pc.getqf("petVnum") != 0 begin pet_system.pet_resummon_after_login() end when 53001.use or 53002.use begin pc.setqf("petItemID", item.get_id()) pc.setqf("petItemVID", item.get_id()) pc.setqf("petItem", item.vnum) pet_system.insert_pet_to_table() pet_system.spawn_character_pet(item.vnum, true) end when ID_KSIEGI_01.use or ID_KSIEGI_02.use or ID_KSIEGI_03.use or ID_KSIEGI_04.use or ID_KSIEGI_05.use or ID_KSIEGI_06.use or ID_KSIEGI_07.use or ID_KSIEGI_08.use or ID_KSIEGI_09.use or ID_KSIEGI_10.use begin pet_system.learn_pet_skill(item.vnum) end when 53005.use begin pet_system.get_pet_new_look() end end end
syserror
SYSERR: Mar 14 13:19:51 :: RunState: LUA_ERROR: [string "pet_system"]:1: attempt to call field `get_id' (a nil value) SYSERR: Mar 14 13:19:51 :: WriteRunningStateToSyserr: LUA_ERROR: quest pet_system.start enter SYSERR: Mar 14 13:19:51 :: RunState: LUA_ERROR: [string "pet_system"]:1: attempt to call field `get_id' (a nil value) SYSERR: Mar 14 13:19:51 :: WriteRunningStateToSyserr: LUA_ERROR: quest pet_system.start enter SYSERR: Mar 14 13:19:51 :: RunState: LUA_ERROR: [string "pet_system"]:1: attempt to call field `get_id' (a nil value) SYSERR: Mar 14 13:19:51 :: WriteRunningStateToSyserr: LUA_ERROR: quest pet_system.start enter