Jump to content

Recommended Posts

  • Management

Hi

 

Today I was starting the pvm event on my server, and the NPC where is the teleport doesn't appears nothing, just the "OK" button.

 

Start the event:

if evento == 1 then
								game.set_event_flag("evento_pvm", 1)
								game.set_event_flag("lvl_pvm", lvl)
								notice_all("Evento PvM está agora ativo!")
								notice_all("Entradas pelo "..mob_name(10674).."")
								notice_all("Nível Mínimo: "..lvl.."")
								mysql_query("INSERT INTO log.log_eventos (id, gm, tipo, x, y, lvl, data) VALUES ('', '"..name.."', 'pvm', '"..x.."', '"..y.."', '"..lvl.."', '"..data1.."');")
								mysql_query("INSERT INTO player.eventos (id, gm, tipo, x, y, lvl, data) VALUES ('', '"..name.."', 'pvm', '"..x.."', '"..y.."', '"..lvl.."', '"..data1.."');")
							elseif evento == 2 then
								return
							end

This appears on virtual box: (a couple of lines like those)

mysql: not found
mysql: not found
mysql: not found
mysql: not found

Entrance:

if game.get_event_flag("evento_pvm") == 1 then
				local x = mysql_query("SELECT x FROM player.eventos WHERE tipo='pvm'")
				local y = mysql_query("SELECT y FROM player.eventos WHERE tipo='pvm'")	
				local pvm = select ("Participar PvM", "Cancelar")
				if pvm == 1 then
					if pc.get_level() >= game.get_event_flag("lvl_pvm") then
						pc.warp(x.x[1], y.y[1])
					else
						setbgimage('level_bg.tga')					
						say_color("black", "                Não tens nível suficiente!")
					end
				elseif pvm == 2 then
					return
				end
			end

This was working the last time I started the server, but now isn't...

 

Someone nows why?

 

Thanks

 

King Regards

 

P.S.: If the event is deactivated appears the line saying "Não tens nível suficiente"...

raw

raw

Link to comment
https://metin2.dev/topic/4415-mysql-query-quest/
Share on other sites

  • Active Member

Try to put a say("test") in front of 

local x = mysql_query("SELECT x FROM player.eventos WHERE tipo='pvm'")
local y = mysql_query("SELECT y FROM player.eventos WHERE tipo='pvm'") 
 
if this doesn't work then the quest is stuck at
local x = mysql_query("SELECT x FROM player.eventos WHERE tipo='pvm'")
local y = mysql_query("SELECT y FROM player.eventos WHERE tipo='pvm'") 
 
Also try
 
local x = mysql_query("SELECT x FROM player.eventos WHERE tipo="pvm"")
local y = mysql_query("SELECT y FROM player.eventos WHERE tipo="pvm"") 
 
or
 
local x = mysql_query('SELECT x FROM player.eventos WHERE tipo="pvm"')
local y = mysql_query('SELECT y FROM player.eventos WHERE tipo="pvm"') 
 
 
  • Love 1
Link to comment
https://metin2.dev/topic/4415-mysql-query-quest/#findComment-28242
Share on other sites

  • Management

I saw another quest (vouchers) who don't use mysql_query, uses os.execute to execute a query on db, and doesn't work too...

I think its problem with the quests communicating with the db...

raw

raw

Link to comment
https://metin2.dev/topic/4415-mysql-query-quest/#findComment-28247
Share on other sites

  • Active Member

or the function itself, i had issues with that function too and i aborted the project what i was working to...

  • Love 1
Link to comment
https://metin2.dev/topic/4415-mysql-query-quest/#findComment-28249
Share on other sites

  • Management

syserr db is clean

 

mysql syserr: http://pastebin.com/JjV1b30e

 

syserr channel1/core1 (where are the maps where I use the quests):

 

lots of lines like those: http://pastebin.com/Pav61J2i

raw

raw

Link to comment
https://metin2.dev/topic/4415-mysql-query-quest/#findComment-28277
Share on other sites

.. Ask the right question.

 

 


mysql: not found
mysql: not found
mysql: not found
mysql: not found

 

 
I guess that's pretty clear. At least for me.
Just execute the following command:
pkg_info
if you're using the new version of pkg then just do:
pkg info
Post the results.
I guess the mysql-client package is missing therefore it's no surprise that your server is unable to find the mysql command.
  • Love 1

what would you do in a battle of survival?

It's coming soon

Link to comment
https://metin2.dev/topic/4415-mysql-query-quest/#findComment-29219
Share on other sites

  • Honorable Member

This appears on virtual box: (a couple of lines like those)

mysql: not found
mysql: not found
mysql: not found
mysql: not found

Find the definition of the mysql_query function and, inside the io.execute, change "mysql" with "/usr/local/bin/mysql".

# find /usr/local/bin -name mysql
/usr/local/bin/mysql
Usually, you should have that file if you installed mysql correctly.

If yes:

Probably, the shell doesn't have the relative path successfully bound:

# echo $PATH
/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/root/bin
In this case, you can decide to use an absolute path or add the missing folder in the relative environment variable.

NB: This is a common issue when you use crontab.

Edited by martysama0134
  • Love 1
Link to comment
https://metin2.dev/topic/4415-mysql-query-quest/#findComment-29220
Share on other sites

  • Management
os.execute('/usr/local/bin/mysql '..pre..' -e'..string.format('%q',query)..' > '..fi)
os.execute("/usr/local/bin/mysql -u mt2 --password='mt2!@#' account --execute='UPDATE account SET coins = coins + ".. mycash .." WHERE id = ".. pc.get_account_id() ..";'")

