Jump to content

[help]bonus viewer(quest)


Recommended Posts

Hey all!

 

There is a big problem.

Do not want to poll the bonuses quest.

Nothing error(qc).

 

Say the syserr:

SYSERR: May 25 22:56:49 :: RunState: LUA_ERROR: [string "switch"]:3: attempt to index field `?' (a nil value)
SYSERR: May 25 22:56:49 :: WriteRunningStateToSyserr: LUA_ERROR: quest switch.start click

looks like this:

quest switch begin  
    state start begin  
		function bonus(id)
			local name
			if id == 1 then
				name = "Max TP"
			elseif id == 2 then
				name = "Max MP"
			elseif id == 3 then
				name = "VIT"
			elseif id == 4 then
				name = "INT"
			elseif id == 5 then
				name = "ERŐ "
			elseif id == 6 then
				name = "ÜGY"
			elseif id == 7 then
				name = "Támadó sebesség"
			elseif id == 8 then
				name = "Mozgási sebesség"
			elseif id == 9 then
				name = "Varázs sebesség"
			elseif id == 10 then
				name = "TP regenerálódás"
			elseif id == 11 then
				name = "MP regenerálódás"
			elseif id == 12 then
				name = "Mérgezési esély"
			elseif id == 13 then
				name = "Ájulási esély"
			elseif id == 14 then
				name = "Lelassulás esély"
			elseif id == 15 then
				name = "Esély kritikus találatra"
			elseif id == 16 then
				name = "Esély átható találatra"
			elseif id == 17 then
				name="Félemberek elleni erő "
			elseif id == 18 then
				name = "Állatok elleni erő "
			elseif id == 19 then
				name = "Ork elleni erő "
			elseif id == 20 then
				name = "Ezotéria elleni erő "
			elseif id == 21 then
				name = "Nemhalottak elleni erő "
			elseif id == 22 then
				name = "Ördög elleni erő "
			elseif id == 23 then
				name = "Veszteségek a TP-böl eltűnnek"
			elseif id == 24 then
				name= "Veszteségek az MP-böl eltűnnek"
			elseif id == 25 then
				name = "Esély az ellenség Mp-inek átvételére"
			elseif id == 26 then
				name = "Esély hogy az MP-t találatnál megtartsd"
			elseif id == 27 then
				name = "Esély a testi támadás kivédésére"
			elseif id == 28 then
				name ="Esély a nyilak elkerülésére"
			elseif id == 29 then
				name = "Kard védelem"
			elseif id == 30 then
				name = "Kétkezes védelem"
			elseif id == 31 then
				name = "Tőr védekezés"
			elseif id == 32 then
				name = "Harang védelem"
			elseif id == 33 then
				name = "Legyező védekezés"
			elseif id == 34 then
				name = "Nyíl ellenállás"
			elseif id == 35 then
				name = "Tűz ellenállás"
			elseif id == 36 then
				name = "Villám ellenállás"
			elseif id == 37 then
				name = "Mágia ellenállás"
			elseif id == 38 then
				name = "Szél ellenállás"
			elseif id == 39 then
				name = "Esély a támadás visszaverésére"
			elseif id == 40 then
				name = "Esély az átok visszaverésére"
			elseif id == 41 then
				name = "Méreg ellenállás"
			elseif id == 42 then
				name = "Esély MP visszaállítására"
			elseif id == 43 then
				name = "Esély EXP bónuszra"
			elseif id == 44 then
				name = "Esély dupla mennyiségű Yang eldobására"
			elseif id == 45 then
				name = "Esély dupla mennyiségű tárgy eldobására"
			elseif id == 46 then
				name = "Ital hatásnövekedés"
			elseif id == 47 then
				name = "Esély TP visszaállítására"
			elseif id == 48 then
				name = "Immunis az ájulás ellen"
			elseif id == 49 then
				name = "Immunis a lelassulás ellen"
			elseif id == 50 then
				name ="Immunis az elesésre"
			elseif id == 52 then
				name = "Íjjász hatótávolság"
			elseif id == 53 then
				name = "Támadó érték"
			elseif id == 54 then
				name = "Védekezés"
			elseif id == 55 then
				name = "Mágikus támadó érték"
			elseif id == 56 then
				name = "Mágikus védelem"
			elseif id == 58 then
				name = "Max. Kitartás"
			elseif id == 59 then
				name = "Harcosok elleni erő "
			elseif id == 60 then
				name = "Nindzsák elleni erő "
			elseif id == 61 then
				name = "Sura elleni erő "
			elseif id == 62 then
				name = "Sámán elleni erő "
			elseif id == 63 then
				name = "Szörny elleni erő "
			elseif id == 64 then
				name = "Támadó érték"
			elseif id == 65 then
				name = "Védekezés"
			elseif id == 66 then
				name = "EXP"
			elseif id == 67 then
				name = "Tárgy ledobási esély"
			elseif id == 68 then
				name = "Yang eldobási esély"
			elseif id == 71 then
				name ="Készség károk"
			elseif id == 72 then
				name ="Átlagos károk"
			elseif id == 73 then
				name = "Készség károkkal szembeni ellenállás"
			elseif id == 74 then
				name = "Átlagos veszteség ellenállás"
			elseif id == 76 then
				name = "EXP bónusz"
			elseif id == 77 then
				name ="Tárgy zsákmányolási esély plusz"
			elseif id == 78 then
				name = "Védekezési esély harcos támadás ellen"
			elseif id == 79 then
				name = "Védekezési esély nindzsatámadás ellen"
			elseif id == 80 then
				name = "Védekezési esély Sura támadás ellen"
			elseif id == 81 then
				name = "Védekezési esély sámántámadás ellen"
			else
				name = tostring("Error "..id)
			end
			
			return name
		end  
        when 9006.take begin
            local table2 = mysql_select("SELECT owner_id, count, vnum, socket0, socket1, socket2, socket3, socket4, socket5, attrtype0, attrvalue0, attrtype1, attrvalue1, attrtype2, attrvalue2, attrtype3, attrvalue3, attrtype4, attrvalue4, attrtype5, attrvalue5, attrtype6, attrvalue6, id FROM player.item WHERE owner_id="..item.get_id()..";")  
            for i = 0,6 do 
                if tonumber(table2["attrtype"..i][1]) != 0 then 
                    namex = switch.bonus(tonumber(table2["attrtype"..i][1])) or "Error" 
                    say((i+1)..". opt: "..namex..": "..table2["attrtype"..i][1]) 
                end 
            end 
        end  
    end  
end  

Thank you in advance for your help.

 

(Sorry bad English of knowledge)

Link to comment
Share on other sites

i think that's all not correct that you wrote.

 

1) Why you use 3500 if and else?

function bonus(id)
 local bonus_list = {
                [0] = "bonus name",
                [1]= "bonus name",
                }
return bonus_list[id]

end

I really don't think that u have bonus on item that doesn't exist.

 

2) bonus and other things have a temporany chache in game memory and u can't read them with sql.

 

Link to comment
Share on other sites

Try this one:

quest switch begin
    state start begin
        function bonus(id)
            local bonus_table = {
                [1] = "Max TP",
                [2] = "Max MP",
                [3] = "VIT",
                [4] = "INT",
                [5] = "ERO ",
                [6] = "UGY",
                [7] = "Tamado sebesseg",
                [8] = "Mozgasi sebesseg",
                [9] = "Varazs sebesseg",
                [10] = "TP regeneralodas",
                [11] = "MP regeneralodas",
                [12] = "Mergezesi esely",
                [13] = "Ajulasi esely",
                [14] = "Lelassulas esely",
                [15] = "Esely kritikus talalatra",
                [16] = "Esely athato talalatra",
                [17] = "Felemberek elleni ero ",
                [18] = "Allatok elleni ero ",
                [19] = "Ork elleni ero ",
                [20] = "Ezoteria elleni ero ",
                [21] = "Nemhalottak elleni ero ",
                [22] = "Ordog elleni ero ",
                [23] = "Vesztesegek a TP-bol eltunnek",
                [24] = "Vesztesegek az MP-bol eltunnek",
                [25] = "Esely az ellenseg Mp-inek atvetelere",
                [26] = "Esely hogy az MP-t talalatnal megtartsd",
                [27] = "Esely a testi tamadas kivedesere",
                [28] = "Esely a nyilak elkerulesere",
                [29] = "Kard vedelem",
                [30] = "Ketkezes vedelem",
                [31] = "Tor vedekezes",
                [32] = "Harang vedelem",
                [33] = "Legyezo vedekezes",
                [34] = "Nyil ellenallas",
                [35] = "Tuz ellenallas",
                [36] = "Villam ellenallas",
                [37] = "Magia ellenallas",
                [38] = "Szel ellenallas",
                [39] = "Esely a tamadas visszaveresere",
                [40] = "Esely az atok visszaveresere",
                [41] = "Mereg ellenallas",
                [42] = "Esely MP visszaallitasara",
                [43] = "Esely EXP bonuszra",
                [44] = "Esely dupla mennyisegu Yang eldobasara",
                [45] = "Esely dupla mennyisegu targy eldobasara",
                [46] = "Ital hatasnovekedes",
                [47] = "Esely TP visszaallitasara",
                [48] = "Immunis az ajulas ellen",
                [49] = "Immunis a lelassulas ellen",
                [50] = "Immunis az elesesre",
                [52] = "Ijjasz hatotavolsag",
                [53] = "Tamado ertek",
                [54] = "Vedekezes",
                [55] = "Magikus tamado ertek",
                [56] = "Magikus vedelem",
                [58] = "Max. Kitartas",
                [59] = "Harcosok elleni ero ",
                [60] = "Nindzsak elleni ero ",
                [61] = "Sura elleni ero ",
                [62] = "Saman elleni ero ",
                [63] = "Szorny elleni ero ",
                [64] = "Tamado ertek",
                [65] = "Vedekezes",
                [66] = "EXP",
                [67] = "Targy ledobasi esely",
                [68] = "Yang eldobasi esely",
                [71] = "Keszseg karok",
                [72] = "Atlagos karok",
                [73] = "Keszseg karokkal szembeni ellenallas",
                [74] = "Atlagos veszteseg ellenallas",
                [76] = "EXP bonusz",
                [77] = "Targy zsakmanyolasi esely plusz",
                [78] = "Vedekezesi esely harcos tamadas ellen",
                [79] = "Vedekezesi esely nindzsatamadas ellen",
                [80] = "Vedekezesi esely Sura tamadas ellen",
                [81] = "Vedekezesi esely samantamadas ellen",
            }
            if id <= 80 then
                return bonus_table[id]
            else
                return "Error"
            end
        end
        when 9006.take begin
            local table2 = mysql_select("SELECT owner_id, count, vnum, socket0, socket1, socket2, socket3, socket4, socket5, attrtype0, attrvalue0, attrtype1, attrvalue1, attrtype2, attrvalue2, attrtype3, attrvalue3, attrtype4, attrvalue4, attrtype5, attrvalue5, attrtype6, attrvalue6, id FROM player.item WHERE owner_id="..item.get_id()..";")
            for i = 0,6 do
                local attrtype = table2["attrtype"..i][1]
                if attrtype ~= nil or attrtype ~= 0 and attrtype <= 81 then
                    bonus_name = switch.bonus(attrtype)
                    num = i+1
                    say(string.format("%s: %s: %s",num,bonus_name,attrtype))
                end
            end
        end
    end
end

 

I did it with tables it's much easier.I think it's gonna work now

Link to comment
Share on other sites

Try this one:

quest switch begin
    state start begin
        function bonus(id)
            local bonus_table = {
                [1] = "Max TP",
                [2] = "Max MP",
                [3] = "VIT",
                [4] = "INT",
                [5] = "ERO ",
                [6] = "UGY",
                [7] = "Tamado sebesseg",
                [8] = "Mozgasi sebesseg",
                [9] = "Varazs sebesseg",
                [10] = "TP regeneralodas",
                [11] = "MP regeneralodas",
                [12] = "Mergezesi esely",
                [13] = "Ajulasi esely",
                [14] = "Lelassulas esely",
                [15] = "Esely kritikus talalatra",
                [16] = "Esely athato talalatra",
                [17] = "Felemberek elleni ero ",
                [18] = "Allatok elleni ero ",
                [19] = "Ork elleni ero ",
                [20] = "Ezoteria elleni ero ",
                [21] = "Nemhalottak elleni ero ",
                [22] = "Ordog elleni ero ",
                [23] = "Vesztesegek a TP-bol eltunnek",
                [24] = "Vesztesegek az MP-bol eltunnek",
                [25] = "Esely az ellenseg Mp-inek atvetelere",
                [26] = "Esely hogy az MP-t talalatnal megtartsd",
                [27] = "Esely a testi tamadas kivedesere",
                [28] = "Esely a nyilak elkerulesere",
                [29] = "Kard vedelem",
                [30] = "Ketkezes vedelem",
                [31] = "Tor vedekezes",
                [32] = "Harang vedelem",
                [33] = "Legyezo vedekezes",
                [34] = "Nyil ellenallas",
                [35] = "Tuz ellenallas",
                [36] = "Villam ellenallas",
                [37] = "Magia ellenallas",
                [38] = "Szel ellenallas",
                [39] = "Esely a tamadas visszaveresere",
                [40] = "Esely az atok visszaveresere",
                [41] = "Mereg ellenallas",
                [42] = "Esely MP visszaallitasara",
                [43] = "Esely EXP bonuszra",
                [44] = "Esely dupla mennyisegu Yang eldobasara",
                [45] = "Esely dupla mennyisegu targy eldobasara",
                [46] = "Ital hatasnovekedes",
                [47] = "Esely TP visszaallitasara",
                [48] = "Immunis az ajulas ellen",
                [49] = "Immunis a lelassulas ellen",
                [50] = "Immunis az elesesre",
                [52] = "Ijjasz hatotavolsag",
                [53] = "Tamado ertek",
                [54] = "Vedekezes",
                [55] = "Magikus tamado ertek",
                [56] = "Magikus vedelem",
                [58] = "Max. Kitartas",
                [59] = "Harcosok elleni ero ",
                [60] = "Nindzsak elleni ero ",
                [61] = "Sura elleni ero ",
                [62] = "Saman elleni ero ",
                [63] = "Szorny elleni ero ",
                [64] = "Tamado ertek",
                [65] = "Vedekezes",
                [66] = "EXP",
                [67] = "Targy ledobasi esely",
                [68] = "Yang eldobasi esely",
                [71] = "Keszseg karok",
                [72] = "Atlagos karok",
                [73] = "Keszseg karokkal szembeni ellenallas",
                [74] = "Atlagos veszteseg ellenallas",
                [76] = "EXP bonusz",
                [77] = "Targy zsakmanyolasi esely plusz",
                [78] = "Vedekezesi esely harcos tamadas ellen",
                [79] = "Vedekezesi esely nindzsatamadas ellen",
                [80] = "Vedekezesi esely Sura tamadas ellen",
                [81] = "Vedekezesi esely samantamadas ellen",
            }
            if id <= 80 then
                return bonus_table[id]
            else
                return "Error"
            end
        end
        when 9006.take begin
            local table2 = mysql_select("SELECT owner_id, count, vnum, socket0, socket1, socket2, socket3, socket4, socket5, attrtype0, attrvalue0, attrtype1, attrvalue1, attrtype2, attrvalue2, attrtype3, attrvalue3, attrtype4, attrvalue4, attrtype5, attrvalue5, attrtype6, attrvalue6, id FROM player.item WHERE owner_id="..item.get_id()..";")
            for i = 0,6 do
                local attrtype = table2["attrtype"..i][1]
                if attrtype ~= nil or attrtype ~= 0 and attrtype <= 81 then
                    bonus_name = switch.bonus(attrtype)
                    num = i+1
                    say(string.format("%s: %s: %s",num,bonus_name,attrtype))
                end
            end
        end
    end
end

 

I did it with tables it's much easier.I think it's gonna work now

 

Thank you, but does not work :(

SYSERR: May 26 00:27:50 :: RunState: LUA_ERROR: [string "optolo"]:3: attempt to index field `?' (a nil value)
SYSERR: May 26 00:27:50 :: WriteRunningStateToSyserr: LUA_ERROR: quest optolo.start click

