Jump to content

SQL Save Tnx Mr.Pres[T]ege ^_^


Recommended Posts

السسلام عليكم ورحمة الله وبرككاته ..

اخباركم شباب ؟؟

عساكم بالف خير ..

طلبتكم اليوم تشرحون لي كيف اخلي المود يسوي حفظ في قاعدة البيانات ..

مثلا ابيه يحفظ الـ حسابات والباسوردات في SQL

يسوي له Tab جديد ويحط فيه SaveSystemAccounts

واللي يبي حق التسجيل + تسجيل الدخول حقي

  
addEvent("onLogin", true) 
addEventHandler("onLogin",root, 
    function (player, user, pass) 
        local account = getAccount ( user, pass ) 
    if ( account ~= true ) then 
        if (logIn ( player, account, pass ) == true) then 
            outputChatBox ( "You Logged in Sucessfuly!", player, 255, 255, 0 , true ) 
        else 
            outputChatBox ( "Login Error!", player, 255, 0, 0 ) 
        end 
    else 
        outputChatBox ( "Wrong username or password!", player, 255, 0, 0 ) 
    end 
     
    end 
) 
  
addEvent("onReg", true) 
addEventHandler("onReg",root, 
    function ( player, user, pass ) 
        local account = getAccount ( user, pass ) 
    if ( account ~= false ) then 
        if (logIn ( player, account, pass ) == true) then 
            outputChatBox ( "You Registerd and Logged in Sucessfuly!", player, 255, 255, 0 ) 
        else 
            outputChatBox ( "You Are Already Logged in !", player, 255, 255, 0 ) 
        end 
    else 
        account = addAccount ( user, pass ) 
        if (logIn ( player, account, pass ) == true) then 
            outputChatBox ( "You Registerd and Logged in Sucessfuly!", player, 255, 255, 0 ) 
        else 
            outputChatBox ( "Register Error !", player, 255, 0, 0 ) 
        end 
    end 
end 
) 
  

وششكرا

Edited by Guest
Link to comment

  
addEventHandler ( "onResourceStart", resourceRoot, 
    function ( ) 
        executeSQLQuery ( "CREATE TABLE IF NOT EXISTS SaveSystemByAboShanab (NameAccount,Password)" ) 
    end 
) 
  
function setSaveSystemByAboShanab ( NameAccount, Password ) 
    return executeSQLQuery ( "INSERT INTO `SaveSystemByAboShanab` ( `NameAccount`, `Password` ) VALUES ( ?, ? )", tostring(user), tostring(pass) ) 
end 
  

شغال ؟

Link to comment
addEventHandler ( "onResourceStart", resourceRoot, 
    function ( ) 
        executeSQLQuery ( "CREATE TABLE IF NOT EXISTS SaveSystemByAboShanab (NameAccount,Password)" ) 
    end 
) 
  
function setSaveSystemByAboShanab ( NameAccount, Password ) 
    return executeSQLQuery ( "INSERT INTO SaveSystemByAboShanab ( NameAccount, Password ) VALUES ( ?, ? )", tostring(NameAccount), tostring(Password) ) 
end 
  
function getAccountsInTable() 
    return executeSQLQuery("SELECT * FROM SaveSystemByAboShanab") 
end 

Link to comment

طيب لو ناخذ هذي الاشياء من مود بريستيج ==

  
addEventHandler ( "onResourceStart", resourceRoot, 
    function ( ) 
        executeSQLQuery ( "CREATE TABLE IF NOT EXISTS SaveSystemByAboShanab (NameAccount,Password)" ) 
    end 
) 
  
function setSaveSystemByAboShanab ( NameAccount, Password ) 
    return executeSQLQuery ( "INSERT INTO SaveSystemByAboShanab ( NameAccount, Password ) VALUES ( ?, ? )", tostring(NameAccount), tostring(Password) ) 
end 
  
