Sticmy Posted September 17, 2016 Share Posted September 17, 2016 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
aka Blue Posted September 17, 2016 Share Posted September 17, 2016 (edited) 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 September 17, 2016 by aka Blue Link to comment
Sticmy Posted September 17, 2016 Author Share Posted September 17, 2016 Entonces no debo usar las funciones executeSQLInsert? Link to comment
aka Blue Posted September 17, 2016 Share Posted September 17, 2016 Te lo he dicho, no, lee la wiki, pone que están deprecated. El código que te pasé funciona correctamente, simplemente ajustalo a lo que quieres hacer. Link to comment
Sticmy Posted September 18, 2016 Author Share Posted September 18, 2016 Es que realmente cuando compran un vehículo, les aparece todo pero cuando reconnectan ya no y me sale ese error D: Link to comment
aka Blue Posted September 18, 2016 Share Posted September 18, 2016 Pero a ver, como te lo explico... que la función esa, no va, está deprecated, no sirve, no funciona Link to comment
-Rex- Posted September 19, 2016 Share Posted September 19, 2016 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
aka Blue Posted September 19, 2016 Share Posted September 19, 2016 (edited) 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 September 19, 2016 by aka Blue Link to comment
Recommended Posts