Jump to content

What's wrong with this?


kevin433

Recommended Posts

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 by Guest
Link to comment

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
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
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 :D

Link to comment

damn, I'm an idiot! :banghead:

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") #-o

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...