djkotsos 101 Posted June 2, 2015 Share Posted June 2, 2015 Hello guys. I have a problem with the pet system, can someone help? Sorry for my english! pet_system.lua PetExpTable = { [1] = 300, [2] = 600, [3] = 900, [4] = 1200, [5] = 1500, [6] = 1800, [7] = 2100, [8] = 2400, [9] = 2700, [10] = 3000, [11] = 3300, [12] = 3600, [13] = 3900, [14] = 4200, [15] = 4500, [16] = 4800, [17] = 5100, [18] = 5400, [19] = 5700, [20] = 6000, [21] = 6300, [22] = 6600, [23] = 6900, [24] = 7200, [25] = 7500, [26] = 7800, [27] = 8100, [28] = 8400, [29] = 8700, [30] = 9000, [31] = 9300, [32] = 9600, [33] = 9900, [34] = 10200, [35] = 10500, [36] = 10800, [37] = 11100, [38] = 11400, [39] = 11700, [40] = 12000, [41] = 12300, [42] = 12600, [43] = 12900, [44] = 13200, [45] = 13500, [46] = 13800, [47] = 14100, [48] = 14400, [49] = 14700, [50] = 15000, [51] = 15300, [52] = 15600, [53] = 15900, [54] = 16200, [55] = 16500, [56] = 16800, [57] = 17100, [58] = 17400, [59] = 17700, [60] = 18000, [61] = 18300, [62] = 18600, [63] = 18900, [64] = 19200, [65] = 19500, [66] = 19800, [67] = 20100, [68] = 20400, [69] = 20700, [70] = 21000, [71] = 21300, [72] = 21600, [73] = 21900, [74] = 22200, [75] = 22500, [76] = 22800, [77] = 23100, [78] = 23400, [79] = 23700, [80] = 24000, [81] = 24300, [82] = 24600, [83] = 24900, [84] = 25200, [85] = 25500, [86] = 25800, [87] = 26100, [88] = 26400, [89] = 26700, [90] = 27000, [91] = 27300, [92] = 27600, [93] = 27900, [94] = 28200, [95] = 28500, [96] = 28800, [97] = 29100, [98] = 29400, [99] = 29700, [100] = 30000, [101] = 30300, [102] = 30600, [103] = 30900, [104] = 31200, [105] = 31500, [106] = 31800, [107] = 32100, [108] = 32400, [109] = 32700, [110] = 33000, [111] = 33300, [112] = 33600, [113] = 33900, [114] = 34200, [115] = 34500, [116] = 34800, [117] = 35100, [118] = 35400, [119] = 35700, [120] = 36000, [121] = 36300, [122] = 36600, [123] = 36900, [124] = 37200, [125] = 37500, [126] = 37800, [127] = 38100, [128] = 38400, [129] = 38700, [130] = 39000, [131] = 39300, [132] = 39600, [133] = 39900, [134] = 40200, [135] = 40500, [136] = 40800, [137] = 41100, [138] = 41400, [139] = 41700, [140] = 42000, [141] = 42300, [142] = 42600, [143] = 42900, [144] = 43200, [145] = 43500, [146] = 43800, [147] = 44100, [148] = 44400, [149] = 44700, [150] = 45000, } PetBonus = { { "offensivo", { "Valore Attacco Fisico","Valore Attacco Magico", }, { "Forte Vs War","Forte Vs Ninja","Forte Vs Sura","Forte Vs Shamy","Forte Vs Mostri", }, { "Danni Critici","Danni Trafiggenti", }, { "Stordimento","Avvelenamento","Rallentamento", }, }, { "difensivo", { "Difesa Attacco Fisico","Difesa Attacco Magico", }, { "Res. Spada","Res. Spadone","Res. Pugnali","Res. Campana","Res. Ventaglio","Res. Freccia","Res. Magia", }, { "Max HP","Max MP", }, { "Rigenerazione HP","Rigenerazione MP", }, }, { 1, { 53,55, }, { 59,60,61,62,63, }, { 15,16, }, { 13,12,14, }, }, { 2, { 54,56, }, { 29,30,31,32,33,34,37, }, { 1,2, }, { 10,11, }, }, } PetArray = { {53001, "fenice_rossa", "Fenice Rossa", 30068, PetExpTable, { 3,1,3,1, }, }, {53002, "fenice_blu", "Fenice Blu", 30068, PetExpTable, { 3,3,1,1, }, }, {53003, "renna", "Renna", 30068, PetExpTable, { 3,1,1,3, }, }, {53005, "azarel", "Azarel", 30068, PetExpTable, { 2,1,3,2, }, }, {53006, "cane", "Cane", 30068, PetExpTable, { 1,3,1,3, }, }, {53007, "leone", "Leone", 30068, PetExpTable, { 1,1,3,3, }, }, {53008, "cinghiale", "Cinghiale", 30068, PetExpTable, { 1,3,3,1, }, }, {53009, "tigre", "Tigre", 30068, PetExpTable, { 2,3,2,1, }, }, } PET_NAME = 1 PET_LEVEL = 2 PET_EXP = 3 PET_TYPE = 1 PET_BON1 = 2 PET_BON2 = 3 PET_BON3 = 4 PET_BON4 = 5 PET_SUMMON = 0 PET_UNSUMMON = 1 PET_READ = 0 PET_WRITE = 1 PET_DATA = 0 PET_BONUS = 1 function inizializza(i) say_title("Pet System:") say("") say("Ciao, hai adottato un nuovo cucciolo") say("per poterlo evocare, come prima cosa") say("dovrai dargli un nome.") local scelta = select("Voglio dargli un nome","Non ora") if scelta == 2 then return -1 end say_title("Pet System:") say("") say("Assegna un nome al tuo cucciolo") say("") say_reward("Nome:") local PetName = tostring(input()) if PetName == "" then say_title("Pet System:") say("") say_reward("Non puoi lasciare l'input vuoto!") return -1 end local DATA_PATH = "/usr/game/share/locale/turkey/quest/pet/" local LOCAL_PATH = pc.get_name().."/" local PET_FILE = PetArray[i][2]..".txt" local PET_BONUS_FILE = PetArray[i][2].."_bonus.txt" if pc.getqf("local_path") != 1 then os.execute("cd "..DATA_PATH.." && mkdir "..LOCAL_PATH.." && chmod 777 "..LOCAL_PATH) pc.setqf("local_path", 1) end local file = io.open(DATA_PATH..LOCAL_PATH..PET_FILE , "w") file:write("..PetName.."n1n0n") io.close(file) local bonus = io.open(DATA_PATH..LOCAL_PATH..PET_BONUS_FILE , "w") bonus:write("0n0n0n0n0n") io.close(bonus) os.execute("cd "..DATA_PATH..LOCAL_PATH.." && chmod 777 *.txt") return 0 end function GetGrade(i) local PetLevel = tonumber(data_tool(i, PET_LEVEL, PET_DATA, PET_READ)) local x = 0 local y = 0 local Grade = 1 while true do x = x + 1 y = y + 1 if y == 10 then Grade = Grade + 1 y = 0 end if x == PetLevel then return Grade end end end function evoca(i, stato) local bonus = { 3,4,5,6, } local status = PetArray[i][6] local PetGrade = tonumber(GetGrade(i)) local PetName = data_tool(i, PET_NAME, PET_DATA, PET_READ) local PetLevel = tonumber(data_tool(i, PET_LEVEL, PET_DATA, PET_READ)) local horse_level = horse.get_level() local apply = 0 local level = 21 + i if stato == PET_SUMMON then local z = 1 while true do if bonus[z] == nil then break end apply = PetGrade*status[z] affect.add_collect(bonus[z], apply, 60*60*8) z = z + 1 end horse.set_level(level) horse.set_name(PetName) horse.summon() chat("Il pet e' stato evocato") horse.set_level(horse_level) else local z = 1 while true do if bonus[z] == nil then break end apply = PetGrade*status[z] affect.remove_collect(bonus[z], apply, 60*60*8) z = z + 1 end horse.set_level(level) horse.unsummon() chat("Il tuo pet e' andato a riposare") horse.set_level(horse_level) end end function PetInfo(x) while true do say_title("Pet System:") say("Informazioni abilita':") say("") say("Lo stile "..PetBonus[x][1].." si divide in 4") say("categorie principali.") say("potrai sviluppare una sola tecnica per categoria") local y = 0 if x == 1 then y = select( "Valore Attacco","Attacco Vs. Razza","Aumento del danno","Tecniche Speciali","Indietro") else y = select( "Valore Difesa","Difesa Vs. Arma","Aumento dei valori vitali","Tecniche Rigenerative","Indietro") end if y == 5 then break end while true do say_title("Pet System:") say("Informazioni abilita':") say("") say("Con l'apprendimento di questa tecnica potrai") say("incrementare il valore "..PetBonus[x][1]) say("Tecniche disponibili:") say("") local z = 1 while true do if PetBonus[x][y+1][z] == nil then break end say_reward(PetBonus[x][y+1][z]) z = z + 1 end local b = select("Indietro") if b == 1 then break end end end end function PetSet(i, t) say_title("Pet System:") say("Gestione abilita':") say("") say("Hai scelto uno stile di combattimento") say("del tipo "..PetBonus[t][1].." per il tuo pet") say_reward("confermi?") local conferma = select("Si","No") if conferma == 2 then return end say_title("Pet System:") say("Gestione abilita':") say("") say("Una volta scelto lo stile di combattimento") say("hai la possibilita' di allenare nuove abilita'") say("scegli con cura le abilita' da sviluppare") say("") local k = select("Scelgo ora","Scelgo dopo") if k == 2 then return end local w = 2 local bonus = {} local bon = {} while true do if PetBonus[t][w] == nil then break end say_title("Pet System:") say("Gestione abilita': ") say("") say_reward("Puoi allenare solo una delle seguenti abilita'") say_reward("sceglila con cura...") say("") local x = select_table( PetBonus[t][w] ) bonus[w-1] = x bon[w-1] = PetBonus[t][w][x] w = w + 1 end say_title("Pet System:") say("Gestione abilita':") say("") say("Hai scelto:") say("") say("Bonus 1: "..bon[1]) say("Bonus 2: "..bon[2]) say("Bonus 3: "..bon[3]) say("Bonus 4: "..bon[4]) say("") say_reward("Confermi?") say("") local c = select("Si","No") if c == 2 then return end data_tool(i, t.."n"..bonus[1].."n"..bonus[2].."n"..bonus[3].."n"..bonus[4].."n", PET_BONUS, PET_WRITE) end function PetMenuAbi(i) local check = tonumber(data_tool(i, PET_TYPE, PET_BONUS, PET_READ)) local status = PetArray[i][6] local PetGrade = tonumber(GetGrade(i)) local PetType = tonumber(data_tool(i, PET_TYPE, PET_BONUS, PET_READ)) local bon1 = tonumber(data_tool(i, PET_BON1, PET_BONUS, PET_READ)) local bon2 = tonumber(data_tool(i, PET_BON2, PET_BONUS, PET_READ)) local bon3 = tonumber(data_tool(i, PET_BON3, PET_BONUS, PET_READ)) local bon4 = tonumber(data_tool(i, PET_BON4, PET_BONUS, PET_READ)) if check == 0 then while true do say_title("Pet System:") say("Benvenuto nel sistema di gestione abilita'") say("come prima cosa devi decidere che tipo") say("di istruzione vuoi dare al tuo pet") local z = select( "Offensiva","Difensiva","Informazioni","Chiudi") if z == 1 then PetSet(i, z) return elseif z == 2 then PetSet(i, z) return elseif z == 3 then while true do say_title("Pet System:") say("Informazioni abilita':") say("") say("Ogni pet puo sviluppare 4 abilita'") say("a seconda dello stile di combattimento") say("") local x = select( "Stile Offensivo","Stile Difensivo","Indietro") if x == 1 then PetInfo(x) elseif x == 2 then PetInfo(x) elseif x == 3 then break end end elseif z == 4 then break end end else say_title("Pet System:") say("Gestione abilita':") say("") say_reward("Cosa desideri fare?") say("") local y = select("Stato abilita'","Reset Abilita'","Chiudi") if y == 1 then local point = {} local p = 1 while true do if status[p] == nil then break end point[p] = status[p]*PetGrade p = p + 1 end say_title("Pet System:") say("Stato abilita':") say("") say_reward("Status:") say("VIT: +"..point[1]) say("INT: +"..point[2]) say("STR: +"..point[3]) say("DEX: +"..point[4]) say_reward("Bonus:") say(PetBonus[PetType][2][bon1]..": +"..PetGrade) say(PetBonus[PetType][3][bon2]..": +"..PetGrade) say(PetBonus[PetType][4][bon3]..": +"..PetGrade) say(PetBonus[PetType][5][bon4]..": +"..PetGrade) elseif y == 2 then say_title("Pet System:") say("Reset abilita'") say("che tipo di istruzione vuoi dare al tuo pet?") say_reward("Ricorda il reset puo essere usato ogni 3 giorni") local j = select("Stile Offensivo","Stile Difensivo","Chiudi") if j == 1 then PetSet(i, j) elseif j == 2 then PetSet(i, j) else return end elseif y == 3 then return end end end function show_pet_menu(i) local PetName = data_tool(i, PET_NAME, PET_DATA, PET_READ) local PetRace = PetArray[i][3] local PetFood = PetArray[i][4] local PetGrade = tonumber(GetGrade(i)) local PetLevel = tonumber(data_tool(i, PET_LEVEL, PET_DATA, PET_READ)) local PetExp = tonumber(data_tool(i, PET_EXP, PET_DATA, PET_READ)) local PetNextExp = PetArray[i][5][PetLevel] while true do say_title("Pet System:") say("Benvenuto nel sistema di gestione del pet") say("") say_reward("cosa desideri fare?") local s = select("Stato Pet", "Ciba Pet", "Abilita' Pet", "Altro", "Chiudi" ) if s == 4 then say_title("Pet System:") say("Benvenuto nel sistema di gestione del pet") say("") say_reward("cosa desideri fare?") local z = select( "Cambia Nome", "Manda via", "Indietro", "Chiudi" ) if z == 1 then say_title("Pet System:") say("") say("Assegna un nuovo nome al tuo cucciolo") say("") say_reward("Nome:") local PetNewName = tostring(input()) if PetNewName == "" then say_title("Pet System:") say("") say_reward("Non puoi lasciare l'input vuoto!") return end if PetNewName == nome then say_title("Pet System:") say("") say_reward("Non puoi usare lo stesso nome!") return end data_tool(i, PetNewName.."n"..PetLevel.."n"..PetExp.."n", PET_DATA, PET_WRITE) evoca(i, PET_UNSUMMON) evoca(i, PET_SUMMON) return elseif z == 2 then evoca(i, PET_UNSUMMON) return elseif z == 3 then elseif z == 4 then break end elseif s == 1 then say_title("Pet System:") say("") say("Nome: "..PetName) say("Razza: "..PetRace) say("Livello: "..PetLevel) say("Grado Istruzione: "..PetGrade) say("Exp: "..PetExp.." / "..PetNextExp) say("Salute: "..horse.get_health_pct().."%") say("Resistenza: "..horse.get_stamina_pct().."%") say("Cibo: "..item_name(PetFood)) return elseif s == 2 then if pc.countitem(PetFood) > 0 then say_title("Pet System:") say("") say("Il tuo cucciolo e' felice") say("per l'ottimo spuntino che ha fatto") pc.removeitem(PetFood, 1) horse.feed() return else say_title("Pet System:") say("") say("Per cibare il tuo cucciolo") say("hai bisogno di: "..item_name(PetFood)) say("") return end elseif s == 3 then if PetLevel >= 10 then PetMenuAbi(i) return else say_title("Pet System:") say("") say_reward("Il Pet deve essere almeno Lv 10") return end elseif s == 5 then break end end end function PetGiveExp(i, Point) local PetName = data_tool(i, PET_NAME, PET_DATA, PET_READ) local PetLevel = tonumber(data_tool(i, PET_LEVEL, PET_DATA, PET_READ)) local PetExp = tonumber(data_tool(i, PET_EXP, PET_DATA, PET_READ)) local PetNextExp = PetArray[i][5][PetLevel] if PetLevel == 150 then return end local PetNewExp = PetExp + Point while true do if PetNewExp < PetNextExp then break end PetNewExp = PetNewExp - PetNextExp PetLevel = PetLevel + 1 end data_tool(i, PetName.."n"..PetLevel.."n"..PetNewExp.."n", PET_DATA, PET_WRITE) end function data_tool(i, linea, tipo, modo) local DATA_PATH = "/usr/game/share/locale/turkey/quest/pet/" local LOCAL_PATH = pc.get_name().."/" local x = 1 local file = "" local PET_FILE = "" local PET_BACKUP = "" if tipo == PET_DATA then PET_FILE = PetArray[i][2]..".txt" PET_BACKUP = PetArray[i][2]..".bak" elseif tipo == PET_BONUS then PET_FILE = PetArray[i][2].."_bonus.txt" PET_BACKUP = PetArray[i][2].."_bonus.bak" end if modo == PET_READ then file = io.open(DATA_PATH..LOCAL_PATH..PET_FILE, "r") while true do local line = file:read("*l") if line == nil then break end text = string.gsub(line, "n", "") if x == linea then io.close(file) return text end x = x + 1 end io.close(file) elseif modo == PET_WRITE then os.execute("cd "..DATA_PATH..LOCAL_PATH.." && mv "..PET_FILE.." "..PET_BACKUP) file = io.open(DATA_PATH..LOCAL_PATH..PET_FILE, "w") file:write(linea) io.close(file) os.execute("cd "..DATA_PATH..LOCAL_PATH.." && chmod 777 "..PET_FILE) end end pet_system.quest quest pet_system begin state start begin when 53001.use or 53002.use or 53003.use or 53005.use or 53006.use or 53007.use or 53008.use or 53009.use begin local ItemValue = item.vnum for i = 1, table.getn(PetArray), 1 do if PetArray[i][1] == ItemValue then local PetState = PetArray[i][2] if pc.getqf("pet_index") == 0 then if pc.getqf(PetState) == 0 then local check = inizializza(i) if check != 0 then return end pc.setqf(PetState, 1) end pc.setqf("pet_index", i) evoca(i, PET_SUMMON) else evoca(i, PET_UNSUMMON) pc.setqf("pet_index", 0) end end end end when 20120.click with pc.getqf("pet_index") == 1 begin show_pet_menu(1) end when 20121.click with pc.getqf("pet_index") == 1 begin show_pet_menu(1) end when 20122.click with pc.getqf("pet_index") == 1 begin show_pet_menu(1) end when 20123.click with pc.getqf("pet_index") == 2 begin show_pet_menu(2) end when 20124.click with pc.getqf("pet_index") == 2 begin show_pet_menu(2) end when 20125.click with pc.getqf("pet_index") == 2 begin show_pet_menu(2) end when 20126.click with pc.getqf("pet_index") == 3 begin show_pet_menu(3) end when 20127.click with pc.getqf("pet_index") == 3 begin show_pet_menu(3) end when 20128.click with pc.getqf("pet_index") == 3 begin show_pet_menu(3) end when 20129.click with pc.getqf("pet_index") == 4 begin show_pet_menu(4) end when 20130.click with pc.getqf("pet_index") == 4 begin show_pet_menu(4) end when 20131.click with pc.getqf("pet_index") == 4 begin show_pet_menu(4) end when 20132.click with pc.getqf("pet_index") == 5 begin show_pet_menu(5) end when 20133.click with pc.getqf("pet_index") == 5 begin show_pet_menu(5) end when 20134.click with pc.getqf("pet_index") == 5 begin show_pet_menu(5) end when 20135.click with pc.getqf("pet_index") == 6 begin show_pet_menu(6) end when 20136.click with pc.getqf("pet_index") == 6 begin show_pet_menu(6) end when 20137.click with pc.getqf("pet_index") == 6 begin show_pet_menu(6) end when 20138.click with pc.getqf("pet_index") == 7 begin show_pet_menu(7) end when 20139.click with pc.getqf("pet_index") == 7 begin show_pet_menu(7) end when 20140.click with pc.getqf("pet_index") == 7 begin show_pet_menu(7) end when 20141.click with pc.getqf("pet_index") == 8 begin show_pet_menu(8) end when 20142.click with pc.getqf("pet_index") == 8 begin show_pet_menu(8) end when 20143.click with pc.getqf("pet_index") == 8 begin show_pet_menu(8) end when kill with pc.getqf("pet_index") != 0 begin local i = pc.getqf("pet_index") if pc.get_level() > (npc.get_level() + 15) then return end if pc.get_level() <= npc.get_level() then PetGiveExp(i, 5) elseif pc.get_level() <= (npc.get_level() + 5) then PetGiveExp(i, 4) elseif pc.get_level() <= (npc.get_level() + 10) then PetGiveExp(i, 3) elseif pc.get_level() <= (npc.get_level() + 15) then PetGiveExp(i, 1) end end when logout with pc.getqf("pet_index") != 0 begin local i = pc.getqf("pet_index") evoca(i, PET_UNSUMMON) pc.setqf("pet_index", 0) end when login with pc.getqf("pet_index") != 0 begin local i = pc.getqf("pet_index") evoca(i, PET_UNSUMMON) pc.setqf("pet_index", 0) end end end Problem SYSERR: Jun 2 01:37:14 :: RunState: LUA_ERROR: locale/turkey/quest/pet_system.lua:122: attempt to index local `file' (a nil value) SYSERR: Jun 2 01:37:14 :: WriteRunningStateToSyserr: LUA_ERROR: quest pet_system.start letter Link to comment Share on other sites More sharing options...
djkotsos 101 Posted June 2, 2015 Author Share Posted June 2, 2015 up Link to comment Share on other sites More sharing options...
Ken 904 Posted June 2, 2015 Share Posted June 2, 2015 Line:123 in pet_system.lua file:write("..PetName.."n1n0n") file:write(..PetName.."n1n0n") Kind Regards Ken Do not be sorry, be better. Link to comment Share on other sites More sharing options...
djkotsos 101 Posted June 2, 2015 Author Share Posted June 2, 2015 (edited) Now she does not open the Metin. Edited August 24, 2022 by Metin2 Dev Core X - External 2 Internal Link to comment Share on other sites More sharing options...
djkotsos 101 Posted June 2, 2015 Author Share Posted June 2, 2015 Problem solved. Link to comment Share on other sites More sharing options...
alin2894 14 Posted June 3, 2015 Share Posted June 3, 2015 (edited) #edited Edited June 13, 2015 by alin2894 Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now