Register for your free account! | Forgot your password?

Go Back   elitepvpers > Popular Games > Metin2 > Metin2 Private Server
You last visited: Today at 11:27

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Offline-Message-System lua problem

Discussion on Offline-Message-System lua problem within the Metin2 Private Server forum part of the Metin2 category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Apr 2014
Posts: 16
Received Thanks: 0
Question Offline-Message-System lua problem

I have a little problem with Offline-Message-System lua function with this 2 functions:i tried this:
Code:
function find_player_by_name(name)
    return mysql_query("SELECT count(name) FROM player.player WHERE name = '"..name.."';")[1][1] > 0
end  
function get_playerid_by_playername(name)
    return mysql_query("SELECT id FROM player.player WHERE name = '"..name.."';").id[1]
end
And this:
Code:
function find_player_by_name(name)
    local a = mysql_query('SELECT COUNT(*) AS exist FROM player.player WHERE name="'..name..'"')
    if a.exist[1] == 1 then return true else return false end
end

function get_playerid_by_playername(name)
    local a = mysql_query('SELECT id FROM player.player WHERE name="'..name..'"')
    return a.id[1]
end
the mysql_query is this:
Code:
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)

   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, b)
       out[i-1]              = out[i-1] or {}
       out[i-1][a]           = tonumber(b) or b
       out[t[1][a]]          = out[t[1][a]] or {}
       out[t[1][a]][i-1]     = tonumber(b) or b
   end) end
   return out
end
the part in the quest that uses that functions in:
Code:
				local playerId = pc.get_player_id()  -- Nachricht an sich selbst schreiben lassen. ist meine PLAYER ID !!!!
				pc.change_money(-MESSAGES[playerId].MONEY)
				messagesystem_1.write_message(MESSAGES[playerId].ADDRESS, MESSAGES[playerId].NAME , MESSAGES[playerId].SUBJECT, MESSAGES[playerId].TEXT, MESSAGES[playerId].ITEM, MESSAGES[playerId].MONEY)
				messagesystem_1.reload_msg('POSTBOXOUT')
			elseif cmd[1] == 'NEWMESSAGE' then
				if not find_player_by_name(cmd[2]) then syschat'Dieser Spielername existiert nicht.' return end
				item_ = tonumber(cmd[5])
				pc.setqf('ITEMCOUNT',0)
				if item_ != -1 then
					item.select_cell(item_)
					local attr = {{item.get_attribute(0)}, {item.get_attribute(1)}, {item.get_attribute(2)}, {item.get_attribute(3)},{item.get_attribute(4)},{item.get_attribute(5)}, {item.get_attribute(6)}}
					local socket, itemVnum, itemCount = {item.get_socket(0), item.get_socket(1), item.get_socket(2),item.get_socket(3),item.get_socket(4),item.get_socket(5)}, item.get_vnum(), item.get_count() 
					if not messagesystem_1.item_can_send(itemVnum) then syschat'Dieses Item kann nicht versendet werden.' return end
					item_ = itemVnum.."#"..itemCount.."#"..socket[1].."#"..socket[2].."#"..socket[3].."#"..socket[4].."#"..socket[5].."#"..socket[6].."#"..attr[1][1].."#"..attr[1][2].."#"..attr[2][1].."#"..attr[2][2].."#"..attr[3][1].."#"..attr[3][2].."#"..attr[4][1].."#"..attr[4][2].."#"..attr[5][1].."#"..attr[5][2].."#"..attr[6][1].."#"..attr[6][2].."#"..attr[7][1].."#"..attr[7][2]
					pc.setqf('ITEMCOUNT', pc.count_item(itemVnum))
				end
				MESSAGES[pc.get_player_id()] = {
					['ADDRESS'] = get_playerid_by_playername(cmd[2]),
					['NAME'] = cmd[2],
					['SUBJECT'] = cmd[3],
					['TEXT'] = "",
					['MONEY'] = cmd[4],
					['ITEM'] =  item_,
				}
				cmdchat('MESSAGESYSTEM NEWMESSAGE_COMPLETE')
			elseif cmd[1] == 'TEXT' then
				MESSAGES[pc.get_player_id()].TEXT = MESSAGES[pc.get_player_id()].TEXT..cmd[2]
				cmdchat('MESSAGESYSTEM TEXT_COMPLETE')
			elseif cmd[1] == 'DELETE_MSG' then
				messagesystem_1.delete_msg(cmd[2],tonumber(cmd[3]))
			elseif cmd[1] == 'TAKE_ITEM' then
And the error i get is this:
Code:
SYSERR: Apr  2 00:28:04 :: RunState: LUA_ERROR: [string "messagesystem_1"]:8: attempt to index field `?' (a nil value)
SYSERR: Apr  2 00:28:04 :: WriteRunningStateToSyserr: LUA_ERROR: quest messagesystem_1.start click
I tried with mysql_query functions from source but no result....Other errors.
Any lua developer to help me?I think is from that 2 functions but i am not sure.It could be from the mysql_query function or the quest?
Another way to make it work?
tigerstefan is offline  
Old 04/03/2016, 18:20   #2
 
elite*gold: 0
Join Date: Apr 2014
Posts: 16
Received Thanks: 0
No one?With a little knolage in lua?
tigerstefan is offline  
Old 04/11/2016, 23:21   #3
 
elite*gold: 0
Join Date: Apr 2014
Posts: 16
Received Thanks: 0
Up
tigerstefan is offline  
Old 04/12/2016, 09:23   #4
 
IceFear's Avatar
 
elite*gold: 0
Join Date: Sep 2010
Posts: 79
Received Thanks: 10
I don't know what the problem with the message system is, but if you execute the queries like that, you will will definetely have a problem with SQL injections.
IceFear is offline  
Reply

Tags
offline message system


Similar Threads Similar Threads
[R]Offline Message System
06/18/2013 - Metin2 PServer Guides & Strategies - 11 Replies
Hi dear people epvp. :pimp: Some turks said that my nickname used elsewhere. My answers : f**k *** :bandit: Anyway let's move on reach topic. First Pictures : http://i.imgur.com/F3tGUDD.jpg
[Release] Iphone-System (Offline Message System)
04/19/2013 - Metin2 PServer Guides & Strategies - 74 Replies
Da ich dafür kein nutzen mehr habe und dies nun alles per Python geregelt habe (ein Dankeschön an .Nova, der mir dabei geholfen hat). Release ich mein iPhone System. mit dem konnte man Nachrichten ingame an andere Spieler senden. Lief knapp halbes (server ist seit 2 monaten down) jahr und bisher tratt auch nie ein Fehler auf... Quest ist im Anhang sowie die Datenbank... Fuktionen:



All times are GMT +2. The time now is 11:27.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.