Plate Posted July 15, 2013 Posted July 15, 2013 Hola bueno necesito una mini ayuda con este script de guardado de cuentas con mysql pero no sirve y tampoco da error function saveAccounts () -- Save in the database local account = getPlayerAccount(source) if ( account ) then local accName = getAccountName(account) local i = getElementInterior( source ) local d = getElementDimension( source ) local skin = getPedSkin ( source ) local money = getPlayerMoney ( source ) local health = getElementHealth ( source ) local armor = getPedArmor ( source ) local q = mysql_query(database,"SELECT * FROM `accounts` WHERE `Account` = '".. accName .."'") if(mysql_num_rows(q) == 0) then mysql_query( database, "INSERT INTO accounts ( `Account`, intterior, demension, skin, money, health, armor) VALUES ( '" .. accName .. "'," .. i .. ", " .. d .. "," .. skin .. "," .. money .. ", ".. health ..", ".. armor .." )" ) else res = mysql_query ( database, "UPDATE `accounts` SET intterior = ".. i ..", demension = ".. d ..", skin = ".. skin ..", money = ".. money ..", health = ".. health ..", armor = ".. armor .." WHERE `Account` = '"..accName.."'") end end end addEventHandler ( "onPlayerQuit", root, saveAccounts ) function loadAccounts () -- Loading from the database local account = getPlayerAccount ( source ) if ( account ) then local accName = getAccountName(account) local result = mysql_query ( database ,"SELECT * FROM `accounts` WHERE `Account` = '"..accName.."'") if result then while true do local row = mysql_fetch_assoc(result) if not row then break end setElementInterior ( source, row.intterior ) setElementDimension ( source, row.demension ) setPedSkin ( source, row.skin ) setPlayerMoney ( source, row.money ) setElementHealth ( source, row.health) setPedArmor ( source, row.armor ) break end end end end addEventHandler ( "onPlayerLogin", root, loadAccounts ) Visita Full GameZ DayZ Mod Server IP: mtasa://158.69.125.144:29015
Castillo Posted July 15, 2013 Posted July 15, 2013 Porque usas las funciones esas? usa las nuevas del MTA que son mas eficientes. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Plate Posted July 15, 2013 Author Posted July 15, 2013 Me las podrias decir? Visita Full GameZ DayZ Mod Server IP: mtasa://158.69.125.144:29015
Castillo Posted July 15, 2013 Posted July 15, 2013 dbConnect dbQuery dbExec dbFree San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Plate Posted July 15, 2013 Author Posted July 15, 2013 Hize desastre nada mas function saveAccounts () -- Save in the database local account = getPlayerAccount(source) if ( account ) then local accName = getAccountName(account) local i = getElementInterior( source ) local d = getElementDimension( source ) local skin = getPedSkin ( source ) local money = getPlayerMoney ( source ) local health = getElementHealth ( source ) local armor = getPedArmor ( source ) local q = dbQuery(database,"SELECT * FROM `accounts` WHERE `Account` = '".. accName .."'") local result = dbPoll( q, 10 ) if result == nil then dbQuery( database, "INSERT INTO accounts ( `Account`, intterior, demension, skin, money, health, armor) VALUES ( '" .. accName .. "'," .. i .. ", " .. d .. "," .. skin .. "," .. money .. ", ".. health ..", ".. armor .." )" ) else res = dbQuery ( database, "UPDATE `accounts` SET intterior = ".. i ..", demension = ".. d ..", skin = ".. skin ..", money = ".. money ..", health = ".. health ..", armor = ".. armor .." WHERE `Account` = '"..accName.."'") end end end addEventHandler ( "onPlayerQuit", root, saveAccounts ) function loadAccounts () -- Loading from the database local account = getPlayerAccount ( source ) if ( account ) then local accName = getAccountName(account) local resultq = dbQuery ( database ,"SELECT * FROM `accounts` WHERE `Account` = '"..accName.."'") if resultq then while true do local result, num_affected_rows, errmsg = dbPoll ( resultq, -1 ) if num_affected_rows > 0 then for result, row in pairs ( result ) do if not row then break end setElementInterior ( source, row.intterior ) setElementDimension ( source, row.demension ) setPedSkin ( source, row.skin ) setPlayerMoney ( source, row.money ) setElementHealth ( source, row.health) setPedArmor ( source, row.armor ) break end end end end end end addEventHandler ( "onPlayerLogin", root, loadAccounts ) Visita Full GameZ DayZ Mod Server IP: mtasa://158.69.125.144:29015
MTA Team 0xCiBeR Posted July 15, 2013 MTA Team Posted July 15, 2013 No defines "database", definelo usando dbConnect Lee los argumentos de las funciones que te dio Solid y estaras bien DevOps Engineer, Cloud Advocate & Security Engineer(Red Team) | Coffee, Containers & Burp
Arsilex Posted July 15, 2013 Posted July 15, 2013 function saveAccounts () -- Save in the database local account = getPlayerAccount(source) if ( account ) then local accName = getAccountName(account) local i = getElementInterior( source ) local d = getElementDimension( source ) local skin = getPedSkin ( source ) local money = getPlayerMoney ( source ) local health = getElementHealth ( source ) local armor = getPedArmor ( source ) local q = dbQuery(database,"SELECT * FROM accounts WHERE Account = '".. accName .."'") local result = dbPoll( q, 10 ) if result == nil then dbQuery( database, "INSERT INTO accounts ( Account, intterior, demension, skin, money, health, armor) VALUES ( '" .. accName .. "'," .. i .. ", " .. d .. "," .. skin .. "," .. money .. ", ".. health ..", ".. armor .." )" ) else res = dbQuery ( database, "UPDATE accounts SET intterior = ".. i ..", demension = ".. d ..", skin = ".. skin ..", money = ".. money ..", health = ".. health ..", armor = ".. armor .." WHERE `Account` = '"..accName.."'") end end end addEventHandler ( "onPlayerQuit", root, saveAccounts ) function loadAccounts () -- Loading from the database local account = getPlayerAccount ( source ) if ( account ) then local accName = getAccountName(account) local resultq = dbQuery ( database ,"SELECT * FROM accounts WHERE Account = '"..accName.."'") if resultq then while true do local result, num_affected_rows, errmsg = dbPoll ( resultq, -1 ) if num_affected_rows > 0 then for result, row in pairs ( result ) do if not row then break end setElementInterior ( source, row.intterior ) setElementDimension ( source, row.demension ) setPedSkin ( source, row.skin ) setPlayerMoney ( source, row.money ) setElementHealth ( source, row.health) setPedArmor ( source, row.armor ) break end end end end end end addEventHandler ( "onPlayerLogin", root, loadAccounts )
MTA Team 0xCiBeR Posted July 16, 2013 MTA Team Posted July 16, 2013 lo de pekio esta bien, siempre y cuando @Plate definas database con un dbConnect DevOps Engineer, Cloud Advocate & Security Engineer(Red Team) | Coffee, Containers & Burp
Plate Posted July 17, 2013 Author Posted July 17, 2013 lo de pekio esta bien, siempre y cuando @Plate definas database con un dbConnect Yo ya hize el dbConnect pero no lo pase por que es privado ^^ Visita Full GameZ DayZ Mod Server IP: mtasa://158.69.125.144:29015
MTA Team 0xCiBeR Posted July 17, 2013 MTA Team Posted July 17, 2013 lo de pekio esta bien, siempre y cuando @Plate definas database con un dbConnect Yo ya hize el dbConnect pero no lo pase por que es privado ^^ lo imagine..Igual puedes usar datos falsos, para verlo entero.. Igual se entendio DevOps Engineer, Cloud Advocate & Security Engineer(Red Team) | Coffee, Containers & Burp
Plate Posted July 21, 2013 Author Posted July 21, 2013 No, no me funciona recien lo probe Visita Full GameZ DayZ Mod Server IP: mtasa://158.69.125.144:29015
Arsilex Posted July 22, 2013 Posted July 22, 2013 que error te sale en el debug? estas seguro que se conecta con el mysql?
Recommended Posts