xRGamingx Posted September 30, 2016 Share Posted September 30, 2016 (edited) Quien me ayuda con este error? por favor es un sistema de Ban.. ERROR: [Cosas]\NCAdmins\Ban_S.lua:94: attempt to perform arithmetic on field 'TiempoBan' (a string value) 90-function TiempodelBaneado ( playerSource ) 91-local ListaBan = executeSQLQuery("SELECT * FROM BaneadosNC") 92-for ListaBaneados1, banead in ipairs ( ListaBan ) do 93-local serialbaneado1 = ListaBan[ListaBaneados1]["SerialBan"] 94-local timedelbaneado = ListaBan[ListaBaneados1]["TiempoBan"]-1 95-if serialbaneado1 then 96-executeSQLUpdate("BaneadosNC", "TiempoBan = '"..tonumber(timedelbaneado).."'", "SerialBan = '"..serialbaneado1.."'") 97-end 98-end 99-end Edited September 30, 2016 by xRGamingx problema escritura Link to comment
aka Blue Posted September 30, 2016 Share Posted September 30, 2016 Ya no se utiliza executeSQLQuery ni executeSQLUpdate. Debes usar las funciones db de MTA para tablas personalizadas. Hace poco le pasé este codigo a otro miembro de la comunidad, mira si e puedes guiar: -- Creamos la base de datos y la tabla principal addEventHandler( "onResourceStart", resourceRoot, function( ) sql = dbConnect ( "sqlite" , "accounts.db" ) -- Create the connection accountsTable = dbExec ( sql , "CREATE TABLE IF NOT EXISTS accounts (account TEXT,password TEXT,serial TEXT)" ) if fileExists( "accounts.db" ) and sql and accountsTable then outputDebugString( "Succefully connected SQLite resource" ) else outputDebugString( "Failed to connect SQLite" ) end end ) -- Comprobar si un SELECT FROM devuelve un resultado: local find_account = dbQuery ( sql , "SELECT * FROM accounts WHERE account = ?", username ) local result = dbPoll( find_account, -1 ) if result and #result > 0 then outputDebugString( "Account exists" ) else outputDebugString( "Account does not exists" ) end -- Uso de INSERT local qh = dbQuery ( sql , "INSERT INTO accounts (account,password,serial) VALUES (?,?,?)", username, md5(password), serial ) local result = dbPoll( qh, -1 ) if result then outputDebugString( "Registered" ) return true else outputDebugString( "Error, contact server admin" ) return end -- Uso de UPDATE local result = dbFree ( dbQuery ( sql , "UPDATE accounts SET password = ? WHERE account = ?" , md5(new_pass), account ) ) if result then outputDebugString( "New MD5 password = "..md5(new_pass) ) outputDebugString( "Without MD5 = "..tostring( new_pass ) ) else outputDebugString( "Error changing password" ) end Link to comment
Recommended Posts