Extremo Posted August 3, 2010 Share Posted August 3, 2010 Hello MTA Community, Today I've decided to actually get into MTA coding. So, as I already have experience in scripting such things, I wanted to start straight ahead into detail and test out if the MTA-MySQL module was working correctly. I made this small clientside script here: -- Testing MySQL Module function TestSQL(thePlayer, command) outputChatBox("#FF0000Works", thePlayer); con = mysql_connect("...","...","...","..."); outputChatBox("#FF0000Connection incomming....", thePlayer); if ( not con ) then -- The connection failed outputChatBox("#FF0000Unable to connect to the MySQL server", thePlayer); else outputChatBox("#FF0000Connected!", thePlayer); end outputChatBox("#FF0000ConnectedorNot", thePlayer); res2 = mysql_query("INSERT INTO cmd VALUES ('" .. getPlayerName( thePlayer ) .. "')"); if( not res2 ) then outputChatBox("#FF0000Unable to query 2", thePlayer); else outputChatBox("#FF0000Success", thePlayer); end outputChatBox("#FF0000Query", thePlayer); mysql_free_result(res2); mysql_close(con); outputChatBox("#FF0000end", thePlayer); end addCommandHandler("test", TestSQL); I obviously couldn't understand why exactly it was not functioning so I put up some chat msg's to see where its getting. Sadly, the only message I receive is the "Works" msg. I am assuming that the module crashes the function and makes it unable to finish executing, could that be in anyway possible and does anyone know a fix? For reference, the sql database is NOT local, its remote. I really have no clue how to fix this issue, as I would NOT want to use SQLlite and hope that you people out there are able to help me. I've searched around google which made me end up on a lot of topics around MTA but I couldn't find any topic(I am probably stupid) that showed me the exact problem with this bit of code. Regards, Extremo. Link to comment
50p Posted August 3, 2010 Share Posted August 3, 2010 Modules are server-side. You can't use functions exported from modules in client-side scripts. Use debug window to see what is wrong with your script. https://wiki.multitheftauto.com/wiki/Debugging Link to comment
Extremo Posted August 3, 2010 Author Share Posted August 3, 2010 If I am not to use module functions client-wise, how would I be able to communicate with the server then? I've read it somewhere before on wiki but can't seem to find it and would really appreciate if you could show me just a small example and elaborate it for me. Regards, Extremo. PS: I am gonna go straight ahead and see if it works server-side. EDIT: Right, I went ahead testing it server-side and it seems fine, except a few errors about the connection but I think I can figure them out Thanks alot EDIT 2: Fixed every Problem, now all I need is a small example of how to make the client and server work together with a small elaboration EDIT 3: Right I now also figured how to add events etc and make the client/server communicate. Thanks a lot, everything worked out well, there was just a slight misunderstanding Link to comment
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