Jump to content

aleksa.mta

Members
  • Posts

    12
  • Joined

  • Last visited

aleksa.mta's Achievements

Square

Square (6/54)

0

Reputation

  1. What you said works, thank you. But now I'm having another problem and hopefully the last one. So assume that res2.USERNAME is a nil value. How do I make an if statement that will test if it's a nil value? Because when I do local res3 = res2.USERNAME if res3 == nil then outputChatBox ("Nil") end it says "attempt to index local res3 (a nil value) So even if it is nil I want the way for the program to confirm it's nil. EDIT: Actually the problem seems to be here that if res2 is nil, it can't event do res3.USERNAME ...
  2. Wait, I don't understand, can you just tell me how to store res2 into a string, for example called res3?
  3. This is a coding problem, I need a simple explanation, warning me about something else won't help..
  4. function checkForUsername (username) handler = mysql_connect("127.0.0.1", "root", "", "akrp_db") local result = mysql_query(handler, "SELECT USERNAME FROM `user_info` WHERE USERNAME = '" .. username .. "'") local res2 = mysql_fetch_assoc (result) outputChatBox (res2) end addEvent("onCheckForUsername", true) addEventHandler ("onCheckForUsername", getRootElement(), checkForUsername) http://prntscr.com/2tjlk4
  5. function checkForUsername (username) handler = mysql_connect("127.0.0.1", "root", "", "akrp_db") local result = mysql_query(handler, "SELECT USERNAME FROM `user_info` WHERE USERNAME = '" .. username .. "'") outputChatBox (result) end addEvent("onCheckForUsername", true) addEventHandler ("onCheckForUsername", getRootElement(), checkForUsername) It's triggered from the client-side script, which I can't send you, too big. error: http://prntscr.com/2th0wr
  6. Now it says 'expected string got table'
  7. Thanks for the help but I have another problem. Say I do local result = mysql_query (some command) And the command is functional since I tested it in phpMyAdmin. The command starts with SELECT so it's suppose to get a value from some column. Now my question is, if it's a single value, how do I convert it to string in order to use it further on because when I try to outputChatBox the value it says that it expected string at argument 1 and got userdata.
  8. Wait, those SQL functions are serverside? Cause my script is client-sided, eh
  9. http://prntscr.com/2tetro All good there..
  10. When I try to connect my script to a local mysql database using handler = mysql_connect("127.0.0.1", "root", "", "random_db") I get an error saying attempt to call global mysql_connect (a nil value) There are only 2 English topic about this problem online and both are left unsolved. The data I entered is correct, I suppose, because I've read some tutorials and it says that I should use "127.0.0.1" as host, "root" as username and nothing as password, also the database name is correct. All XAMPP modules running and I've downloaded mta_mysql.dll, put it in the modules folder and added <module src="mta_mysql.dll" /> in mtaserver.conf. I copied libmysql.dll in the server folder, as it says I should.. When I start the server it says that everything is running correctly. So I hope someone can solve it, thanks
  11. META: <meta> <script src="welcome.lua" type="client" /> </meta> Script: function main () outputChatBox ("asdasd") end addEventHandler ("onClientPlayerJoin", getRootElement(), main) Made it as simple as possible now, still not working
  12. So all my scripts were working normally until a day ago. My client-sided scripts suddenly no longer work while server-sided ones do. It's not about my script because I know that there is nothing wrong with it. To confirm that, I copied one of the scripts provided with the scripting guide on mtawiki (and those scripts are 100% correct I guess) but they still don't work. I am also 100% sure that my meta.xml file is fine and that everything is in the correct folder. Even when I type 'start resource' it says that my resource is running and that there are no problems. Yes, I also specified the 'type = "client"' in meta file so that's not it. As I said, no problems whatsoever with the server-sided scripts. What I've already tried: - Restarting server - Restarting MTA - Restarting computer - Reinstalling MTA (to a clean directory) - Trying out different scripts - Making new resource and trying the same with it - Trying out some of the older scripts - Checking to see if host window shows any errors - Asking on other forums - Googling Now there might be one clue. Someone on other forum told me to type 'debugscript 3' in-game and then start the resource. When I did that I got : http://prntscr.com/2smvgz So that's the only thing that might be pointing out to the problem. I hope someone can solve this, thanks in advance! P.S: The script I used is basically : http://prntscr.com/2smvp5 - an example of onClientPlayerJoin event at mtawiki
×
×
  • Create New...