like this?

raw

raw

Link to comment
https://metin2.dev/topic/4415-mysql-query-quest/#findComment-29221
Share on other sites

  • Honorable Member

os.execute('/usr/local/bin/mysql ...the-rest-of-the-command...')

like this?

Yes, but you should also check whether you have this file or not:

# ls -l /usr/local/bin/mysql
-rwxr-xr-x  1 root  wheel  3333736 Nov 16 03:49 /usr/local/bin/mysql
  • Love 1
Link to comment
https://metin2.dev/topic/4415-mysql-query-quest/#findComment-29222
Share on other sites

  • Management

That part is now working right, thanks!

 

But the mysql_query function isn't working :S

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('/usr/local/bin/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

I have FreeBSD 8.2, I guess is MySQL 5.1, but I tried with the two and doesnt' work...

 

My old mysql_query function:

function mysql_query(query,user,pw,db,ip) -- Gibt ALLE Werte als STR zurück.   
	local var = {}
	var.pre = ''
	if ip ~= nil then
		var.pre = var.pre..' -h'..ip
	end
	if user ~= nil then
		var.pre = var.pre..' -u'..user
	end
	if pw ~= nil then
		var.pre = var.pre..' -p'..pw
	end
	if db ~= nil then
		var.pre = var.pre..' -D'..db
	end
	var.scriptfile = 'sc_'..pc.get_name()
	var.outputfile = 'op_'..pc.get_name()
	query= string.gsub(query,'"',"'")
	var.str = "/usr/local/bin/mysql "..var.pre.." < "..var.scriptfile.." > "..var.outputfile
	script = io.open(var.scriptfile,"w")
	script:write(query)
	script:close()
	os.execute(var.str)
	local g = {}
	local f = io.open(var.outputfile)
	g.i = 0
	g.li={}
	g.out= {}
    g.count = 0
	for line in f:lines() do
		g.i = g.i+1
		g.li[g.i] = line
	end
    -- TESTDEBUG
    if g.li[1] == nil then
        return "ERROR"
    end
    if string.len(g.li[1]) == 0 then
        return "ERROR"
    end
    -- TESTDEBUG ENDE
    -- Abfrage später :  if out == "ERROR" then return end << Beispiel!!
	g.fields = split(g.li[1],'	')
	table.foreachi(g.fields,
			function(lb,ln)
				g.out[ln] = {}
			end)
	table.foreachi(g.li,
	function(ou1,ou2)
	if ou1 > 1 then
		local la = split(ou2,'	')
        g.count = g.count+1
		table.foreachi(g.fields,
			function(lb,ln)
				g.out[ln][(ou1-1)] = la[lb]
			end)
	end
	end
	)
	f:close()
    -- Alle Strings, die nur Zahlen beinhalten, in Zahlen umwandeln
    -- Zeigt gleichzeitig die Nutzungsmöglichkeit vom von mir modifizierten tonumber()
    table.foreach(g.out,
        function(i,l)
        table.foreach(l,
            function(i2,l2)
                local d,e = tonumber(l2)
                if e then
                    g.out[i][i2] = d
                end
            end
        )
        end
    )
	g.out.__data = {}                   -- Zur Ausgabe Queryspezifischer Daten
	g.out.__data.fields = g.fields
    g.out.__data.lines  = g.count
    g.out.__data.user = user
    g.out.__data.pass = pw
    g.out.__data.host = ip
    g.out.__data.db = db
    g.out.__data.query = query
	os.execute("rm "..var.scriptfile)
	os.execute("rm "..var.outputfile)
	return g.out
end

raw

raw

Link to comment
https://metin2.dev/topic/4415-mysql-query-quest/#findComment-29224
Share on other sites

Hello, your code line os.execute need full path to mysql file.

This is also common to happen on scripts in fbsd.

 

Change this:

os.execute('mysql '..pre..' --e='..string.format('%q',query)..' > '..fi) -- für MySQL51

 

to

os.execute('/usr/local/bin/mysql '..pre..' --e='..string.format('%q',query)..' > '..fi) -- für MySQL51

 

it will work. ;)

 

Good 2015 to all. :)

 

many edits.. -> rusty English.. eheh!

EDIT2:

You may also change:

    os.execute('mysql '..pre..' --e='..string.format('%q',query)..' > '..fi) -- für MySQL51
    --os.execute('/usr/local/bin/mysql '..pre..' -e'..string.format('%q',query)..' > '..fi) -- für MySQL55
to
    --os.execute('mysql '..pre..' --e='..string.format('%q',query)..' > '..fi) -- für MySQL51
    os.execute('/usr/local/bin/mysql '..pre..' -e'..string.format('%q',query)..' > '..fi) -- für MySQL55
 
If you're using mysql 5.5...
  • Love 1
Link to comment
https://metin2.dev/topic/4415-mysql-query-quest/#findComment-29233
Share on other sites

  • Management

Thanks Dave

But has I said to you on private, on function give_dm (vouchers) who use is.execute I changed mysql to the complete directory, and worked by on the function mysql_query isn't working...

raw

raw

Link to comment
https://metin2.dev/topic/4415-mysql-query-quest/#findComment-29242
Share on other sites

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please use https://metin2.download/ when uploading files smaller than 100MB, otherwise the approval will take longer due to manual upload.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • 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.