Jump to content

Ayuda D:


Sticmy

Recommended Posts

Hola quisiera saber porque me causa este error D:

Imagen:http://subefotos.com/ver/?f7951b2b2ec8a71ab3991c5570b6ee06o.png

Codígo:

function Insertar (source, ide, cost, x, y, z, r, r1, g1, b1, r2, g2, b2)
	local account = getPlayerAccount(source)
	local id = math.random (0,999999999)
	local check = executeSQLQuery("SELECT * FROM Vehiculos where Numero = '" .. id .. "'")
	if not ( type( check ) == "table" and #check == 0 ) or not check then
		InsertarData (source, ide, cost, x, y, z, r, r1, g1, b1, r2, g2, b2)
	else
		executeSQLInsert ( "Vehiculos", "'0','"..id.."','"..getAccountName(account).."','"..ide.."','"..cost.."','0','1000','"..x.."','"..y.."','"..z.."','"..r.."','"..r1.."','"..g1.."','"..b1.."','"..r2.."','"..g2.."','"..b2.."','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'" )  
		setElementID (getElementData(source, "hisCar"), tostring(id))
		triggerClientEvent (source, "onBuyGuiSetText", source, getVehicleNameFromModel(ide), tostring(id))
	end 
end

 

Link to comment

Usa dbQuery, aquí te dejo un ejemplo de mi sistema de logueo. Esas funciones son muy viejas ya:

		local find_account = dbQuery ( sql , "SELECT * FROM accounts WHERE account = ?", username )
		local result = dbPoll( find_account, -1 )
		if result and #result > 0 then
			triggerClientEvent( player, "loginPanel:executeMessage", player, "Account already exists", 1 )
			return
		else
			local serial = getPlayerSerial( player )
			local account = addAccount( username, password )
			if serial then
				if not account then
					triggerClientEvent( player, "loginPanel:executeMessage", player, "Can not add account to MTA Base.", 1 )
					return
				else
					local qh = dbQuery ( sql , "INSERT INTO accounts (account,password,serial) VALUES (?,?,?)", username, password, serial )
					local result = dbPoll( qh, -1 )
					if result then
						triggerClientEvent( player, "loginPanel:executeMessage", player, "Succefully registered. Welcome", 0 )
						return true
					else
						triggerClientEvent( player, "loginPanel:executeMessage", player, "Error, contact with server admin", 1 )
						return
					end				
				end
			else
				triggerClientEvent( player, "loginPanel:executeMessage", player, "Fatal error. Contact server admin.", 1 )
				return
			end
		end

Espero que te sirva, suerte.

Edited by aka Blue
Link to comment

Por sierto Blue, Para modificar o insertar datos en una tabla es preferible usar dbExec, dbQuery se usa como para obtener datos de una tabla.

Si el dbQuery no se hace ( o no se cumple o ejecuta  ) dbPoll siempre retornara una tabla vacía, asi que siempre se va a cumplir esa condición 

Link to comment

Yo comparto lo que a mí me ha funcionado correctamente. dbExec en particular me suelta errores (que es obvio que quizás porque no lo sé utilizar correctamente). La cuestión es que quiero que entienda que esas funciones de execute ya están deprecated y se usa dbFUNCION.

PD: Sin ofender, es por cierto*

Edited by aka Blue
Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...