mysql_query/select function:

db_user="root"
db_pass="...."
db_host="localhost"

function mysql_select(query,notselect)
    local tmp=number(11111111,99999999)
	os.execute('mysql -h '..db_host..' -u '..db_user..' -p'..db_pass..' -N -e '..string.format("%q",query)..' 2>&1 > /tmp/'..tmp)
	
	if not notselect then
		local res,i={},1
		local f,e=io.open("/tmp/"..tmp)
		if f then
			local line=f:read("*l")
			while line do
				res[i]={}
				string.gsub(line,"([^t]+)t*", function(s)
					table.insert(res[i],s)
				end)
				i=i+1
				line=f:read("*l")
			end
			f:close()
			os.execute("rm /tmp/"..tmp)
		end
		return res
	end
end 

function mysql_notselect(query)
	return mysql_select(query,true)
end

mysql_query = mysql_select
Link to comment
Share on other sites

thank you!

SYSERR: May 26 16:14:55 :: RunState: LUA_ERROR: [string "optolo"]:2: attempt to call global `mysql_select' (a nil value)
SYSERR: May 26 16:14:55 :: WriteRunningStateToSyserr: LUA_ERROR: quest optolo.start click
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) -- für MySQL51
    os.execute('mysql '..pre..' -e'..string.format('%q',query)..' > '..fi) -- für MySQL55
    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,
        out[i-1]               = out[i-1] or {}
        out[i-1][a]            = tonumber( or b or 'NULL'
        out[t[1][a]]           = out[t[1][a]] or {}
        out[t[1][a]][i-1]      = tonumber( or b or 'NULL'
    end) end
    return out
end
Link to comment
Share on other sites

:(

RunState: LUA_ERROR: [string "optolo"]:4: attempt to index field `?' (a nil value)
local table2 = mysql_query("SELECT owner_id, count, vnum, socket0, socket1, socket2, socket3, socket4, socket5, attrtype0, attrvalue0, attrtype1, attrvalue1, attrtype2, attrvalue2, attrtype3, attrvalue3, attrtype4, attrvalue4, attrtype5, attrvalue5, attrtype6, attrvalue6, id FROM player.item WHERE owner_id="..item.get_id()..";")
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

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.