Jump to content

Help on debug messages needed


Ch3ck3r

Recommended Posts

Hi guys,

i'm relatively new to lua and mta but not so new at scripting in general.

I want to create a new gamemode, starting from scratch and ran into my first problem already.

I want to use a mysql database and therefor i am checking the database connection on resource start up.

This is the relevant piece of code

function onGamemodeStart(resource)
g_gameMode = resource
g_mysqlHandler = mysql_connect("localhost", "mtasa", "------", "mtasa")
if(not g_mysqlHandler) then
	outputDebugString("Could not establish connection to database server", 1)
	outputConsole("Could not establish connection to database server")
	outputServerLog("Could not establish connection to database server")
	shutdown("Could not establish connection to database server")
end
end
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), onGamemodeStart)

This piece of code does work, indeed. It shuts down my server when the connection can't be established.

But i'm missing the debug output. None of the Lines above create a readable Message. Ther is no message

in the console nor in the log file neither a debugmessage in the server.

I set debugscript to 3 (ingame) and scriptdebugloglevel (in mtaserver.conf) to 3 as well.

Any help appreciated

Thanks :)

Edited by Guest
Link to comment

Thanks for this information, though i'd have to know this. Now you are mentioning it it came to my mind, that i've stumbled about this damn error in other languages and modules already.

Nevertheless i've one question left. It's not really a problem but maybe you got some advice for me.

I need to use the same mysql connection in serveral resources.

How do i do that in the best way?

I tried to pass the mysq_handle with an exported function which didn't worked.

By passing the handle between resources it always became a string and was useless.

Atm. i solved it by saving the mysql data in settings.xml and create one connection per resource.

Isn't there a better way?

Link to comment

Like robhol suggested, i summed up everything in a central resource called 'database'

Actually the whole file just overwrites the mysql functions providing the resource parameter automatically.

It was quite a boring task to rewrite all mysql function, so if anybody is in need of it, i will post it up on here.

Currently it does only work from server-side. Maybe i will do some event based system for handling action with client scripts later.

Link to comment

No, it'd get pretty messy if there was I think, though it could be useful sometimes...

Something that could be added in the future would be an tag in the meta.xml that would import one resource into another - either by just mapping functions directly to exported ones or by running the resource again in the instance of the resource that was imported...

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...