Well, I explain I am trying to make a system in environments on my server but I have 2 problems and they are the following: Not detecting the ID and the text, the ID is inserted in the database but the text is not. I hope you can help me, thanks.
CODE :
local elements = { }
local function loadText( id, text, x, y, z, interior, dimension )
local element = createElement( "3dtext" )
setElementPosition( element, x, y, z )
setElementInterior( element, interior )
setElementDimension( element, dimension )
setElementData( element, "text", tostring( text ) )
elements[ id ] = element
end
addEventHandler( "onResourceStart", resourceRoot,
function( )
local result = dbPoll(dbQuery(handler, "SELECT * FROM 3dtext ORDER BY textID ASC" ),-1)
if result then
for key, data in ipairs( result ) do
loadText( data.textID, data.text, data.x, data.y, data.z, data.interior, data.dimension )
end
end
end
)
local function createtext(player,cmd,textID,...)
if GetElementData(player,"AdminLvl", 5) then
local text = table.concat( { ... }, " " )
local x, y, z = getElementPosition( player )
local insertid = dbExec ( handler, "INSERT INTO `3dtext`(`text`, `x`, `y`, `z`, `interior`, `dimension`) VALUES (?,?,?,?,?,?)", text, x, y, z, getElementInterior( player ),getElementDimension( player ) )
if insertid then
loadText( insertid, text, x, y, z, getElementInterior( player ), getElementDimension( player ) )
outputChatBox( "Text created. (ID " .. insertid .. ")", player, 0, 255, 0 )
else
outputDebugString( e )
outputChatBox( "Error MYSQL.", player, 255, 0, 0 )
end
else
outputChatBox( "Command: /" .. cmd .. " [text]", player, 255, 255, 255 )
end
end
addCommandHandler("createtext",createtext)
(Sorry for my bad english)
In the debugscript show´s me this error : In the line 37 : attempt to concatenate local 'insertid' (a boolean value)
And this is how it create : https://imgur.com/2Je5B9T