GTX Posted April 10, 2012 Posted April 10, 2012 Hello. I was trying to make "protection" for my script. function CHECKING() result = mysql_query(connect_mysql_check, "SELECT name FROM granted") if (result) then while true do local row = mysql_fetch_assoc(result) if not row then break end if getParticalServerName(row.name) then CONNECT() else WRONG() end end end mysql_free_result(result) end connect_mysql_check = mysql_connect(host, user, password, database_, 3306, "/var/run/mysqld/mysqld.sock") if not connect_mysql_check then outputChatBox("#FF8800[TOPTIMES] #FF6565Could not connect with MySQL Server.", getRootElement(), 255, 255, 255, true) else setTimer(CHECKING, 500, 1) end local row = mysql_fetch_assoc(result) at line 4 returns nil. Why? Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS. Developer and owner of https://projectbea.st - Project Beast
Jaysds1 Posted April 10, 2012 Posted April 10, 2012 (edited) try this: function CHECKING() result = mysql_query(connect_mysql_check, "SELECT * FROM granted") if (result) then local row = mysql_fetch_assoc(result) if not row then errno=mysql_errno (connect_mysql_check) outputDebugString("Sorry, the result was not returned. Here's a error number: "..errno.." .",1) break end if getParticalServerName(row.name) then CONNECT() else WRONG() end end end mysql_free_result(result) Edited April 10, 2012 by Guest My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
GTX Posted April 10, 2012 Author Posted April 10, 2012 Doesn't work. Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS. Developer and owner of https://projectbea.st - Project Beast
Jaysds1 Posted April 10, 2012 Posted April 10, 2012 try using dbConnect() dbQuery() dbExec() dbQuery() dbPoll() dbFree () My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
GTX Posted April 10, 2012 Author Posted April 10, 2012 I'd like to use these, but in this case I will use mysql_connect, mysql_query... I can't find solution why it returns nil... Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS. Developer and owner of https://projectbea.st - Project Beast
Jaysds1 Posted April 10, 2012 Posted April 10, 2012 I edited the code again... If an error number comes up, search this site for it: MySQL-Error codes My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
GTX Posted April 10, 2012 Author Posted April 10, 2012 0 came out. Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS. Developer and owner of https://projectbea.st - Project Beast
Jaysds1 Posted April 10, 2012 Posted April 10, 2012 0 came out. Does that table exist? My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
GTX Posted April 10, 2012 Author Posted April 10, 2012 Which table? row? Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS. Developer and owner of https://projectbea.st - Project Beast
Jaysds1 Posted April 10, 2012 Posted April 10, 2012 Which table? row? Table: granted Plus, the "name" is not defined... What name do you want to get? My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
GTX Posted April 10, 2012 Author Posted April 10, 2012 "name" is column. I want to get rows and if row matches server name, function CONNECT activates, else WRONG activates. Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS. Developer and owner of https://projectbea.st - Project Beast
Jaysds1 Posted April 10, 2012 Posted April 10, 2012 The server seem like it can't get the column and table... I've edited the code again, if there's no debugstring then the column doesn't exit. and if there is then the table granted doesn't exit. My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
GTX Posted April 10, 2012 Author Posted April 10, 2012 Still 0. Nothing is missing: http://shrani.si/f/13/8/vWU33cV/2012-04-101532.png Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS. Developer and owner of https://projectbea.st - Project Beast
Jaysds1 Posted April 10, 2012 Posted April 10, 2012 now, try running that query using this: "SELECT name FROM granted" Post a screenshot after. My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
GTX Posted April 10, 2012 Author Posted April 10, 2012 Where should I run query? At the web? If so: http://shrani.si/f/S/FX/2smLn8LW/2012-04-101540.png if at the server, it returns same as before (nil). Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS. Developer and owner of https://projectbea.st - Project Beast
Jaysds1 Posted April 10, 2012 Posted April 10, 2012 This is what I got from the wiki: mysql_query In case of error this function returns nil. I don't see any errors in it but the wiki is saying there's an error. My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
GTX Posted April 10, 2012 Author Posted April 10, 2012 Hmm, I think mysql_fetch_assoc is returning nil but I don't know why. Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS. Developer and owner of https://projectbea.st - Project Beast
Jaysds1 Posted April 10, 2012 Posted April 10, 2012 oh, snap, srry, I was looking at something else EDIT: try this: connect_mysql_check = mysql_connect(host, user, password, database_, 3306, "/var/run/mysqld/mysqld.sock") if not connect_mysql_check then outputChatBox("#FF8800[TOPTIMES] #FF6565Could not connect with MySQL Server.",root, 255, 255, 255, true) else setTimer(CHECKING, 500, 1) end function CHECKING() result = mysql_query(connect_mysql_check, "SELECT name FROM granted") if (result) then local row = mysql_fetch_assoc(result) if not row then outputDebugString("Sorry, but the row was not returned") end if getParticalServerName(row.name) then CONNECT() else WRONG() end end mysql_free_result(result) end My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
drk Posted April 10, 2012 Posted April 10, 2012 Hello. I was trying to make "protection" for my script. function CHECKING() result = mysql_query(connect_mysql_check, "SELECT name FROM granted") if (result) then while true do local row = mysql_fetch_assoc(result) if not row then break end if getParticalServerName(row.name) then CONNECT() else WRONG() end end end mysql_free_result(result) end connect_mysql_check = mysql_connect(host, user, password, database_, 3306, "/var/run/mysqld/mysqld.sock") if not connect_mysql_check then outputChatBox("#FF8800[TOPTIMES] #FF6565Could not connect with MySQL Server.", getRootElement(), 255, 255, 255, true) else setTimer(CHECKING, 500, 1) end local row = mysql_fetch_assoc(result) at line 4 returns nil. Why? I think MySQL need ` `. Like this: mysql_query ( connect_mysql_check, "SELECT `name` FROM `granted`" ) Also, check if connect_mysql_check returns 1. EPT Team Server Development: 0% Learning C++ | C++ is amazing
Jaysds1 Posted April 10, 2012 Posted April 10, 2012 I think MySQL need ` `.Like this: mysql_query ( connect_mysql_check, "SELECT `name` FROM `granted`" ) Also, check if connect_mysql_check returns 1. Oh,ya, nice thinking, i totally forgot about that part, nice work and the connect_mysql_check returned... My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now