Jump to content
  • 0

mysql query - quest


Karbust

Question

  • Web Developer

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"...

QJ0orbR.png

Metin2 Icon Database

Link to comment
Share on other sites

23 answers to this question

Recommended Posts

  • 0
  • Bronze

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
Share on other sites

  • 0

.. 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
Share on other sites

  • 0
  • 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
Share on other sites

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

like this?

QJ0orbR.png

Metin2 Icon Database

Link to comment
Share on other sites

  • 0
  • Web Developer

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

QJ0orbR.png

Metin2 Icon Database

Link to comment
Share on other sites

  • 0

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
Share on other sites

  • 0
  • Web Developer

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...

QJ0orbR.png

Metin2 Icon Database

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Activity

    1. 11

      When Uninstalling Gaya System

    2. 11

      When Uninstalling Gaya System

    3. 11

      When Uninstalling Gaya System

    4. 11

      When Uninstalling Gaya System

    5. 11

      When Uninstalling Gaya System

    6. 11

      When Uninstalling Gaya System

    7. 11

      When Uninstalling Gaya System

    8. 11

      When Uninstalling Gaya System

    9. 8

      Use Items with the Effect of Use

  • Recently Browsing

    • No registered users viewing this page.
×
×
  • 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.