Suainzettello 23 Posted August 17, 2016 Share Posted August 17, 2016 Hi all, I have a problem with the new function "mysql_direct_query" of Lollo91, (for those not familiar) -> http://www.elitepvpers.com/forum/metin2-pserver-guides-strategies/3327940-release-mysql_direct_query-get_table_postfix-mysql_escape_string-written-c-lua.html After implementing all in the source, I have this quest: Spoiler quest bantool begin state start begin when letter with pc.is_gm() begin send_letter("Ban-tool") end when button or info begin -- Tanto per sicurezza... if not pc.is_gm() then return end local menu = {"Ban player", "Remove ban", "Close"} say_title("Ban-tool") say("Select the function:[ENTER]") local s = select_table(menu) if s == table.getn(menu) then return end -- local name repeat say_title(menu) say("Insert name of player:[ENTER]") name = input() if name == "" then say("The name you entered is invalid.[ENTER]") return end say_title(menu) say_reward("You have entered: "..name) say("Are you sure you want to continue?[ENTER]") local a = select("Yes", "No, repeat", "Cancel") if a == 3 then return elseif a == 1 then break end until false say_title(menu) -- local result, query_result = mysql_direct_query("SELECT player.account_id FROM player.player WHERE player.name='"..name.."' limit 1;") -- Controllo errori if result != 0 then say("There was an error.") say("Description of error:") say_reward(query_result) return end local AccStatus = {"BLOCK","OK"} -- local AccID = tonumber(query_result[1][1]) -- if AccID == nil then say("The player does not exist.[ENTER]") return end -- Ban/sban player result, query_result = mysql_direct_query("UPDATE account.account SET account.status='"..AccStatus.."' WHERE account.id='"..AccID.."' limit 1;") -- Controllo errori if result != 0 then say("There was an error.") say("Description of error:") say_reward(query_result) return end say("Successfully completed operation![ENTER]") end endend The problem is this: say("There was an error.") say("Description of error:")Why the query does not work? Thank you! Link to comment Share on other sites More sharing options...
Over 1 Posted August 17, 2016 Share Posted August 17, 2016 Hi, Did you try the request inside the navicat console ? Regards Link to comment Share on other sites More sharing options...
Suainzettello 23 Posted August 17, 2016 Author Share Posted August 17, 2016 No, i don't try... Link to comment Share on other sites More sharing options...
Over 1 Posted August 18, 2016 Share Posted August 18, 2016 Hmm You should ! Unless you just troll . But why don't use mysql_query instead of mysql_direct_query ? Mysql_query should do the trick. Link to comment Share on other sites More sharing options...
Honorable Member martysama0134 7174 Posted August 18, 2016 Honorable Member Share Posted August 18, 2016 It's not query_result[1][1], but query_result[1].account_id Check out my GitHub Link to comment Share on other sites More sharing options...
Suainzettello 23 Posted August 18, 2016 Author Share Posted August 18, 2016 1 hour ago, martysama0134 said: It's not query_result[1][1], but query_result[1].account_id Fai un esempio con la quest per favore Link to comment Share on other sites More sharing options...
Honorable Member martysama0134 7174 Posted August 18, 2016 Honorable Member Share Posted August 18, 2016 (edited) 5 hours ago, Suainzettello said: Fai un esempio con la quest per favore local query = string.format("SELECT account_id FROM player%s WHERE name='%s' limit 1;", get_table_postfix(), mysql_escape_string(pc.get_name())) syschat(query) local aff_result, query_result = mysql_direct_query(query) syschat(aff_result) syschat(aff_result==1 and query_result[1].account_id or "NONE") This example should suffice Edited August 20, 2022 by Metin2 Dev Core X - External 2 Internal Check out my GitHub 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