kevin433 Posted February 19, 2010 Share Posted February 19, 2010 (edited) Hi, Everytime I start the server it show me this: WARNING: MYSQL.lua: Bad argument @ 'getPlayerName' - Line: 32 [16:45:53] ERROR: ...reas/server/mods/deathmatch/resources/play/MYSQL.lua:32: attempt to concatenate a boolean value What does this mean? That's my code: function CreateMYSQLAccount(playerSource) if(not mysqlconnection) then outputServerLog("MYSQL Connection failed!") else mysql_select_db(mysqlconnection, "mtaserver") --benutzername = getPlayerName(player) [b]local result2 = mysql_query(mysqlconnection,"SELECT Username FROM Benutzer WHERE Username='" .. getPlayerName(playerSource) .."'")[/b] if(mysql_num_rows(result2) > 0) then outputServerLog( getPlayerName(playerSoure).. "gibt es schon!") outputChatBox( getPlayerName(playerSoure).. "getb es schon!", playerSource) else mysql_query(mysqlconnection, "INSERT INTO Benutzer (Username) VALUES('" .. getPlayerName(playerSource) .. "') ") result = mysql_query(mysqlconnection, "SELECT Username FROM Benutzer") outputServerLog("result: "..mysql_result(result, 1, 1)) outputChatBox("Spieler: "..mysql_result(result, 1, 1)) end end end addCommandHandler("register", CreateMYSQLAccount) Line 32 is in Bold Edited February 19, 2010 by Guest Link to comment
Aibo Posted February 19, 2010 Share Posted February 19, 2010 use [lua] tags, please error means that playerSource either not defined or is not a player element, so getPlayerName returns "false", which cannot be put into string. is playerSource passed to the function? *) and you have a typo in "playerSoure" here: outputServerLog( getPlayerName(playerSoure).. "gibt es schon!") outputChatBox( getPlayerName(playerSoure).. "getb es schon!", playerSource) Link to comment
Mr.Hankey Posted February 19, 2010 Share Posted February 19, 2010 is playerSource passed to the function? *) A command handler always passes the player who executed the command as first parameter so this should be valid. Somehow it still seems like this is not the case. Try "outputChatBox(type(playerSource))" somewhere to check the type of the variable (should be "userdata" in case of a player element ). Link to comment
kevin433 Posted February 19, 2010 Author Share Posted February 19, 2010 I've read at Wiki that if I use the function "addCommandHandler", "source" is defined as "playerSource". It's at "Handler function parameters" and showed in Example 3 here: https://wiki.multitheftauto.com/wiki/AddCommandHandler Link to comment
Aibo Posted February 19, 2010 Share Posted February 19, 2010 is playerSource passed to the function? *) A command handler always passes the player who executed the command as first parameter so this should be valid. Somehow it still seems like this is not the case. Try "outputChatBox(type(playerSource))" somewhere to check the type of the variable (should be "userdata" in case of a player element ). damn i missed the handler at the bottom Link to comment
kevin433 Posted February 19, 2010 Author Share Posted February 19, 2010 damn, I'm an idiot! In a file broph.lua I had this: addEventHandler("onResourceStart", resourceRoot, function() for i,player in ipairs(getElementsByType("player")) do spawn(player) end MYSQLData() CreateMYSQLAccount("ROFL") end ) Before I used getPlayerName I just typed in a Name into the function. Forgot to take away the CreateMYSQLAccount("ROFL") 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