Some 'basic' questions

Hey there!

In the previous years I have studied Java at university and I just discovered that there is a programming language called lua. No honestly, I had never heard of it before, haha. It really looks similar to java to me.

Anyway, I have 2 basic questions, which would probably make some of you angry if I ask. And maybe a topic already exists of it, but I could not find it yet.

-> With Java we always import files in the top of a .java file like “import java.util.*”. How do you ‘Import sql file to your database’. I don’t even know which file the database is, lol.
-> Where is citmp-server.yml located? The search option doesn’t find the file.

It really isn’t the same.

What? In Java you don’t even do this. You import a library and write the “import this SQL into the server” yourself. It’s the same in any language. There’s a library on here called “mysql-async” which, is probably the recommended one to use.

That’s not been a thing for a while now… What are you wanting it for? There might be a more up-to-date way of doing it (in fact, there almost certainly is).

2 Likes

Thanks for the information, but you probably have no idea where you’re talking about when you said ‘In java you don’t even do this’. Just for your information, you do have to. For example, just try to create a decent calculator without importing any file. I wish you goodluck and I will give you $1,000 if you can send me the files.

Sorry, I think you may be confused. I’m not saying you don’t import classes from certain namespaces to use them. I’m saying you don’t import an SQL file into a database from Java. You implement the code yourself to it.

5 Likes

There is only one person here who does not know what they are talking about. It just so happens that it is you.

What he was referring to was this:

In Java, you do not import an SQL file in to the database. You either reference a library that will allow you to query the database you are using. Because an SQL file is simply a collection of queries, you would then run the queries through the methods provided by the library.

Here’s your calculator with no imports; where’s my money?

public class Calculator {
	
	public static void main(String[] args) {
		if (args.length != 3) {
			System.out.println("Please provide 3 arguments!\n<add/subtract/multiply/divide> <first number> <second number>");
			System.exit(0);
		}
		double number1 = 0;
		double number2 = 0;
		try {
			number1 = Double.parseDouble(args[1]);
		} catch (Exception ex) {
			System.out.println("Please provide a valid number. '" + args[1] + "' is invalid.");
			System.exit(1);
		}
		try {
			number2 = Double.parseDouble(args[2]);
		} catch (Exception ex) {
			System.out.println("Please provide a valid number. '" + args[2] + "' is invalid.");
			System.exit(1);
		}
		switch (args[0].toLowerCase()) {
			default:
				System.out.println("Invalid Operation '"+args[0]+".' Please use add, subtract, multiply or divide.\n<add/subtract/multiply/divide> <first number> <second number>");
				System.exit(2);
				break;
			case "add":
				System.out.println(number1 + " + " + number2 + " = " + (number1 + number2));
				break;
			case "subtract":
				System.out.println(number1 + " - " + number2 + " = " + (number1 - number2));
				break;
			case "multiply":
				System.out.println(number1 + " * " + number2 + " = " + (number1 * number2));
				break;
			case "divide":
				System.out.println(number1 + " / " + number2 + " = " + (number1 / number2));
				break;
		}
	}
	
}

Anyways, your database is not a file, you will need to set up a MySQL database (you can find information online) and upload the SQL file through your database client.

Yes I understand what he meant now, lol (I’m not native speaker so it’s hard for me XD).

Anyway, you must be joking if you say that that code will work XDD (And if you finally provide one, I will honestly still give you the $$). Didn’t even read it yet but if you think it will work, I will test it and if it does I’ll give you the $$, if it doesn’t you have 0 shots left. So tell me if I should test this one, or if you provide me of another bs code lol.
Post scriptum: the numbers and */± ^ must all be typed in in a .bat file, so not that you change the numbers in the .java file (sorry for my bad English again, but I hope you understand what I mean XD)

Ok so to go ahead and straighten this out right now.

Search Mysql-async on the forums. That is one way to use a mysql database in your code.

Second it shows you where that file is in the wiki.fivem.net when you look for how to run a fivem server. I am on my phone so don’t know the exact names on the wiki. The file should be called server.cfg now though.

Nah I probably did not understand what they mean (and still don’t).
I do have Mysql-async and also added ‘start [filename]’ to the resources, but i’m getting these errors:

Error loading script server.lua in resource jobs-system: server.lua:1: attempt to call a nil value (global 'require')
stack traceback:
        server.lua:1: in main chunk
Failed to load script server.lua.
Started resource jobs-system
Error loading script paycheck_sv.lua in resource paycheck: paycheck_sv.lua:1: attempt to call a nil value (global 'require')
stack traceback:
        paycheck_sv.lua:1: in main chunk
Failed to load script paycheck_sv.lua.

Somewhere it stated that I had to ‘import to your database’ and I was wondering if that might have been the cause of these eerrors. Probably not, but was the only thing I could think of what I was possibly doing wrong. I have no idea what ‘nil value’ means, besides that it is a common Latin word (nihil/nil) for ‘nothing’. XD

Well require no longer works in fivem. What script are you trying to use that is using require?

Script for jobs etc.

Ah. Yes. It does use mysql async but it no longer uses require. Remove all the require() functions. Then go into your serverconfig file and add this

SET IT UP TO THE DATABASE YOU ARE USING

set mysql_connection_string "server=127.0.0.01;database=gta5_gamemode_essential;userid=root;password=1202"

Then

You will need to do this in the __resource.lua

server_script '@mysql-async/lib/MySQL.lua'

I do apologize if I forgot something. I am walking and typing so…

You’re really helpful bro!
Ehm just a little question.
I suppose that if I have to add this in __resource.lua:
server_script ‘@mysql-async/lib/MySQL.lua’
I have to replace it for server_script “server.lua”
Or should I add it beneath it?

And the 'set mysql…", does it matter where I put it? Should it be above the ‘start [names]’ ?

Sorry about the confusion please reread as I edited it. Was my mistake.

First question however, remains :stuck_out_tongue:

Just in the resource file.

My bad, I mean second question remains… xd

I usually set it anywhere. I usually set it below the starts.

You’re a hero! Thanks!!

Did it work?

(20 chars)

No errors, didn’t test it ingame yet tho.