function SelectFromSql ( ) 
    local data = executeSQLQuery ( "SELECT * FROM SaveSystemByAboShanab" ) 
    if ( type ( data ) == "table" and #data == 0) or not data then 
        return { } 
    else 
        return data 
    end 
end 
  
addEvent ( "RefreshList", true ) 
addEventHandler ( "RefreshList", root, 
    function ( ) 
        UpDateListInSql ( source ) 
    end 
) 
  
addEvent ( "Save:To:Data:Base", true ) 
addEventHandler ( "Save:To:Data:Base", root, 
    function ( user, pass ) 
        setSQL_Data ( user, pass ) 
    end 
) 
  

كذا يضبط ولا لا ؟

Link to comment

بعد التعديل عليه

  
addEventHandler ( "onResourceStart", resourceRoot, 
    function ( ) 
        executeSQLQuery ( "CREATE TABLE IF NOT EXISTS SaveSystemByAboShanab (NameAccount,Password)" ) 
    end 
) 
  
function setSaveSystemByAboShanab ( NameAccount, Password ) 
    return executeSQLQuery ( "INSERT INTO SaveSystemByAboShanab ( NameAccount, Password ) VALUES ( ?, ? )", tostring(NameAccount), tostring(Password) ) 
end 
  
function SelectFromSql ( ) 
    local data = executeSQLQuery ( "SELECT * FROM SaveSystemByAboShanab" ) 
    if ( type ( data ) == "table" and #data == 0) or not data then 
        return { } 
    else 
        return data 
    end 
end 
  
addEvent ( "RefreshList", true ) 
addEventHandler ( "RefreshList", root, 
    function ( ) 
        UpDateListInSql ( source ) 
    end 
) 
  
addEvent ( "Save:To:Data:Base", true ) 
addEventHandler ( "Save:To:Data:Base", root, 
    function ( user, pass ) 
        setSaveSystemByAboShanab ( user, pass ) 
    end 
) 
  

كود تسجيل الدخول + التسجيل

  
addEvent("onLogin", true) 
addEventHandler("onLogin",root, 
    function (player, user, pass) 
        local account = getAccount ( user, pass ) 
    if ( account ~= true ) then 
        if (logIn ( player, account, pass ) == true) then 
            outputChatBox ( "You Logged in Sucessfuly!", player, 255, 255, 0 , true ) 
            executeSQLInsert ( "NameAccount", ""..user .."Password", ""..pass .."" ) 
        else 
            outputChatBox ( "Login Error!", player, 255, 0, 0 ) 
        end 
    else 
        outputChatBox ( "Wrong username or password!", player, 255, 0, 0 ) 
    end 
  
    end 
) 
  
addEvent("onReg", true) 
addEventHandler("onReg",root, 
    function ( player, user, pass ) 
        local account = getAccount ( user, pass ) 
    if ( account ~= false ) then 
        if (logIn ( player, account, pass ) == true) then 
            outputChatBox ( "You Registerd and Logged in Sucessfuly!", player, 255, 255, 0 ) 
            executeSQLInsert ( "NameAccount", ""..user .."Password", ""..pass .."" ) 
        else 
            outputChatBox ( "You Are Already Logged in !", player, 255, 255, 0 ) 
        end 
    else 
        account = addAccount ( user, pass ) 
        if (logIn ( player, account, pass ) == true) then 
            outputChatBox ( "You Registerd and Logged in Sucessfuly!", player, 255, 255, 0 ) 
            executeSQLInsert ( "NameAccount", ""..user .."Password", ""..pass .."" ) 
        else 
            outputChatBox ( "Register Error !", player, 255, 0, 0 ) 
        end 
    end 
end 
) 
  

ماضبطط وش الحل ؟؟

Link to comment

ي لبيه ي بريستيججج ييييييي لبيهه

وربي انككك مملكك تم الحل تم الحل ذذ ..

يعطيك الف الف عافية ^_^

  
addEvent("onLogin", true) 
addEventHandler("onLogin",root, 
    function (player, user, pass, NameAccount, Password) 
        local account = getAccount ( user, pass ) 
    if ( account ~= true ) then 
        if (logIn ( player, account, pass ) == true) then 
            outputChatBox ( "You Logged in Sucessfuly!", player, 255, 255, 0 , true ) 
            executeSQLQuery ( "INSERT INTO SaveSystemByAboShanab ( NameAccount, Password ) VALUES ( ?, ? )", user, pass ) 
        else 
            outputChatBox ( "Login Error!", player, 255, 0, 0 ) 
        end 
    else 
        outputChatBox ( "Wrong username or password!", player, 255, 0, 0 ) 
    end 
  
    end 
) 
  
addEvent("onReg", true) 
addEventHandler("onReg",root, 
    function ( player, user, pass, NameAccount, Password ) 
        local account = getAccount ( user, pass ) 
    if ( account ~= false ) then 
        if (logIn ( player, account, pass ) == true) then 
            outputChatBox ( "You Registerd and Logged in Sucessfuly!", player, 255, 255, 0 ) 
            executeSQLQuery ( "INSERT INTO SaveSystemByAboShanab ( NameAccount, Password ) VALUES ( ?, ? )", user, pass ) 
        else 
            outputChatBox ( "You Are Already Logged in !", player, 255, 255, 0 ) 
        end 
    else 
        account = addAccount ( user, pass ) 
        if (logIn ( player, account, pass ) == true) then 
            outputChatBox ( "You Registerd and Logged in Sucessfuly!", player, 255, 255, 0 ) 
            executeSQLQuery ( "INSERT INTO SaveSystemByAboShanab ( NameAccount, Password ) VALUES ( ?, ? )", user, pass ) 
        else 
            outputChatBox ( "Register Error !", player, 255, 0, 0 ) 
        end 
    end 
end 
) 
  

الثانين ^_^

  
addEventHandler ( "onResourceStart", resourceRoot, 
    function ( ) 
        executeSQLQuery ( "CREATE TABLE IF NOT EXISTS SaveSystemByAboShanab (NameAccount,Password)" ) 
    end 
) 
  
function setSaveSystemByAboShanab ( user, pass, NameAccount, Password ) 
    return executeSQLQuery ( "INSERT INTO SaveSystemByAboShanab ( NameAccount, Password ) VALUES ( ?, ? )", tostring(user), tostring(pass) ) 
end 
  
function SelectFromSql ( ) 
    local data = executeSQLQuery ( "SELECT * FROM SaveSystemByAboShanab" ) 
    if ( type ( data ) == "table" and #data == 0) or not data then 
        return { } 
    else 
        return data 
    end 
end 
  
addEvent ( "RefreshList", true ) 
addEventHandler ( "RefreshList", root, 
    function ( ) 
        UpDateListInSql ( source ) 
    end 
) 
  
addEvent ( "Save:To:Data:Base", true ) 
addEventHandler ( "Save:To:Data:Base", root, 
    function ( user, pass ) 
        setSaveSystemByAboShanab ( user, pass ) 
    end 
) 
  

يعطيك مليون ترليون عافية ^_^

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...