Hello there,
I've been scripting a login script working on mysql.
Until now it quite sucseed but, i'm having some a problem.
The problem is i want to create a export / custom function so it would be easier to
use the function in syntaxes etc.
function getUsername(source)
local handler = mysql_connect("localhost", "root", "BLABLABLA", "BLABLABLA")
local result = mysql_query(handler, "SELECT * FROM users WHERE serial = '"..getPlayerSerial( source ).."' AND online = '1';") -- Execute the query
if (result) then
while true do
local row = mysql_fetch_assoc(result)
if (not row) then break end
--[[ outputChatBox(row["username"].." is your username.", source, 0, 255, 0) ]]--
end
mysql_free_result(result) -- Free the result
end
end
addEvent( "getUsername", true )
addEventHandler( "getUsername", getRootElement(), getUsername )
As you guys can see i've been struggling to make a function that get's the username of the player
But now i want to use it in mysql syntaxes and more thing so i need to create an export or a custom function.
I already tried myself but it did not succes. I did add the function in meta.xml as export
And then i used the export like this:
local getUsername1 = exports.login_mysql:getUsername(source)
local CheckPlayer = mysql_query(handler,"SELECT * FROM users WHERE username = '"..getUsername1.."' AND online = '1';")
But it did not work and gave me the error: ERROR: login_mysql\login_server.lua:71: attempt to concatenate local 'getUsername1' (a nil value). I've searched the forums for days to look for an explaination or fix
but again, i did not sucssed so now i'm asking somebody for help... and an explaination.
Thanks in forward,
Greetz SyntaxError