AboShanab Posted March 30, 2013 Share Posted March 30, 2013 (edited) السسلام عليكم ورحمة الله وبركاته .. اخباركم شباب .. عسساكم بخير .. اليوم انا مسوي لوحة تسجيل + تسجيل الدخول انا سويت لهـا حفظ بـ SQL لاكن الان ابيها اذا جط على checkbox صح اذا دخل المرة الثانية يكون اسم المستخدم + كلمة المرور محفوظة كود تسجيل الدخول + التسجيل 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 ) triggerClientEvent (source, "HideWindow", source) 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 ) triggerClientEvent (source, "HideWindow", source) else outputChatBox ( "You Are Already Logged in !", player, 255, 255, 0 ) triggerClientEvent (source, "HideWindow", source) 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 ) triggerClientEvent (source, "HideWindow", source) else outputChatBox ( "Register Error !", player, 255, 0, 0 ) end end end ) كود الـ SQL 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 ) هل من ححل وششكرا Edited March 30, 2013 by Guest Link to comment
iPrestege Posted March 30, 2013 Share Posted March 30, 2013 ضيف على نفس الجدول جدول للشيك بوكس و حطه يوم يسجل الدخول يشيك على الشيك ويرسل للسيرفر ويكون فية اون كلنت ريسورس ستارت بـ حيث يتأكد اذا كان موجود ومحفوظ الشيك او لا وترسل الحساب و الباس # وعندك فنكشن زايد مدري حق وش مسوية Link to comment
AboShanab Posted March 30, 2013 Author Share Posted March 30, 2013 من عقلي ذذ .. اخوي بريستيج ي اخي سو لي الكود او عطني مثال يعني ساعدني اكثر الله يعطيك العافية .. من امس وانا افكر في الكود ماني عارف ي اخي .. لا تنسى اني توني جالس اتعلم على SQL .. ساعدني وماراح انسى لك المعروف Link to comment
AboShanab Posted March 30, 2013 Author Share Posted March 30, 2013 GUIEditor = { checkbox = {}, edit = {}, button = {}, window = {}, label = {} } addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(201, 188, 490, 255, "مود تسجيل الدخول + التسجيل من قبل العم ابو شنب", false) guiSetVisible (GUIEditor.window[1], false) guiWindowSetSizable(GUIEditor.window[1],false) guiWindowSetMovable(GUIEditor.window[1],true) guiSetProperty(GUIEditor.window[1], "CaptionColour", "FF1B7EE3") GUIEditor.button[1] = guiCreateButton(10, 22, 22, 21, "Ar", false, GUIEditor.window[1]) guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FF1B7EE3") GUIEditor.button[2] = guiCreateButton(36, 22, 22, 21, "En", false, GUIEditor.window[1]) guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FF1B7EE3") GUIEditor.button[3] = guiCreateButton(456, 21, 24, 27, "X", false, GUIEditor.window[1]) guiSetProperty(GUIEditor.button[3], "NormalTextColour", "FFFF0000") GUIEditor.label[1] = guiCreateLabel(185, 43, 127, 25, "اسم الحساب", false, GUIEditor.window[1]) guiLabelSetColor(GUIEditor.label[1], 236, 141, 17) GUIEditor.edit[1] = guiCreateEdit(91, 78, 310, 31, "", false, GUIEditor.window[1]) GUIEditor.label[2] = guiCreateLabel(185, 121, 127, 25, "كلمة المرور", false, GUIEditor.window[1]) guiLabelSetColor(GUIEditor.label[2], 236, 141, 17) GUIEditor.edit[2] = guiCreateEdit(90, 156, 310, 31, "", false, GUIEditor.window[1]) GUIEditor.checkbox[1] = guiCreateCheckBox(421, 230, 59, 16, "حفظ ؟", false, false, GUIEditor.window[1]) GUIEditor.button[4] = guiCreateButton(10, 194, 114, 36, "تسجيل", false, GUIEditor.window[1]) GUIEditor.button[5] = guiCreateButton(178, 194, 114, 36, "تسجيل الدخول", false, GUIEditor.window[1]) GUIEditor.button[6] = guiCreateButton(338, 194, 114, 36, "زائر", false, GUIEditor.window[1]) end ) ---------- -- bindKey ---------- bindKey ( "F7" , "down" , function() if ( guiGetVisible ( GUIEditor.window[1] ) == true ) then guiSetVisible ( GUIEditor.window[1] ,false ) showCursor (false ) guiSetInputEnabled(false) elseif ( guiGetVisible ( GUIEditor.window[1] ) == false ) then guiSetVisible ( GUIEditor.window[1] ,true ) showCursor (false ) guiSetInputEnabled(true) playSound("xAboShanab.mp3") end end ) -------------------- -- Login and register -------------------- function clickLoginRegister() if (source == GUIEditor.button[5]) then triggerServerEvent ( "onLogin", getRootElement(), getLocalPlayer(), guiGetText(GUIEditor.edit[1]), guiGetText(GUIEditor.edit[2]) ) elseif (source == GUIEditor.button[4]) then triggerServerEvent ( "onReg", getRootElement(), getLocalPlayer(), guiGetText(GUIEditor.edit[1]), guiGetText(GUIEditor.edit[2]) ) end end addEventHandler ("onClientGUIClick", getRootElement(), clickLoginRegister) -------------------- -- Languages -------------------- addEventHandler("onClientGUIClick",getRootElement(), function () if ( source == GUIEditor.button[1] ) then guiSetText(GUIEditor.window[1],"مود التسجيل + تسجيل الدخول من قبل ابو شنب") guiSetText(GUIEditor.label[1],"اسم الحساب") guiSetText(GUIEditor.label[2],"كلمة المرور") guiSetText(GUIEditor.checkbox[1],"حفظ ؟") guiSetText(GUIEditor.button[4],"تسجيل") guiSetText(GUIEditor.button[5],"تسجيل الدخول") guiSetText(GUIEditor.button[6],"زائر") elseif ( source == GUIEditor.button[2] ) then guiSetText(GUIEditor.window[1],"Script register / login By AboShanab") guiSetText(GUIEditor.label[1],"Name Account") guiSetText(GUIEditor.label[2],"Password") guiSetText(GUIEditor.checkbox[1],"Save ?") guiSetText(GUIEditor.button[4],"register") guiSetText(GUIEditor.button[5],"login") guiSetText(GUIEditor.button[5],"Guest") end end ) -------------------- -- Exit Window -------------------- addEventHandler("onClientGUIClick",getRootElement(), function () if ( source == GUIEditor.button[3] ) then guiSetVisible ( GUIEditor.window[1] ,false ) showCursor (false) guiSetInputEnabled(false) end end ) -------------------- -- Hide Window Function -------------------- addEvent("HideWindow", true) addEventHandler("HideWindow",root, function() guiSetVisible (GUIEditor.window[1], false) end ) Link to comment
MR.S3D Posted March 30, 2013 Share Posted March 30, 2013 Client GUIEditor = { checkbox = {}, edit = {}, button = {}, window = {}, label = {} } addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(201, 188, 490, 255, "مود تسجيل الدخول + التسجيل من قبل العم ابو شنب", false) guiSetVisible (GUIEditor.window[1], false) guiWindowSetSizable(GUIEditor.window[1],false) guiWindowSetMovable(GUIEditor.window[1],true) guiSetProperty(GUIEditor.window[1], "CaptionColour", "FF1B7EE3") GUIEditor.button[1] = guiCreateButton(10, 22, 22, 21, "Ar", false, GUIEditor.window[1]) guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FF1B7EE3") GUIEditor.button[2] = guiCreateButton(36, 22, 22, 21, "En", false, GUIEditor.window[1]) guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FF1B7EE3") GUIEditor.button[3] = guiCreateButton(456, 21, 24, 27, "X", false, GUIEditor.window[1]) guiSetProperty(GUIEditor.button[3], "NormalTextColour", "FFFF0000") GUIEditor.label[1] = guiCreateLabel(185, 43, 127, 25, "اسم الحساب", false, GUIEditor.window[1]) guiLabelSetColor(GUIEditor.label[1], 236, 141, 17) GUIEditor.edit[1] = guiCreateEdit(91, 78, 310, 31, "", false, GUIEditor.window[1]) GUIEditor.label[2] = guiCreateLabel(185, 121, 127, 25, "كلمة المرور", false, GUIEditor.window[1]) guiLabelSetColor(GUIEditor.label[2], 236, 141, 17) GUIEditor.edit[2] = guiCreateEdit(90, 156, 310, 31, "", false, GUIEditor.window[1]) GUIEditor.checkbox[1] = guiCreateCheckBox(421, 230, 59, 16, "حفظ ؟", false, false, GUIEditor.window[1]) GUIEditor.button[4] = guiCreateButton(10, 194, 114, 36, "تسجيل", false, GUIEditor.window[1]) GUIEditor.button[5] = guiCreateButton(178, 194, 114, 36, "تسجيل الدخول", false, GUIEditor.window[1]) GUIEditor.button[6] = guiCreateButton(338, 194, 114, 36, "زائر", false, GUIEditor.window[1]) end ) ---------- -- bindKey ---------- bindKey ( "F7" , "down" , function() if ( guiGetVisible ( GUIEditor.window[1] ) == true ) then guiSetVisible ( GUIEditor.window[1] ,false ) showCursor (false ) guiSetInputEnabled(false) elseif ( guiGetVisible ( GUIEditor.window[1] ) == false ) then guiSetVisible ( GUIEditor.window[1] ,true ) showCursor (false ) guiSetInputEnabled(true) playSound("xAboShanab.mp3") end end ) -------------------- -- Login and register -------------------- function clickLoginRegister() if (source == GUIEditor.button[5]) then triggerServerEvent ( "onLogin", getRootElement(), getLocalPlayer(), guiGetText(GUIEditor.edit[1]), guiGetText(GUIEditor.edit[2]) ) elseif (source == GUIEditor.button[4]) then triggerServerEvent ( "onReg", getRootElement(), getLocalPlayer(), guiGetText(GUIEditor.edit[1]), guiGetText(GUIEditor.edit[2]) ) end end addEventHandler ("onClientGUIClick", getRootElement(), clickLoginRegister) -------------------- -- Languages -------------------- addEventHandler("onClientGUIClick",getRootElement(), function () if ( source == GUIEditor.button[1] ) then guiSetText(GUIEditor.window[1],"مود التسجيل + تسجيل الدخول من قبل ابو شنب") guiSetText(GUIEditor.label[1],"اسم الحساب") guiSetText(GUIEditor.label[2],"كلمة المرور") guiSetText(GUIEditor.checkbox[1],"حفظ ؟") guiSetText(GUIEditor.button[4],"تسجيل") guiSetText(GUIEditor.button[5],"تسجيل الدخول") guiSetText(GUIEditor.button[6],"زائر") elseif ( source == GUIEditor.button[2] ) then guiSetText(GUIEditor.window[1],"Script register / login By AboShanab") guiSetText(GUIEditor.label[1],"Name Account") guiSetText(GUIEditor.label[2],"Password") guiSetText(GUIEditor.checkbox[1],"Save ?") guiSetText(GUIEditor.button[4],"register") guiSetText(GUIEditor.button[5],"login") guiSetText(GUIEditor.button[5],"Guest") end end ) -------------------- -- Exit Window -------------------- addEventHandler("onClientGUIClick",getRootElement(), function () if ( source == GUIEditor.button[3] ) then guiSetVisible ( GUIEditor.window[1] ,false ) showCursor (false) guiSetInputEnabled(false) end end ) -------------------- -- Hide Window Function -------------------- addEvent("HideWindow", true) addEventHandler("HideWindow",root, function() guiSetVisible (GUIEditor.window[1], false) xmlFile(guiCheckBoxGetSelected(GUIEditor.checkbox[1])) end ) ----------------------- --get user name and passward & add ------------------------ addEventHandler( 'onClientResourceStart', getResourceRootElement(getThisResource()), function( ) showLoginWindow() end ) addEvent("addUserNameAndPassword", true) addEventHandler("addUserNameAndPassword",root, function(user,pass) guiSetText(GUIEditor.edit[1],tostring(user)) guiSetText(GUIEditor.edit[2],tostring(pass)) end ) function showLoginWindow() xmlFileName = "login.xml" local xmlFile = xmlLoadFile(xmlFileName) if xmlFile then status = xmlNodeGetAttribute(xmlFile, "savecheckbox") end if status == "true" then local username = tostring(xmlNodeGetAttribute(xmlFile, "username")) if username ~= "" then guiCheckBoxSetSelected(GUIEditor.checkbox[1],true) triggerServerEvent ( "getUserNameAndPassword", getLocalPlayer(),username) end end end function xmlFile(find) if find == true then setElementData(localPlayer, "checkbox", true) else setElementData(localPlayer, "checkbox", false) end xmlFileName = "login.xml" local xmlFile = xmlLoadFile(xmlFileName) if not xmlFile then xmlFile = xmlCreateFile(xmlFileName, "checkbox") xmlNodeSetAttribute(xmlFile, "savecheckbox", tostring(getElementData(localPlayer, "checkbox"))) end xmlNodeSetAttribute(xmlFile, "savecheckbox", tostring(getElementData(localPlayer, "checkbox"))) xmlNodeSetAttribute(xmlFile, "username", tostring(guiGetText(GUIEditor.edit[1]))) xmlSaveFile(xmlFile) xmlUnloadFile(xmlFile) end Server السيرفر كامل مع sql addEventHandler ( "onResourceStart", resourceRoot, function ( ) executeSQLQuery ( "CREATE TABLE IF NOT EXISTS SaveSystemByAboShanab (NameAccount,Password)" ) end ) addEvent ( "getUserNameAndPassword", true ) addEventHandler ( "getUserNameAndPassword", root, function ( user ) local res = executeSQLQuery( "SELECT * FROM SaveSystemByAboShanab WHERE NameAccount = ?", tostring( user )) if ( type ( res ) == "table" and #res == 0 ) or not res then return end triggerClientEvent (source, "addUserNameAndPassword", source,res[1]["NameAccount"],res[1]["Password"]) end ) 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 ) triggerClientEvent (source, "HideWindow", source) 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 ) triggerClientEvent (source, "HideWindow", source) else outputChatBox ( "You Are Already Logged in !", player, 255, 255, 0 ) triggerClientEvent (source, "HideWindow", source) end else account = addAccount ( user, pass ) if (logIn ( player, account, pass ) == true) then outputChatBox ( "You Registerd and Logged in Sucessfuly!", player, 255, 255, 0 ) local res = executeSQLQuery( "SELECT * FROM SaveSystemByAboShanab WHERE NameAccount = ?", tostring( user )) if ( type ( res ) == "table" and #res == 0 ) or not res then executeSQLQuery ( "INSERT INTO SaveSystemByAboShanab ( NameAccount, Password ) VALUES ( ?, ? )", user, pass ) end triggerClientEvent (source, "HideWindow", source) else outputChatBox ( "Register Error !", player, 255, 0, 0 ) end end end ) Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now