amosth 9 Posted August 17, 2018 Share Posted August 17, 2018 Hello friends, I have created a column called "ok" in account, now I need to click on npc to check this example column: column "ok" = 0 if the value of the "ok" column is 0 goes from the error message, if the value of the "ok" column is 1 of the correct message. I hope you could understand. Thank you for the attention. when info or button begin say("blablabla") local f = select("bla si","bla no") if f == 1 then local c,query = mysql_direct_query("SELECT * FROM account.account WHERE id = '"..pc.get_account_id().."' LIMIT 1;") if query[1].ok < 1 then say'existe un valor menor a 1' else say'existe un valor de 1' end end if f == 2 then return end end not work =/ Link to comment Share on other sites More sharing options...
Premium tierrilopes 452 Posted August 17, 2018 Premium Share Posted August 17, 2018 (edited) If you created a new column called ok, you can just select that specific column instead of everything. SELECT * FROM account.account Will be SELECT new_column FROM account.account Here the example querying only the create_time: Edited August 25, 2022 by Metin2 Dev Core X - External 2 Internal 1 Link to comment Share on other sites More sharing options...
Bot Metin2 Dev 4929 Posted August 17, 2018 Bot Share Posted August 17, 2018 This is really usefull if you are newbie into a development. But be aware of possible SQL injection (not this case). It is better to do this within a packets system. Link to comment Share on other sites More sharing options...
amosth 9 Posted August 17, 2018 Author Share Posted August 17, 2018 9 hours ago, Chyu ^^ said: This is really usefull if you are newbie into a development. But be aware of possible SQL injection (not this case). It is better to do this within a packets system. I'll look into this. Could you help me with this case? Link to comment Share on other sites More sharing options...
Bot Metin2 Dev 4929 Posted August 17, 2018 Bot Share Posted August 17, 2018 Well actually I still can't manage connection with database via packets. Link to comment Share on other sites More sharing options...
amosth 9 Posted August 18, 2018 Author Share Posted August 18, 2018 11 hours ago, Chyu ^^ said: Well actually I still can't manage connection with database via packets. So can you help me with the quest? Link to comment Share on other sites More sharing options...
Premium Syreldar 1886 Posted August 18, 2018 Premium Share Posted August 18, 2018 quest ok begin state start begin when info or button begin say("blablabla") if (select("bla si", "bla no") == 1) then local _, query = mysql_direct_query(string.format("SELECT ok FROM account.account WHERE id = %d LIMIT 1;", pc.get_account_id())); say(string.format("value: %d;", query[1].ok)) end -- if end -- when end -- state end -- quest make sure your 'ok' column only accepts "int" as value types. 1 "Nothing's free in this life. Ignorant people have an obligation to make up for their ignorance by paying those who help them. Either you got the brains or cash, if you lack both you're useless." Syreldar Link to comment Share on other sites More sharing options...
amosth 9 Posted August 19, 2018 Author Share Posted August 19, 2018 18 hours ago, Syreldar said: quest ok begin state start begin when info or button begin say("blablabla") if (select("bla si", "bla no") == 1) then local _, query = mysql_direct_query(string.format("SELECT ok FROM account.account WHERE id = %d LIMIT 1;", pc.get_account_id())); say(string.format("value: %d;", query[1].ok)) end -- if end -- when end -- state end -- quest make sure your 'ok' column only accepts "int" as value types. Thanks man if (select("bla si", "bla no") == 1) then local a_, query = mysql_direct_query(string.format("SELECT ok FROM account.account WHERE id = %d LIMIT 1;", pc.get_account_id())); if a_== id then say("ok") else say("no") end --say(string.format("value: %d;", query[1].ok)) end -- if one last question, how do I check 2 column in the same result? Example: if (select("bla si", "bla no") == 1) then local a_, query = mysql_direct_query(string.format("SELECT ok,life FROM account.account WHERE id = %d LIMIT 1;", pc.get_account_id())); if a_== id then say("ok") else say("no") end end -- if EDIT: Is not working =/ if (select("bla si", "bla no") == 1) then local a_, query = mysql_direct_query(string.format("SELECT ok FROM account.account WHERE id = %d LIMIT 1;", pc.get_account_id())); if a_== id then say("ok") else say("no") end --say(string.format("value: %d;", query[1].ok)) end -- if Link to comment Share on other sites More sharing options...
amosth 9 Posted August 24, 2018 Author Share Posted August 24, 2018 Please someone help me with this is very important. 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