Jump to content

مشكلة فحفظ الحساب


SycroX

Recommended Posts

حاولت اسوي

حفظ الحساب بس ما ظبتت ووش المشكلة

  
addEventHandler("onClientGUIClick", guiRoot, function() 
    if source == save then 
    if guiCheckBoxGetSelected(save) == true then 
    triggerServerEvent("OnSave", localPlayer, guiGetText(Name), guiGetText(Pass)) 
    end 
  end 
end) 
  
addEvent("setInformations", true) 
addEventHandler("setInformations", root, function(User, Pass) 
  guiSetText(Name, User) 
  guiSetText(Pass, Pass) 
  guiCheckBoxSetSelected(save, true) 
end) 
  
--server 
  
  
  
addEventHandler("onResourceStart", resourceRoot, function() 
  executeSQLQuery("CREATE TABLE IF NOT EXISTS Account_Table (Serial,UserName,UserPass)") 
  outputDebugString("Sql Remember User Name - User Pass , Loaded .", 3) 
end) 
  
addUser = function(Serial, UserName, UserPass) 
  return executeSQLQuery("INSERT INTO Account_Table (Serial,UserName,UserPass) VALUES(?,?,?)", Serial, UserName, UserPass) 
end 
  
setUser = function(Serial, UserName, UserPass) 
  return executeSQLQuery("UPDATE Account_Table SET UserName=?,UserPass=? WHERE Serial=?", UserName, UserPass, Serial) 
end 
  
