Malibu Posted January 18, 2023 Share Posted January 18, 2023 (edited) WARNING: [TESTE]\S.lua:58: Bad argument @ 'dbQuery' [Expected db-connection at argument 1, got nil] WARNING: [TESTE]\S.lua:58: Bad argument @ 'dbPoll' [Expected db-query at argument 1, got boolean] ERROR: [TESTE]\S.lua:26: attempt to concatenate local 'insertid' (a nil value) Code: addCommandHandler("add", function(playerSource, commandName, intid, inttype, cost, ...) --if getElementData(playerSource, "Element_Referente_ao_Admin") > 7 then if intid and inttype and cost and (...) then name = table.concat({...}, " ") x,y,z = getElementPosition(playerSource) intbel = interiorok[tonumber(intid)] if intbel then local interiorid = intbel[1] local ix = intbel[2] local iy = intbel[3] local iz = intbel[4] local marker_int = getElementInterior(playerSource) local marker_dim = getElementDimension(playerSource) local query = dbQuery(connection, "INSERT INTO interiors SET x = ?, y = ?, z = ?, interiorx = ?, interiory = ?, interiorz = ?, name = ?, type = ?, cost = ?, interior = ?, interiorwithin = ?, dimensionwithin = ?, customint = ?, owner = ?",x, y, z, ix, iy, iz, name, inttype, cost, interiorid, marker_int, marker_dim, 0, 0) local insertered, _, insertid = dbPoll(query, -1) if insertered then loadOneInteriorWhereID(insertid) -- ERRO ESTA NESTA NESTA LINHA end outputChatBox("#ffffff Interior created, ID: #33ccff"..insertid, playerSource,124, 197, 118,true) end end --end end ) Edited January 18, 2023 by Lord Henry Script convertido de HTML para Lua. Link to comment
Shady1 Posted January 18, 2023 Share Posted January 18, 2023 (edited) 17 minutes ago, Malibu said: WARNING: [TESTE]\S.lua:58: Bad argument @ 'dbQuery' [Expected db-connection at argument 1, got nil] WARNING: [TESTE]\S.lua:58: Bad argument @ 'dbPoll' [Expected db-query at argument 1, got boolean] ERROR: [TESTE]\S.lua:26: attempt to concatenate local 'insertid' (a nil value) Code: addCommandHandler("add", function(playerSource, commandName, intid, inttype, cost, ...) --if getElementData(playerSource, "Element_Referente_ao_Admin") > 7 then if intid and inttype and cost and (...) then name = table.concat({...}, " ") x,y,z = getElementPosition(playerSource) intbel = interiorok[tonumber(intid)] if intbel then local interiorid = intbel[1] local ix = intbel[2] local iy = intbel[3] local iz = intbel[4] local marker_int = getElementInterior(playerSource) local marker_dim = getElementDimension(playerSource) local query = dbQuery(connection, "INSERT INTO interiors SET x = ?, y = ?, z = ?, interiorx = ?, interiory = ?, interiorz = ?, name = ?, type = ?, cost = ?, interior = ?, interiorwithin = ?, dimensionwithin = ?, customint = ?, owner = ?",x, y, z, ix, iy, iz, name, inttype, cost, interiorid, marker_int, marker_dim, 0, 0) local insertered, _, insertid = dbPoll(query, -1) if insertered then loadOneInteriorWhereID(insertid) <--- ERRO ESTA NESTA NESTA LINHA end outputChatBox("#ffffff Interior created, ID: #33ccff"..insertid, playerSource,124, 197, 118,true) end end --end end ) Verifique sua conexão db e verifique se você tem conexão db,e você pode mostrar todo o seu código, posso ajudá-lo Edited January 18, 2023 by Shady1 1 Link to comment
Malibu Posted January 18, 2023 Author Share Posted January 18, 2023 6 minutes ago, Shady1 said: Verifique sua conexão db e verifique se você tem conexão db,e você pode mostrar todo o seu código, posso ajudá-lo local host = "127.0.0.1" local username = "root" local password = "" local database = "custom" local sqlConnection = dbConnect( "mysql", "dbname="..database..";host="..host, username, password, "charset=utf8" ) addCommandHandler("add", function(playerSource, commandName, intid, inttype, cost, ...) --if getElementData(playerSource, "Admin") > 7 then if intid and inttype and cost and (...) then name = table.concat({...}, " ") x,y,z = getElementPosition(playerSource) intbel = interiorok[tonumber(intid)] if intbel then local interiorid = intbel[1] local ix = intbel[2] local iy = intbel[3] local iz = intbel[4] local marker_int = getElementInterior(playerSource) local marker_dim = getElementDimension(playerSource) local query = dbQuery(connection, "INSERT INTO interiors SET x = ?, y = ?, z = ?, interiorx = ?, interiory = ?, interiorz = ?, name = ?, type = ?, cost = ?, interior = ?, interiorwithin = ?, dimensionwithin = ?, customint = ?, owner = ?",x, y, z, ix, iy, iz, name, inttype, cost, interiorid, marker_int, marker_dim, 0, 0) local insertered, _, insertid = dbPoll(query, -1) if insertered then loadOneInteriorWhereID(insertid) end outputChatBox("#99cc99[NØG]:#ffffff Interior created, ID: #33ccff"..insertid, playerSource,124, 197, 118,true) end else outputChatBox("#99cc99[NØG]:#ffffff /" .. commandName .. " [InteriorID] [Tipo] [Valor] [Nome]", playerSource,124, 197, 118,true) outputChatBox("#99cc99[Tipos]:#ffffff [0 - Casa] [1 - Negocio] [2 - Construção do Governo] [4 - Garagem]", playerSource,124, 197, 118,true) end --end end ) addCommandHandler("delint", function (playerSource, cmd, id) --if getElementData(playerSource, "Admin") >= 11 then if not id then outputChatBox("#99cc99[NØG]#ffffff /".. cmd .." [InteriorID]",playerSource, 124, 197, 118, true) return end local delMarker = nil for k, v in pairs(getElementsByType("marker")) do if tostring(getElementData(v, "dbid")) == tostring(id) then delMarker = v break end end if isElement(delMarker) then destroyElement(delMarker) end if dbPoll(dbQuery(connection,"DELETE FROM interiors WHERE id=?",id),-1) then outputChatBox("#99cc99[NØG]:#ffffff Interior deleted! #33ccff("..id..")",playerSource,124, 197, 118,true) end --end end ) addEventHandler("onResourceStart",resourceRoot,function() local loadCount = 0 local Query = dbPoll(dbQuery(connection,"SELECT * FROM interiors"),-1) if (Query) then for k, v in ipairs(Query) do loadOneInteriorWhereID(v["id"]) loadCount = loadCount+1 end end end) function loadOneInteriorWhereID(id) local Query = dbPoll(dbQuery(connection,"SELECT * FROM interiors WHERE id=?",id),-1) if (Query) then for i,row in ipairs(Query) do if row["owner"] <= 0 and row["type"] == 0 then -- 102, 204, 255 --markerElement2 = exports.rm_marker:createCustomMarker(row["x"],row["y"],row["z"]-1,"cylinder",0.7,124,200,90,"arrow.png") markerElement = createMarker(row["x"], row["y"], row["z"]-1, "cylinder", 0.7, 102, 204, 255) setElementAlpha(markerElement,100) --intmarkerElement2 = exports.rm_marker:createCustomMarker(row["interiorx"],row["interiory"],row["interiorz"]-1,"cylinder",0.7,255,50,11,"arrow.png") intmarkerElement = createMarker( row["interiorx"], row["interiory"], row["interiorz"]-1, "cylinder", 0.7, 102, 204, 255, 100) setElementAlpha(intmarkerElement,100) setElementDimension(intmarkerElement2,row["id"]) elseif row["type"] == 1 then markerElement = createMarker( row["x"], row["y"], row["z"]-1, "cylinder", 0.7, 221, 118, 0, 100) intmarkerElement = createMarker( row["interiorx"], row["interiory"], row["interiorz"]-1, "cylinder", 0.7, 221, 118, 0, 100) elseif row["type"] == 2 then markerElement = createMarker( row["x"], row["y"], row["z"]-1, "cylinder", 0.7, 221, 118, 0, 100) intmarkerElement = createMarker( row["interiorx"], row["interiory"], row["interiorz"]-1, "cylinder", 0.7, 221, 118, 0, 100) elseif row["type"] == 4 then markerElement = createMarker( row["x"], row["y"], row["z"]-1, "cylinder", 0.7, 56, 66, 71, 100) intmarkerElement = createMarker( row["interiorx"], row["interiory"], row["interiorz"]-1, "cylinder", 0.7, 56, 66, 71, 100) else -- markerElement2 = exports.rm_marker:createCustomMarker(row["x"],row["y"],row["z"]-1,"cylinder",0.7,159,147,11,"arrow.png") markerElement = createMarker(row["x"], row["y"], row["z"]-1, "cylinder", 0.7, 102, 204, 255) setElementAlpha(markerElement,100) -- intmarkerElement2 = exports.rm_marker:createCustomMarker(row["interiorx"],row["interiory"],row["interiorz"]-1,"cylinder",0.7,159,147,11,"arrow.png") intmarkerElement = createMarker( row["interiorx"], row["interiory"], row["interiorz"]-1, "cylinder", 0.7, 102, 204, 255, 100) setElementAlpha(intmarkerElement,100) setElementDimension(intmarkerElement2,row["id"]) end local Query = dbPoll(dbQuery(connection,"SELECT * FROM characters WHERE id=?", row["owner"]),-1) if Query then for k, v in ipairs(Query) do ownerName = v["charname"] end end setElementData(markerElement,"ownerName",ownerName) setElementData(intmarkerElement,"ownerName",ownerName) setElementData(markerElement,"isIntMarker",true) setElementData(intmarkerElement,"isIntOutMarker",true) setElementData(markerElement,"other",intmarkerElement) setElementData(intmarkerElement,"other",markerElement) setElementData(markerElement,"dbid",row["id"]) setElementData(intmarkerElement,"dbid",row["id"]) setElementData(markerElement,"inttype",row["type"]) setElementData(intmarkerElement,"inttype",row["type"]) setElementData(markerElement,"owner",row["owner"]) setElementData(intmarkerElement,"owner",row["owner"]) setElementData(markerElement,"x",row["x"]) setElementData(intmarkerElement,"x",row["interiorx"]) setElementData(markerElement,"y",row["y"]) setElementData(intmarkerElement,"y",row["interiory"]) setElementData(markerElement,"z",row["z"]) setElementData(intmarkerElement,"z",row["interiorz"]) setElementData(intmarkerElement,"outx",row["x"]) setElementData(intmarkerElement,"outy",row["y"]) setElementData(intmarkerElement,"outz",row["z"]) setElementData(markerElement, "angle", row["angle"]) setElementData(markerElement, "locked", row["locked"]) setElementData(markerElement, "cost", row["cost"]) setElementData(markerElement, "name", row["name"]) setElementData(markerElement, "fee", row["fee"]) setElementData(markerElement, "customint", row["customint"]) setElementData(markerElement, "light", row["light"]) setElementDimension(markerElement, row["dimensionwithin"]) setElementInterior(markerElement, row["interiorwithin"]) setElementData(markerElement, "size", row["size"]) setElementData(intmarkerElement, "angle", row["angleexit"]) setElementData(intmarkerElement, "locked", row["locked"]) setElementData(intmarkerElement, "cost", row["cost"]) setElementData(intmarkerElement, "name", row["name"]) setElementData(intmarkerElement, "fee", row["fee"]) setElementData(intmarkerElement, "customint", row["customint"]) setElementData(intmarkerElement, "light", row["light"]) setElementInterior(intmarkerElement, row["interior"]) if row["interior"] == 0 and not row["customint"] then setElementDimension(intmarkerElement, 0) --setElementDimension(intmarkerElement2, 0) else setElementDimension(intmarkerElement, row["id"]) end end end end addEvent("lockIntToClient",true) addEventHandler("lockIntToClient",getRootElement(),function(playerSource,id,lock) dbExec(connection, "UPDATE interiors SET locked = ? WHERE id = ?",lock,id) end) function updateInteriorOwner(intID,playerSource,intCost) local res = dbPoll(dbQuery(connection, "UPDATE interiors SET owner=? WHERE id = ?",getElementData(playerSource,"ID"),intID),-1) for k, v in ipairs(getElementsByType("marker")) do if getElementData(v, "dbid") == intID then destroyElement(v) end end loadOneInteriorWhereID(intID) setElementData(playerSource,"money",(getElementData(playerSource,"money") or 0)-intCost) exports.fv_inventory:givePlayerItem(playerSource,41,1,intID,100,0) end addEvent("updateInteriorOwner", true) addEventHandler("updateInteriorOwner", getRootElement(), updateInteriorOwner) function changeInterior(playerSource, x, y, z, int, dim, customInt, dbID) if customInt then exports.see_customint:callLoadInteriorTextures(playerSource, dbID) end setElementPosition(playerSource, x, y, z) if int == 0 and not customInt then setElementDimension(playerSource, 0) else setElementDimension(playerSource, dim) end setElementInterior(playerSource, int) showCursor(playerSource, false) if dim == 0 then local hour, minute = getTime() triggerClientEvent(playerSource, "setBackToActualTime", playerSource, hour, minute) end end addEvent("changeInterior", true) addEventHandler("changeInterior", getRootElement(), changeInterior) function changeVehInterior(playerSource,veh, x, y, z, int, dim) local veh = getPedOccupiedVehicle(playerSource) if veh then setElementPosition(veh, x, y, z) setElementDimension(veh, dim) setElementInterior(veh, int) setElementPosition(playerSource, x, y, z) setElementDimension(playerSource, dim) setElementInterior(playerSource, int) end end addEvent("changeVehInterior", true) addEventHandler("changeVehInterior", getRootElement(), changeVehInterior) function giveInteriorKey(playerSource,value, pay) --outputChatBox(pay) setElementData(playerSource,"money",(getElementData(playerSource,"money") or 0)-pay) end addEvent("giveInteriorKey",true) addEventHandler("giveInteriorKey",getRootElement(),giveInteriorKey) addCommandHandler("setintname",function(playerSource,cmd,id,...) --if getElementData(playerSource, "Admin") >= 8 then if id and (...) then id = tonumber(id) reName = table.concat({...}, " ") for k,v in ipairs(getElementsByType("marker")) do if getElementData(v,"dbid") == id then outputChatBox("#99cc99[NØG]:#ffffff Interior renomeado #33ccff("..getElementData(v,"name")..")#ffffff -> #33ccff"..reName.."#ffffff.",playerSource,124, 197, 118,true) setElementData(v,"name",reName) dbExec(connection, "UPDATE interiors SET name = ? WHERE id = ?",reName,id) end end else outputChatBox("#99cc99[NØG]:#ffffff /"..cmd.." [interiorID] [Nome]",playerSource,124, 197, 118,true) end --end end) addCommandHandler("setintcost",function(playerSource,cmd,markerID,newCost) --if getElementData(playerSource, "Admin") >= 8 then if markerID and newCost then markerID = tonumber(markerID) newCost = tonumber(newCost) for k,v in ipairs(getElementsByType("marker")) do if getElementData(v,"dbid") == markerID then setElementData(v,"cost",newCost) dbExec(connection, "UPDATE interiors SET cost = ? WHERE id = ?",newCost,markerID) end end outputChatBox("#99cc99[NØG]:#ffffff Valor Alterado -> #33ccff"..newCost.."#ffffff.",playerSource,124, 197, 118,true) else outputChatBox("#99cc99[NØG]:#ffffff /"..cmd.." [interiorID] [Novo Valor]",playerSource,124, 197, 118,true) end --end end) addCommandHandler("getintcost",function(playerSource) --if getElementData(playerSource, "Admin") >= 8 then if getElementData(playerSource, "isInIntMarker") == true then local theIntElement = getElementData(playerSource,"int:Marker") if getElementData(theIntElement,"isIntMarker") == true then local defaultCost = getElementData(theIntElement,"cost") outputChatBox("#99cc99[NØG]:#ffffff Este interior custa#33ccff"..defaultCost.."#ffffff $.",playerSource,124, 197, 118,true) end else outputChatBox("#d9534f[NØG]:#ffffff Você não está em um Marker.",playerSource,124, 197, 118,true) end --end end) addCommandHandler("sellint",function(playerSource) if getElementData(playerSource, "isInIntMarker") == true then local theMarkElement = getElementData(playerSource,"int:Marker") local theMarkOwner = getElementData(theMarkElement,"owner") if getElementData(theMarkElement,"isIntMarker") == true then if tonumber(getElementData(playerSource,"ID")) == tonumber(theMarkOwner) then local theMarkCost = getElementData(theMarkElement,"cost") local theMarkID = getElementData(theMarkElement,"dbid") setElementData(playerSource,"money",getElementData(playerSource,"money")-(theMarkCost/2)) outputChatBox("#99cc99[NØG]:#ffffff Você vendeu com sucesso o seu interior para #33ccff"..(theMarkCost/2).."#ffffff $.",playerSource,124, 197, 118,true) dbExec(connection, "UPDATE interiors SET owner = ? WHERE id = ?",0,theMarkID) for k, v in ipairs(getElementsByType("marker")) do if getElementData(v, "dbid") == theMarkID then destroyElement(v) end end loadOneInteriorWhereID(theMarkID) setElementData(playerSource,"isInIntMarker",false) setElementData(playerSource,"int:Marker",nil) else outputChatBox("#d9534f[NØG]:#ffffff Este não é o seu interior.",playerSource,124, 197, 118,true) end end else outputChatBox("#d9534f[NØG]:#ffffff Você não está no marker.",playerSource,124, 197, 118,true) end end) addEventHandler("onPlayerCommand",root,function(command) if (command == "edit") then if getElementData(source, "isInIntMarker") == true then local theMarkElement = getElementData(source,"int:Marker") local theMarkOwner = getElementData(theMarkElement,"owner") if getElementData(theMarkElement,"isIntMarker") == true then if tonumber(getElementData(source,"ID")) == tonumber(theMarkOwner) then cancelEvent() end end end end end) addCommandHandler("gotohouse",function(playerSource,cmd,number) --if getElementData(playerSource,"Admin") >= 4 then number = tonumber(number) if number then for k,v in ipairs(getElementsByType("marker")) do if getElementData(v,"isIntMarker") == true then if getElementData(v,"dbid") == number then local markX,markY,markZ = getElementPosition(v) local markInt = getElementInterior(v) local markDim = getElementDimension(v) setElementPosition(playerSource,markX,markY,markZ+1) setElementInterior(playerSource,markInt) setElementDimension(playerSource,markDim) outputChatBox("#99cc99[NØG]:#ffffff Você foi teletransportado para o interior. #33ccff("..number..")", playerSource,124, 197, 118,true) end end end else outputChatBox("#99cc99[NØG]:#ffffff /"..cmd.." [interiorID]", playerSource,124, 197, 118,true) end --end end) addCommandHandler("setinteriorid",function(playerSource,cmd,reID) --if getElementData(playerSource, "Admin") >= 8 then if reID then reID = tonumber(reID) if getElementData(playerSource, "isInIntMarker") == true then local theInteriorElement = getElementData(playerSource,"int:Marker") if getElementData(theInteriorElement,"isIntOutMarker") == true then intOut = interiorok[tonumber(reID)] if intOut then local interiorid = intOut[1] local ix = intOut[2] local iy = intOut[3] local iz = intOut[4] setElementPosition(playerSource,ix,iy,iz) setElementInterior(playerSource,interiorid) setElementPosition(theInteriorElement,ix,iy,iz-1) setElementInterior(theInteriorElement,interiorid) setElementData(theInteriorElement,"x",ix) setElementData(theInteriorElement,"y",iy) setElementData(theInteriorElement,"z",iz) dbExec(connection, "UPDATE interiors SET interiorx = ?, interiory = ?, interiorz = ?, interior = ? WHERE id = ?",ix,iy,iz,interiorid,getElementData(theInteriorElement,"dbid")) outputChatBox("#99cc99[NØG]:#ffffff Interior ID changed.",playerSource,124, 197, 118,true) end end else outputChatBox("#d9534f[NØG]:#ffffff Você não está no marcador.",playerSource,124, 197, 118,true) end else outputChatBox("#99cc99[NØG]:#ffffff /"..cmd.." [interiorID]",playerSource,124, 197, 118,true) end --end end) addCommandHandler("setinteriorexit",function(playerSource,cmd,number) if getElementData(playerSource,"Admin") >= 8 then number = tonumber(number) if number then for k,v in ipairs(getElementsByType("marker")) do if getElementData(v,"isIntOutMarker") == true then if getElementData(v,"dbid") == number then local newX,newY,newZ = getElementPosition(playerSource) local newInt = getElementInterior(playerSource) setElementPosition(v,newX,newY,newZ-1) setElementInterior(v,newInt) setElementData(v,"x",newX) setElementData(v,"y",newY) setElementData(v,"z",newZ) dbExec(connection, "UPDATE interiors SET interiorx = ?, interiory = ?, interiorz = ?, interior = ? WHERE id = ?",newX,newY,newZ,newInt,getElementData(v,"dbid")) outputChatBox("#99cc99[NØG]:#ffffff A saída interna foi alterada. #33ccff("..number..")", playerSource,124, 197, 118,true) end end end else outputChatBox("#99cc99[NØG]:#ffffff /"..cmd.." [interiorID]", playerSource,124, 197, 118,true) end end end) Sim, estou conectado ao banco de dados, tem conexão. Porem esta dando esse erro Link to comment
Shady1 Posted January 18, 2023 Share Posted January 18, 2023 local query = dbQuery(connection, "INSERT INTO interiors SET x = ?, y = em vez de a conexão será sqlConnection Link to comment
Malibu Posted January 18, 2023 Author Share Posted January 18, 2023 (edited) [13:19:15] WARNING: [TESTE]\sourceS.lua:21: Bad argument @ 'dbQuery' [Expected db-connection at argument 1, got nil] [13:19:15] WARNING: [TESTE]\sourceS.lua:22: Bad argument @ 'dbPoll' [Expected db-query at argument 1, got boolean] [13:19:15] ERROR: [TESTE]\sourceS.lua:26: attempt to concatenate local 'insertid' (a nil value) Troquei e esta apresentando o mesmo erro e não esta adicionando no DB 7 minutes ago, Shady1 said: local query = dbQuery(connection, "INSERT INTO interiors SET x = ?, y = em vez de a conexão será sqlConnection Edited January 18, 2023 by Malibu Link to comment
sousateew Posted January 18, 2023 Share Posted January 18, 2023 4 hours ago, Malibu said: [13:19:15] WARNING: [TESTE]\sourceS.lua:21: Bad argument @ 'dbQuery' [Expected db-connection at argument 1, got nil] [13:19:15] WARNING: [TESTE]\sourceS.lua:22: Bad argument @ 'dbPoll' [Expected db-query at argument 1, got boolean] [13:19:15] ERROR: [TESTE]\sourceS.lua:26: attempt to concatenate local 'insertid' (a nil value) Troquei e esta apresentando o mesmo erro e não esta adicionando no DB Isso não altera nada. Você está com o MySQL ligado e configurou no script corretamente? Esse script precisa de uma conexão via MySQL, caso não tenha instalado ou configurado corretamente. Falhas como essa irão ocorrer. Link to comment
Malibu Posted January 18, 2023 Author Share Posted January 18, 2023 10 minutes ago, Sousateew said: Isso não altera nada. Você está com o MySQL ligado e configurou no script corretamente? Esse script precisa de uma conexão via MySQL, caso não tenha instalado ou configurado corretamente. Falhas como essa irão ocorrer. Olá, verifiquei sim e esta tudo correto a respeito da conexão com o MySql. eu ate fiz algumas alterações e ele estava mandando para a tabela porem não estava como sperado 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