Jump to content

Recommended Posts

Witam, chciałbym zrobić zapis danych do mysql. Zrobiłem już skrypt, jednak nic się nie zapisuję proszę o pomoc.

  
connection = nil 
  
function onStart() 
connection = mysql_connect("127.0.0.1", "***", "****", "****") -- laczenie 
if ( not connection ) then -- blad polaczenia 
 outputDebugString("Błąd podczas łączenia z bazą danych") 
end 
  
local result = mysql_query(connection, "SELECT * FROM players") -- pobieranie wozów 
  
if (not result) then -- blad 
outputDebugString("Bład przy pobieraniu pojazdów (" .. mysql_errno(connection) .. ") " .. mysql_error(connection)) 
end 
end 
  
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), onStart) 
  
  
  
  
function saveToDB(pojazd, gracz) 
  
    if isElement(gracz) then 
 local serial = getPlayerSerial(gracz) 
 local nazwa = getAccountName(gracz) 
 local kasa = getPlayerMoney(gracz) 
 local skin = getElementModel(gracz) 
        local result = mysql_query(connection, "INSERT INTO players VALUES (`"..serial.."`, `"..nazwa.."` ,`"..kasa.."`,`"..skin.."`)") -- zapis wozu do bazy 
         
        if (not result) then -- blad 
            outputDebugString("Bład przy zapisie do bazy (" .. mysql_errno(connection) .. ") " .. mysql_error(connection)) 
         
        end 
        mysql_free_result(result) -- cleanup plz 
    end 
end 
setTimer( saveToDB, 3000, 0 ) 
  

Proszę o pomoc.

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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