getUser = function(Serial) 
  local Row = executeSQLQuery("SELECT * FROM Account_Table WHERE Serial = '" .. Serial .. "'") 
  if (type(Row) == "table" and #Row == 0) or not Row then 
    return {} 
  else 
    return tostring(Row[1].UserName), tostring(Row[1].UserPass) 
  end 
end 
  
addEvent("getPass",true) 
addEventHandler("getPass",root,function () 
local UserName, UserPass = getUser(getPlayerSerial(source)) 
if tostring(UserName) and tostring(UserPass) then 
triggerClientEvent(source, "setInformations", source, UserName, UserPass) 
end 
end) 
  
addEvent("OnSave", true) 
addEventHandler("OnSave", root, function(UserName, UserPass) 
  local Serial = getPlayerSerial(source) 
    local Row = executeSQLQuery("SELECT * FROM Account_Table WHERE Serial = '" .. Serial .. "'") 
    if (type(Row) == "table" and #Row == 0) or not Row then 
      addUser(Serial, UserName, UserPass) 
    else 
      setUser(Serial, UserName, UserPass) 
    end 
end) 
  
  
Link to comment

جرب

addEventHandler("onClientGUIClick", guiRoot, function() 
    if source == save then 
    if guiCheckBoxGetSelected(save) == true then 
    triggerServerEvent("OnSave", localPlayer, guiGetText(Name), guiGetText(Pass)) 
    end 
  end 
end) 
  
addEvent("setInformations", true) 
addEventHandler("setInformations", root, function(User, Pass) 
  guiSetText(Name, User) 
  guiSetText(Pass, Pass) 
  guiCheckBoxSetSelected(save, true) 
end) 
  
--server 
  
  
addEventHandler('onResourceStart',resourceRoot, function ( ) 
executeSQLQuery("CREATE TABLE IF NOT EXISTS Account_Table (Serial,UserName,UserPass)") 
end) 
  
function addUser ( player , user , pass ) 
local row = executeSQLQuery('SELECT * FROM Account_Table WHERE Serial=?',getPlayerSerial(player)) 
if ( row and type ( row ) == 'table' and #row ~= 0 ) then  
executeSQLQuery('UPDATE Account_Table SET UserName=?,UserPass=? WHERE Serial=?',user,pass,getPlayerSerial(player)) 
else 
executeSQLQuery('INSERT INTO Account_Table (Serial,UserName,UserPass) VALUES (?,?,?)',getPlayerSerial(player),user,pass) 
end 
end 
  
function getUser ( player ) 
local row = executeSQLQuery('SELECT * FROM Account_Table WHERE Serial=?',getPlayerSerial(player)) 
if ( row and type ( row ) == 'table' and #row ~= 0 ) then  
return row[1]['UserName'],row[1]['UserPass'] 
end  
end 
  
addEvent("getPass",true) 
addEventHandler("getPass",root,function () 
local user,pass = getUser ( source ) 
triggerClientEvent(source, "setInformations", source,user,pass) 
end) 
  
addEvent("OnSave", true) 
addEventHandler("OnSave", root, function(UserName, UserPass) 
addUser ( source , UserName, UserPass ) 
end) 
Link to comment
متقول ملها

جربت اعما

local User = guiGetText(Name)

ما ظبتت بردو

آسف علي التأخير

تخيل

الكهرباء كل دة كانت قاطعة عندي :mrgreen:

-- المهم

لو دة جيم مود و اول لما الاعب يخش السيرفرر

تفضل

  
addEventHandler ("onClientGUIClick",log, -- زرار تسجيل الدخول 
        function () -- عدل علي الباقي بالشكل اللي انت عايزه 
        local username = guiGetText (Name) 
        local password = guiGetText (Pass) 
        triggerServerEvent ("LOGINTRIGGER",localPlayer,username,password) 
if guiCheckBoxGetSelected (save) then -- لو الاعب حاط علامة صح 
triggerServerEvent ("saveLogPass",localPlayer,username,password) -- الداتا تتحفظ 
else -- لو مفيش علامة صح 
triggerServerEvent ("deleteLogPass",localPlayer) -- نشيل الداتا لمنع التكرار 
        end 
        end 
        ,false) 
  
addEvent ("SHOWwINTRIGGER",true) 
addEventHandler ("SHOWwINTRIGGER",root, 
    function (SQLData) 
-- اكوادك 
-- مثال 
guiSetVisible (yourwindow,true) 
    showCursor (true) 
    guiSetInputEnabled (true) 
-- 
if type(SQLData) == "table" and #SQLData ~= 0 then  
    for i,k in ipairs (SQLData) do 
    guiSetText (Name,k.ID) 
    guiSetText (Pass,k.PW) 
end 
-- 
guiCheckBoxSetSelected (save,true) 
-- 
else 
-- لو مفيش داتا متسجلة او الاعب ماحطش علامة صح علي البتاعة او مش عارف اسمها ايه 
-- النافذة تظهرله عادي و علامة الصح تتشال  
guiCheckBoxSetSelected (save,false) 
-- 
guiSetVisible (yourwindow,true) 
showCursor (true) 
guiSetInputEnabled (true) 
end 
end 
) 

--server 
addEventHandler ("onResourceStart",resourceRoot, 
function () 
executeSQLQuery ("CREATE TABLE IF NOT EXISTS `accountsave` (serial,ID,PW)") 
end 
) 
  
addEvent ("saveLogPass",true) 
addEventHandler ("saveLogPass",root, 
function (username,password) 
local yyy = executeSQLQuery ('SELECT * FROM `accountsave` WHERE serial =?',getPlayerSerial(source)) 
if ( type (yyy) == "table" and #yyy == 0 or not yyy ) then 
executeSQLQuery ('INSERT INTO `accountsave` (serial,ID,PW) VALUES (?,?,?)',getPlayerSerial(source),username,password) 
else 
executeSQLQuery ("UPDATE `accountsave` SET ID=?, PW=? WHERE serial=?",username,password,getPlayerSerial(source)) 
end 
end 
) 
  
addEvent ("deleteLogPass",true) 
addEventHandler ("deleteLogPass",root, 
function (username,password) 
executeSQLQuery ("DELETE FROM `accountsave` WHERE serial",getPlayerSerial(source)) 
end 
) 
  
addEventHandler ("onPlayerJoin",root, -- اظهار لوحة التسجيل في حدث لما الاعب يدخل السيرفر 
function () 
local SQLData = executeSQLQuery ('SELECT * FROM `accountsave` WHERE serial =?',getPlayerSerial(source)) -- ايجاد الداتا 
-- تقدر تحط اكواد هنا 
triggerClientEvent (source,"SHOWwINTRIGGER",source,SQLData) -- تريجر اظهار النافذة 
end 
) 
Link to comment
متقول ملها

جربت اعما

local User = guiGetText(Name)

ما ظبتت بردو

آسف علي التأخير

تخيل

الكهرباء كل دة كانت قاطعة عندي :mrgreen:

-- المهم

لو دة جيم مود و اول لما الاعب يخش السيرفرر

تفضل

  
addEventHandler ("onClientGUIClick",log, -- زرار تسجيل الدخول 
        function () -- عدل علي الباقي بالشكل اللي انت عايزه 
        local username = guiGetText (Name) 
        local password = guiGetText (Pass) 
        triggerServerEvent ("LOGINTRIGGER",localPlayer,username,password) 
if guiCheckBoxGetSelected (save) then -- لو الاعب حاط علامة صح 
triggerServerEvent ("saveLogPass",localPlayer,username,password) -- الداتا تتحفظ 
else -- لو مفيش علامة صح 
triggerServerEvent ("deleteLogPass",localPlayer) -- نشيل الداتا لمنع التكرار 
        end 
        end 
        ,false) 
  
addEvent ("SHOWwINTRIGGER",true) 
addEventHandler ("SHOWwINTRIGGER",root, 
    function (SQLData) 
-- اكوادك 
-- مثال 
guiSetVisible (yourwindow,true) 
    showCursor (true) 
    guiSetInputEnabled (true) 
-- 
if type(SQLData) == "table" and #SQLData ~= 0 then  
    for i,k in ipairs (SQLData) do 
    guiSetText (Name,k.ID) 
    guiSetText (Pass,k.PW) 
end 
-- 
guiCheckBoxSetSelected (save,true) 
-- 
else 
-- لو مفيش داتا متسجلة او الاعب ماحطش علامة صح علي البتاعة او مش عارف اسمها ايه 
-- النافذة تظهرله عادي و علامة الصح تتشال  
guiCheckBoxSetSelected (save,false) 
-- 
guiSetVisible (yourwindow,true) 
showCursor (true) 
guiSetInputEnabled (true) 
end 
end 
) 

--server 
addEventHandler ("onResourceStart",resourceRoot, 
function () 
executeSQLQuery ("CREATE TABLE IF NOT EXISTS `accountsave` (serial,ID,PW)") 
end 
) 
  
addEvent ("saveLogPass",true) 
addEventHandler ("saveLogPass",root, 
function (username,password) 
local yyy = executeSQLQuery ('SELECT * FROM `accountsave` WHERE serial =?',getPlayerSerial(source)) 
if ( type (yyy) == "table" and #yyy == 0 or not yyy ) then 
executeSQLQuery ('INSERT INTO `accountsave` (serial,ID,PW) VALUES (?,?,?)',getPlayerSerial(source),username,password) 
else 
executeSQLQuery ("UPDATE `accountsave` SET ID=?, PW=? WHERE serial=?",username,password,getPlayerSerial(source)) 
end 
end 
) 
  
addEvent ("deleteLogPass",true) 
addEventHandler ("deleteLogPass",root, 
function (username,password) 
executeSQLQuery ("DELETE FROM `accountsave` WHERE serial",getPlayerSerial(source)) 
end 
) 
  
addEventHandler ("onPlayerJoin",root, -- اظهار لوحة التسجيل في حدث لما الاعب يدخل السيرفر 
function () 
local SQLData = executeSQLQuery ('SELECT * FROM `accountsave` WHERE serial =?',getPlayerSerial(source)) -- ايجاد الداتا 
-- تقدر تحط اكواد هنا 
triggerClientEvent (source,"SHOWwINTRIGGER",source,SQLData) -- تريجر اظهار النافذة 
end 
) 

انتا فهمت انا عايز اعمل ايه

انا عامل شيك بوكس و عاوز لما اكتب الباس و الحساب فلاديت بوكس يتحفظو يعني لما اخروج و ارجع الاقيهم مكتوبين جوا الاديت بوكس

Link to comment

يااخوي انت مسوي لمن يضغط ع حفظ يجيب الاسم والباس ويرسلهم تريقر لسيرفر

اكثر الناس وومنهم انا اسوي حفظ ثم احط الاسم والباس

سوي لمن يضغط ع زر الدخول يتحقق ان كان محطي ع الحفظ صح او لا

ووقتها كمل الباقي م يحتاج اعلمك.

Link to comment
يااخوي انت مسوي لمن يضغط ع حفظ يجيب الاسم والباس ويرسلهم تريقر لسيرفر

اكثر الناس وومنهم انا اسوي حفظ ثم احط الاسم والباس

سوي لمن يضغط ع زر الدخول يتحقق ان كان محطي ع الحفظ صح او لا

ووقتها كمل الباقي م يحتاج اعلمك.

جربتها ما ظبتت بردو

Link to comment
متقول ملها

جربت اعما

local User = guiGetText(Name)

ما ظبتت بردو

آسف علي التأخير

تخيل

الكهرباء كل دة كانت قاطعة عندي :mrgreen:

-- المهم

لو دة جيم مود و اول لما الاعب يخش السيرفرر

تفضل

  
addEventHandler ("onClientGUIClick",log, -- زرار تسجيل الدخول 
        function () -- عدل علي الباقي بالشكل اللي انت عايزه 
        local username = guiGetText (Name) 
        local password = guiGetText (Pass) 
        triggerServerEvent ("LOGINTRIGGER",localPlayer,username,password) 
if guiCheckBoxGetSelected (save) then -- لو الاعب حاط علامة صح 
triggerServerEvent ("saveLogPass",localPlayer,username,password) -- الداتا تتحفظ 
else -- لو مفيش علامة صح 
triggerServerEvent ("deleteLogPass",localPlayer) -- نشيل الداتا لمنع التكرار 
        end 
        end 
        ,false) 
  
addEvent ("SHOWwINTRIGGER",true) 
addEventHandler ("SHOWwINTRIGGER",root, 
    function (SQLData) 
-- اكوادك 
-- مثال 
guiSetVisible (yourwindow,true) 
    showCursor (true) 
    guiSetInputEnabled (true) 
-- 
if type(SQLData) == "table" and #SQLData ~= 0 then  
    for i,k in ipairs (SQLData) do 
    guiSetText (Name,k.ID) 
    guiSetText (Pass,k.PW) 
end 
-- 
guiCheckBoxSetSelected (save,true) 
-- 
else 
-- لو مفيش داتا متسجلة او الاعب ماحطش علامة صح علي البتاعة او مش عارف اسمها ايه 
-- النافذة تظهرله عادي و علامة الصح تتشال  
guiCheckBoxSetSelected (save,false) 
-- 
guiSetVisible (yourwindow,true) 
showCursor (true) 
guiSetInputEnabled (true) 
end 
end 
) 

--server 
addEventHandler ("onResourceStart",resourceRoot, 
function () 
executeSQLQuery ("CREATE TABLE IF NOT EXISTS `accountsave` (serial,ID,PW)") 
end 
) 
  
addEvent ("saveLogPass",true) 
addEventHandler ("saveLogPass",root, 
function (username,password) 
local yyy = executeSQLQuery ('SELECT * FROM `accountsave` WHERE serial =?',getPlayerSerial(source)) 
if ( type (yyy) == "table" and #yyy == 0 or not yyy ) then 
executeSQLQuery ('INSERT INTO `accountsave` (serial,ID,PW) VALUES (?,?,?)',getPlayerSerial(source),username,password) 
else 
executeSQLQuery ("UPDATE `accountsave` SET ID=?, PW=? WHERE serial=?",username,password,getPlayerSerial(source)) 
end 
end 
) 
  
addEvent ("deleteLogPass",true) 
addEventHandler ("deleteLogPass",root, 
function (username,password) 
executeSQLQuery ("DELETE FROM `accountsave` WHERE serial",getPlayerSerial(source)) 
end 
) 
  
addEventHandler ("onPlayerJoin",root, -- اظهار لوحة التسجيل في حدث لما الاعب يدخل السيرفر 
function () 
local SQLData = executeSQLQuery ('SELECT * FROM `accountsave` WHERE serial =?',getPlayerSerial(source)) -- ايجاد الداتا 
-- تقدر تحط اكواد هنا 
triggerClientEvent (source,"SHOWwINTRIGGER",source,SQLData) -- تريجر اظهار النافذة 
end 
) 

انتا فهمت انا عايز اعمل ايه

انا عامل شيك بوكس و عاوز لما اكتب الباس و الحساب فلاديت بوكس يتحفظو يعني لما اخروج و ارجع الاقيهم مكتوبين جوا الاديت بوكس

يامعلم انت مش فاهم الاكواد بتاعتي اقرأهم

و عن تجربة ليا مفيش مشاكل

SQL دة لما الاعب يدوس علي زرار التسجيل و هو حاط علامة صح علي الايديت بوكس النظام يحفظ اللي مكتوب في الايديت

لو مش حاط علامة صح يمسح الداتا عشان منع التكرار

دة لما يسجل الدخول

انما لما ييجي يخش مرة تانية

الاعب يعمل تريجر و يجيب بينات الحفظ

لو في بينات محفوظة فعلاً النافذة تظهر و علامة الصح تبقي موجودة في الشيك بوكس

guieditو اليوزر و الباسورد يتحطوا علي ال

لو مفيش بينات محفوظة

علامة الصح تتشال و النافذة تظهرله عادي

يكون فاضي guiedit و ال

المشكلة فيك انت مش فاهم انا عملت ايه

انا اقصد تضيف الاكواد دي عندك

مش اقصد هي دي كل الاكواد

و لو مش عارف تتصرف اطرح الاكواد كلها عشان اساعدك ان شاء الله

Link to comment
---------------- 
--   Client Side 
---------------- 
  
triggerServerEvent("checkPlayerSaveAccount", localPlayer) 
addEvent("SendAccountData", true) 
addEventHandler("SendAccountData", root, function(user, pass) 
    guiSetText(userEdit, user) 
    guiSetText(passEdit, pass) 
end) 
  
  
---------------- 
--   Server Side 
---------------- 
  
--***SQL DATA***-- 
sql = executeSQLQuery 
sql "CREATE TABLE IF NOT EXISTS string_data(data_name TEXT, data_value TEXT)" 
function setSQLData(data, value) 
    assert(type(data) == "string", "Bad Argument @setStringData #1 [string expect, got "..type(data).."]") 
    assert(type(value) == "string", "Bad Argument @setStringData #2 [string expect, got "..type(value).."]") 
    local query = sql("SELECT * FROM string_data WHERE data_name=?", data) 
    if query and type(query) == "table" and #query == 1 then 
        sql("UPDATE string_data SET data_value=? WHERE data_name=?", value, data) 
    else 
        sql("INSERT INTO string_data(data_name, data_value) VALUES(?, ?)", data, value) 
    end 
    return true 
end 
  
function getSQLData(data) 
    assert(type(data) == "string", "Bad Argument @getStringData #1 [string expect, got "..type(data).."]") 
    local query = sql("SELECT data_value FROM string_data WHERE data_name=?", data) 
    return query and type(query) == "table" and #query == 1 and query[1]["data_value"] 
end 
  
function removeSQLData(data) 
    assert(type(data) == "string", "Bad Argument @removeSQLData #1 [string expect, got "..type(data).."]") 
    return sql("DELETE FROM string_data WHERE data_name=?", data) 
end 
  
--***Save Account(Remember me)***-- 
function savePlayerAccount(player, user, pass) 
    if (isElement(player) and getElementType(player) == "player") and type(user) == "string" and type(pass) == "string" then 
        return setSQLData("accountSaved:"..getPlayerSerial(player), toJSON({user, pass})) 
    end 
    return false 
end 
  
function removeSavedPlayerAccount(player) 
    if (isElement(player) and getElementType(player) == "player") then 
        return getSQLData("accountSaved:"..getPlayerSerial(player)) and removeSQLData("accountSaved:"..getPlayerSerial(player)) 
    end 
    return false 
end 
  
function getSavedPlayerAccount(player) 
    if (isElement(player) and getElementType(player) == "player") then 
        return unpack(fromJSON(getSQLData("accountSaved:"..getPlayerSerial(player)))) 
    end 
    return false 
end 
  
addEvent("checkPlayerSaveAccount", true) 
addEventHandler("checkPlayerSaveAccount", root, function( ) 
    local user, pass = getSavedPlayerAccount(source) 
    triggerClientEvent(source, "SendAccountData", source, type(user) == "string" and user or "", type(pass) == "string" and pass or "") 
end) 

اذ سجل الدخول بس سوي

savePlayerAccount(player, user, pass) -- for example : savePlayerAccount(source, "Conosole", "password") 

Link to comment
----------------
--   Client Side
----------------
 
triggerServerEvent("checkPlayerSaveAccount", localPlayer)
addEvent("SendAccountData", true)
addEventHandler("SendAccountData", root, function(user, pass)
    guiSetText(userEdit, user)
    guiSetText(passEdit, pass)
end)
 
 
----------------
--   Server Side
----------------
 
--***SQL DATA***--
sql = executeSQLQuery
sql "CREATE TABLE IF NOT EXISTS string_data(data_name TEXT, data_value TEXT)"
function setSQLData(data, value)
    assert(type(data) == "string", "Bad Argument @setStringData #1 [string expect, got "..type(data).."]")
    assert(type(value) == "string", "Bad Argument @setStringData #2 [string expect, got "..type(value).."]")
    local query = sql("SELECT * FROM string_data WHERE data_name=?", data)
    if query and type(query) == "table" and #query == 1 then
        sql("UPDATE string_data SET data_value=? WHERE data_name=?", value, data)
    else
        sql("INSERT INTO string_data(data_name, data_value) VALUES(?, ?)", data, value)
    end
    return true
end
 
function getSQLData(data)
    assert(type(data) == "string", "Bad Argument @getStringData #1 [string expect, got "..type(data).."]")
    local query = sql("SELECT data_value FROM string_data WHERE data_name=?", data)
    return query and type(query) == "table" and #query == 1 and query[1]["data_value"]
end
 
function removeSQLData(data)
    assert(type(data) == "string", "Bad Argument @removeSQLData #1 [string expect, got "..type(data).."]")
    return sql("DELETE FROM string_data WHERE data_name=?", data)
end
 
--***Save Account(Remember me)***--
function savePlayerAccount(player, user, pass)
    if (isElement(player) and getElementType(player) == "player") and type(user) == "string" and type(pass) == "string" then
        return setSQLData("accountSaved:"..getPlayerSerial(player), toJSON({user, pass}))
    end
    return false
end
 
function removeSavedPlayerAccount(player)
    if (isElement(player) and getElementType(player) == "player") then
        return getSQLData("accountSaved:"..getPlayerSerial(player)) and removeSQLData("accountSaved:"..getPlayerSerial(player))
    end
    return false
end
 
function getSavedPlayerAccount(player)
    if (isElement(player) and getElementType(player) == "player") then
        return unpack(fromJSON(getSQLData("accountSaved:"..getPlayerSerial(player))))
    end
    return false
end
 
addEvent("checkPlayerSaveAccount", true)
addEventHandler("checkPlayerSaveAccount", root, function( )
    local user, pass = getSavedPlayerAccount(source)
    triggerClientEvent(source, "SendAccountData", source, type(user) == "string" and user or "", type(pass) == "string" and pass or "")
end)

اذ سجل الدخول بس سوي

savePlayerAccount(player, user, pass) -- for example : savePlayerAccount(source, "Conosole", "password") 

ما ظبتت بردو

function onClickLogin(button,state)
    if(button == "left" and state == "up") then
        if (source == Log) then
            username = guiGetText(Name)
            password = guiGetText(Pass)
            if guiCheckBoxGetSelected ( sfsave ) == true then
            triggerServerEvent("checkPlayerSaveAccount", localPlayer)
            end
            triggerServerEvent("onRequestLogin",player,username,password,enableKickPlayer,attemptedLogins,maxLoginAttempts,checksave)
            xmlFileHandler()
        end
    end
end
addEventHandler("onClientGUIClick",Log,onClickLogin)

Server Side

player = getLocalPlayer()
function loginPlayer(username,password,enableKickPlayer,attemptedLogins,maxLoginAttempts,checksave)
    if isGuestAccount(getPlayerAccount(source)) then
        if not (username == "") then
            if not (password == "") then
                local account = getAccount ( username, password )
                if ( account ~= false ) then
                    for k,v in ipairs(getAccounts()) do
                        if getAccountData(v, "Serial") == getPlayerSerial(source) then
                            noa = noa+1
                        end
                    end
                    if noa < 2 and not getAccountData(account, "Serial") or getAccountData(account, "Serial") == getPlayerSerial(source) then
                        noa = 0
                        logIn (source, account, password)
                        savePlayerAccount(source, account, password)
                        exports["guimessages"]:outputServer(source,"#ff0000*#FFFF00[server] :#00FF00 You have sucessfully logged in!", 255, 255, 255)
                        setTimer(outputChatBox,700,1,"#ff0000*#FFFF00[server] :#00FF00 To enable auto-login, use /enableauto!",source,255,255,255,true)
                        triggerClientEvent (source,"hideLoginWindow",getRootElement())
                        if checksave == true then
                        triggerClientEvent(source,"saveLoginToXML",getRootElement(),username,password)
                        else
                        triggerClientEvent(source,"resetSaveXML",getRootElement(),username,password)
                        end
                        loadacc(source)
                    else
                        noa = 0
                        outputChatBox("#ff0000*#FFFF00[server] :#FF0000You're allowed to own 2 accounts only!يحق لك أن تملك حسابين فقط", source, 255, 0, 0)
                    end
               
                else
                    if enableKickPlayer == true then
                        if (attemptedLogins >= maxLoginAttempts-1) then
                            exports["guimessages"]:outputServer(source, "#ff0000*#FFFF00[server] :#FF0000 Error! Wrong username or password!", 255, 255, 255)
                            setTimer(outputChatBox,500,1,"#ff0000*#FFFF00[server] :#FF0000 Warning! Maximum login attempts reached! "..attemptedLogins+1 .."/"..maxLoginAttempts.."",source,255,255,255,true)
                            setTimer(outputChatBox,1000,1,"#ff0000*#FFFF00[server] :#ff0000 You will be kicked in seconds!",source,255,255,255,true)
                            setTimer(kickPlayer,5000,1,source,"Failed to login")
                        else
                            exports["guimessages"]:outputServer(source, "#ff0000*#FFFF00[server] :#FF0000 Error! Wrong username and/or password!", 255, 255, 255)
                            setTimer(outputChatBox,500,1,"#ff0000*#FFFF00[server] :#00FF00 Login attempts: "..attemptedLogins+1 .."/"..maxLoginAttempts.."",source,255,255,255,true)
                            triggerClientEvent(source,"onRequestIncreaseAttempts",source)
                        end
                    else
                        exports["guimessages"]:outputServer(source, "#ff0000*#FFFF00[server] :#FF0000 Error! Wrong username or password!", 255, 255, 255)
                    end
                end
            else
                exports["guimessages"]:outputServer(source,"#ff0000*#FFFF00[server] :#FF0000 Error! Please enter your password!",255, 255, 255)
            end
        else
            exports["guimessages"]:outputServer(source, "#ff0000*#FFFF00[server] :#ff0000 Error! Please enter your username!", 255, 255, 255)
        end
    else
        logIn (source, account, password)
        exports["guimessages"]:outputServer(source, "#ff0000*#FFFF00[server] :#00FF00 You have sucessfully logged in!", 0 , 255, 0)
        setTimer(outputChatBox,700,1,"#ff0000*#FFFF00[server] :#00FF00To enable auto-login, use /enableauto!",source,255,255,255,true)
        triggerClientEvent (source,"hideLoginWindow",getRootElement())
        loadacc(source)
  end
end

Link to comment
----------------
--   Client Side
----------------
 
triggerServerEvent("checkPlayerSaveAccount", localPlayer)
addEvent("SendAccountData", true)
addEventHandler("SendAccountData", root, function(user, pass)
    guiSetText(userEdit, user)
    guiSetText(passEdit, pass)
end)
 
 
----------------
--   Server Side
----------------
 
--***SQL DATA***--
sql = executeSQLQuery
sql "CREATE TABLE IF NOT EXISTS string_data(data_name TEXT, data_value TEXT)"
function setSQLData(data, value)
    assert(type(data) == "string", "Bad Argument @setStringData #1 [string expect, got "..type(data).."]")
    assert(type(value) == "string", "Bad Argument @setStringData #2 [string expect, got "..type(value).."]")
    local query = sql("SELECT * FROM string_data WHERE data_name=?", data)
    if query and type(query) == "table" and #query == 1 then
        sql("UPDATE string_data SET data_value=? WHERE data_name=?", value, data)
    else
        sql("INSERT INTO string_data(data_name, data_value) VALUES(?, ?)", data, value)
    end
    return true
end
 
function getSQLData(data)
    assert(type(data) == "string", "Bad Argument @getStringData #1 [string expect, got "..type(data).."]")
    local query = sql("SELECT data_value FROM string_data WHERE data_name=?", data)
    return query and type(query) == "table" and #query == 1 and query[1]["data_value"]
end
 
function removeSQLData(data)
    assert(type(data) == "string", "Bad Argument @removeSQLData #1 [string expect, got "..type(data).."]")
    return sql("DELETE FROM string_data WHERE data_name=?", data)
end
 
--***Save Account(Remember me)***--
function savePlayerAccount(player, user, pass)
    if (isElement(player) and getElementType(player) == "player") and type(user) == "string" and type(pass) == "string" then
        return setSQLData("accountSaved:"..getPlayerSerial(player), toJSON({user, pass}))
    end
    return false
end
 
function removeSavedPlayerAccount(player)
    if (isElement(player) and getElementType(player) == "player") then
        return getSQLData("accountSaved:"..getPlayerSerial(player)) and removeSQLData("accountSaved:"..getPlayerSerial(player))
    end
    return false
end
 
function getSavedPlayerAccount(player)
    if (isElement(player) and getElementType(player) == "player") then
        return unpack(fromJSON(getSQLData("accountSaved:"..getPlayerSerial(player))))
    end
    return false
end
 
addEvent("checkPlayerSaveAccount", true)
addEventHandler("checkPlayerSaveAccount", root, function( )
    local user, pass = getSavedPlayerAccount(source)
    triggerClientEvent(source, "SendAccountData", source, type(user) == "string" and user or "", type(pass) == "string" and pass or "")
end)

اذ سجل الدخول بس سوي

savePlayerAccount(player, user, pass) -- for example : savePlayerAccount(source, "Conosole", "password") 

ما ظبتت بردو

function onClickLogin(button,state)
    if(button == "left" and state == "up") then
        if (source == Log) then
            username = guiGetText(Name)
            password = guiGetText(Pass)
            if guiCheckBoxGetSelected ( sfsave ) == true then
            triggerServerEvent("checkPlayerSaveAccount", localPlayer)
            end
            triggerServerEvent("onRequestLogin",player,username,password,enableKickPlayer,attemptedLogins,maxLoginAttempts,checksave)
            xmlFileHandler()
        end
    end
end
addEventHandler("onClientGUIClick",Log,onClickLogin)

Server Side

player = getLocalPlayer()
function loginPlayer(username,password,enableKickPlayer,attemptedLogins,maxLoginAttempts,checksave)
    if isGuestAccount(getPlayerAccount(source)) then
        if not (username == "") then
            if not (password == "") then
                local account = getAccount ( username, password )
                if ( account ~= false ) then
                    for k,v in ipairs(getAccounts()) do
                        if getAccountData(v, "Serial") == getPlayerSerial(source) then
                            noa = noa+1
                        end
                    end
                    if noa < 2 and not getAccountData(account, "Serial") or getAccountData(account, "Serial") == getPlayerSerial(source) then
                        noa = 0
                        logIn (source, account, password)
                        savePlayerAccount(source, account, password)
                        exports["guimessages"]:outputServer(source,"#ff0000*#FFFF00[server] :#00FF00 You have sucessfully logged in!", 255, 255, 255)
                        setTimer(outputChatBox,700,1,"#ff0000*#FFFF00[server] :#00FF00 To enable auto-login, use /enableauto!",source,255,255,255,true)
                        triggerClientEvent (source,"hideLoginWindow",getRootElement())
                        if checksave == true then
                        triggerClientEvent(source,"saveLoginToXML",getRootElement(),username,password)
                        else
                        triggerClientEvent(source,"resetSaveXML",getRootElement(),username,password)
                        end
                        loadacc(source)
                    else
                        noa = 0
                        outputChatBox("#ff0000*#FFFF00[server] :#FF0000You're allowed to own 2 accounts only!يحق لك أن تملك حسابين فقط", source, 255, 0, 0)
                    end
               
                else
                    if enableKickPlayer == true then
                        if (attemptedLogins >= maxLoginAttempts-1) then
                            exports["guimessages"]:outputServer(source, "#ff0000*#FFFF00[server] :#FF0000 Error! Wrong username or password!", 255, 255, 255)
                            setTimer(outputChatBox,500,1,"#ff0000*#FFFF00[server] :#FF0000 Warning! Maximum login attempts reached! "..attemptedLogins+1 .."/"..maxLoginAttempts.."",source,255,255,255,true)
                            setTimer(outputChatBox,1000,1,"#ff0000*#FFFF00[server] :#ff0000 You will be kicked in seconds!",source,255,255,255,true)
                            setTimer(kickPlayer,5000,1,source,"Failed to login")
                        else
                            exports["guimessages"]:outputServer(source, "#ff0000*#FFFF00[server] :#FF0000 Error! Wrong username and/or password!", 255, 255, 255)
                            setTimer(outputChatBox,500,1,"#ff0000*#FFFF00[server] :#00FF00 Login attempts: "..attemptedLogins+1 .."/"..maxLoginAttempts.."",source,255,255,255,true)
                            triggerClientEvent(source,"onRequestIncreaseAttempts",source)
                        end
                    else
                        exports["guimessages"]:outputServer(source, "#ff0000*#FFFF00[server] :#FF0000 Error! Wrong username or password!", 255, 255, 255)
                    end
                end
            else
                exports["guimessages"]:outputServer(source,"#ff0000*#FFFF00[server] :#FF0000 Error! Please enter your password!",255, 255, 255)
            end
        else
            exports["guimessages"]:outputServer(source, "#ff0000*#FFFF00[server] :#ff0000 Error! Please enter your username!", 255, 255, 255)
        end
    else
        logIn (source, account, password)
        exports["guimessages"]:outputServer(source, "#ff0000*#FFFF00[server] :#00FF00 You have sucessfully logged in!", 0 , 255, 0)
        setTimer(outputChatBox,700,1,"#ff0000*#FFFF00[server] :#00FF00To enable auto-login, use /enableauto!",source,255,255,255,true)
        triggerClientEvent (source,"hideLoginWindow",getRootElement())
        loadacc(source)
  end
end

اطرح الكود بتاعك

اللي هو لما شخص يدخل السيرفر

تظهرله لوحة التسجيل

سيرفر و كلينت او علي حسب اللي عملته

triggerServerEvent("checkPlayerSaveAccount", localPlayer)

و دة كمان اطرح الايفينت

و بالنسبة لأكواد التسجيل في السيرفر

امسحها xml انت حاط فيها فنكشنات تريجر

و ماعملتش اللي قولتلك عليه :mrgreen:

Edited by Guest
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...