CRoW,,# Posted March 18, 2013 Share Posted March 18, 2013 وش استخدم عشان اسوي لوحة تسجيل دخول Link to comment
iPrestege Posted March 18, 2013 Share Posted March 18, 2013 getAccount addAccount logIn Link to comment
CRoW,,# Posted March 18, 2013 Author Share Posted March 18, 2013 function centerWindow( center_window ) local screenW, screenH = guiGetScreenSize( ); local windowW, windowH = guiGetSize( center_window, false ); local x, y = ( screenW - windowW ) / 2, ( screenH - windowH ) / 2; guiSetPosition( center_window, x, y, false ); end GUIEditor_Button = {} GUIEditor_Checkbox = {} GUIEditor_Label = {} GUIEditor_Edit = {} GUIEditor_Image = {} wnd = guiCreateWindow(1,1,799,599,"",false) guiSetAlpha(wnd,1) GUIEditor_Image[1] = guiCreateStaticImage(10,25,780,438,"images/tarkep.png",false,wnd) GUIEditor_Button[1] = guiCreateButton(248,564,94,26,"login",false,wnd) GUIEditor_Button[2] = guiCreateButton(420,565,94,24,"register",false,wnd) GUIEditor_Checkbox[1] = guiCreateCheckBox(438,525,25,38,"",false,false,wnd) guiCheckBoxSetSelected(GUIEditor_Checkbox[1],true) GUIEditor_Label[1] = guiCreateLabel(463,532,142,19,"حفظ كلمة المرور",false,wnd) GUIEditor_Edit[1] = guiCreateEdit(306,468,169,23,"",false,wnd) GUIEditor_Edit[2] = guiCreateEdit(306,501,169,23,"",false,wnd) GUIEditor_Label[2] = guiCreateLabel(243,469,110,21,"username",false,wnd) GUIEditor_Label[3] = guiCreateLabel(243,502,110,21,"password",false,wnd) ss = guiCreateStaticImage(1,1,799,599,"images/صوره.png",false) guiSetVisible(wnd,false) addEventHandler("onClientResourceStart", root, function() guiSetVisible(wnd, true) showCursor(true) end) addEventHandler("onClientGUIClick",root, function () local user = guiGetText(GUIEditor.edit[1]) local pass = guiGetText(GUIEditor.edit[2]) if ( source == GUIEditor_Button[1] ) then if string.len(user) > 0 and string.len(pass) > 0 then triggerServerEvent("onLogin",localPlayer,user,pass) end elseif ( source == GUIEditor_Button[2] ) then if string.len(user) > 0 and string.len(pass) > 0 then triggerServerEvent("onRegister",localPlayer,user,pass) end end end كذا ؟ Link to comment
iPrestege Posted March 18, 2013 Share Posted March 18, 2013 addEventHandler("onClientGUIClick",root, function () local user = guiGetText(GUIEditor.edit[1]) local pass = guiGetText(GUIEditor.edit[2]) if ( source == GUIEditor_Button[1] ) then if string.len(user) > 0 and string.len(pass) > 0 then triggerServerEvent("onLogin",localPlayer,user,pass) end elseif ( source == GUIEditor_Button[2] ) then if string.len(user) > 0 and string.len(pass) > 0 then triggerServerEvent("onRegister",localPlayer,user,pass) end end end ) Link to comment
CRoW,,# Posted March 18, 2013 Author Share Posted March 18, 2013 (edited) طيب ابي الكود الي يحفظ الباس +الحساب وابي اربطه بالCheckBox Edited March 18, 2013 by Guest Link to comment
CRoW,,# Posted March 18, 2013 Author Share Posted March 18, 2013 تضغط على CheckBox وتنحفظ البيانات اذا دخلت مرة ثانية تحصل الحساب+الباس موجودين يعني تضغط login وتدخل Link to comment
CRoW,,# Posted March 18, 2013 Author Share Posted March 18, 2013 XML File or SQL . طيب وش الامر الي يسويه ؟ Link to comment
PaiN^ Posted March 18, 2013 Share Posted March 18, 2013 هذي قواعد بيانات تحفظ فيها المعلومات Link to comment
CRoW,,# Posted March 18, 2013 Author Share Posted March 18, 2013 هذي قواعد بيانات تحفظ فيها المعلومات ادري ذذ Link to comment
X-SHADOW Posted March 18, 2013 Share Posted March 18, 2013 https://wiki.multitheftauto.com/wiki/Cl ... _functions Link to comment
CRoW,,# Posted March 18, 2013 Author Share Posted March 18, 2013 local username, password = loadLoginFromXML() if not( username == "" or password == "") then guiCheckBoxSetSelected ( checkbox_save, true ) guiSetText ( edit_Login, tostring(username)) guiSetText ( edit_password, tostring(password)) else guiCheckBoxSetSelected ( GUIEditor_Checkbox[1], false ) guiSetText ( GUIEditor_Button[1], tostring(username)) guiSetText ( GUIEditor_Button[2], tostring(password)) end end "" pass="" save="false"> ذا ميتا اذا في خطا صححوه لاهنتم Link to comment
#Al-Ha[J]aRii Posted March 18, 2013 Share Posted March 18, 2013 Client Side ! function centerWindow( center_window ) local screenW, screenH = guiGetScreenSize( ); local windowW, windowH = guiGetSize( center_window, false ); local x, y = ( screenW - windowW ) / 2, ( screenH - windowH ) / 2; guiSetPosition( center_window, x, y, false ); end GUIEditor_Button = {} GUIEditor_Checkbox = {} GUIEditor_Label = {} GUIEditor_Edit = {} GUIEditor_Image = {} wnd = guiCreateWindow(1,1,799,599,"",false) guiSetAlpha(wnd,1) GUIEditor_Image[1] = guiCreateStaticImage(10,25,780,438,"images/tarkep.png",false,wnd) GUIEditor_Button[1] = guiCreateButton(248,564,94,26,"login",false,wnd) GUIEditor_Button[2] = guiCreateButton(420,565,94,24,"register",false,wnd) GUIEditor_Checkbox[1] = guiCreateCheckBox(438,525,25,38,"",false,false,wnd) guiCheckBoxSetSelected(GUIEditor_Checkbox[1],true) GUIEditor_Label[1] = guiCreateLabel(463,532,142,19,"حفظ كلمة المرور",false,wnd) GUIEditor_Edit[1] = guiCreateEdit(306,468,169,23,"",false,wnd) GUIEditor_Edit[2] = guiCreateEdit(306,501,169,23,"",false,wnd) GUIEditor_Label[2] = guiCreateLabel(243,469,110,21,"username",false,wnd) GUIEditor_Label[3] = guiCreateLabel(243,502,110,21,"password",false,wnd) ss = guiCreateStaticImage(1,1,799,599,"images/صوره.png",false) guiSetVisible(wnd,false) addEventHandler("onClientResourceStart", root, function() guiSetVisible(wnd, true) showCursor(true) end) addEventHandler ("onClientGUIClick", root, function ( ) if ( source == GUIEditor.button[1] ) then triggerServerEvent("login", localPlayer, localPlayer, guiGetText ( GUIEditor.edit[1] ), guiGetText ( GUIEditor.edit[2] ) ) elseif ( source == GUIEditor.button[2] ) then triggerServerEvent("register", localPlayer, localPlayer, guiGetText ( GUIEditor.edit[1] ), guiGetText ( GUIEditor.edit[2] ) ) end end ) addEvent ( "HideTheWindow", true ) addEventHandler ( "HideTheWindow", root, function ( ) guiSetVisible ( wnd, false ) fadeCamera ( true ) showCursor ( false ) end ) Server Side ! addEvent ( "login", true ) addEventHandler ( "login", 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 With User : #00FF00[ " .. user .. " ]!", player, 255, 255, 0 , true ) setElementModel ( player, 287 ) triggerClientEvent ( player, "HideTheWindow", player ) else outputChatBox ( "Your Login Error!", player, 255, 255, 0 ) end else outputChatBox ( "Wrong Username or Password!", player, 255, 255, 0 ) end end ) addEvent ( "register", true ) addEventHandler ( "register", 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 ) setElementModel ( player, 287 ) triggerClientEvent ( player, "HideTheWindow", player ) 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 - Please Remember Your User/Password!", player, 255, 255, 0 ) outputChatBox ( "Register Details : [ Username ] : #00FF00" .. user .. " #FFFF1A[ Password ] : #00FF00" .. pass .. "", player, 255, 255, 0 , true ) setElementModel ( player, 287 ) triggerClientEvent ( player, "HideTheWindow", player ) else outputChatBox ( "Register/Login error!", player, 255, 255, 0 ) end end end ) Link to comment
][sojn][ Posted March 18, 2013 Share Posted March 18, 2013 قاعدة البيانات صعب sql اول تعلم اكثر وزد خبرتك وبعدين تعمق بالاشياء ذي Link to comment
#Al-Ha[J]aRii Posted March 18, 2013 Share Posted March 18, 2013 الحجري كودك غلط شكرآ على تنبيه اصلحه الحين لاني عملته بسرعة ذذ Link to comment
CRoW,,# Posted March 18, 2013 Author Share Posted March 18, 2013 قاعدة البيانات صعب sql اول تعلم اكثر وزد خبرتك وبعدين تعمق بالاشياء ذي لا مو لازم sql +حصلت الككود حق الحفظ Link to comment
CRoW,,# Posted March 18, 2013 Author Share Posted March 18, 2013 الكود النهائي function centerWindow( center_window ) local screenW, screenH = guiGetScreenSize( ); local windowW, windowH = guiGetSize( center_window, false ); local x, y = ( screenW - windowW ) / 2, ( screenH - windowH ) / 2; guiSetPosition( center_window, x, y, false ); end GUIEditor_Button = {} GUIEditor_Checkbox = {} GUIEditor_Label = {} GUIEditor_Edit = {} GUIEditor_Image = {} wnd = guiCreateWindow(1,1,799,599,"",false) guiSetAlpha(wnd,1) GUIEditor_Image[1] = guiCreateStaticImage(10,25,780,438,"images/tarkep.png",false,wnd) GUIEditor_Button[1] = guiCreateButton(248,564,94,26,"login",false,wnd) GUIEditor_Button[2] = guiCreateButton(420,565,94,24,"register",false,wnd) GUIEditor_Checkbox[1] = guiCreateCheckBox(438,525,25,38,"",false,false,wnd) guiCheckBoxSetSelected(GUIEditor_Checkbox[1],true) GUIEditor_Label[1] = guiCreateLabel(463,532,142,19,"حفظ كلمة المرور",false,wnd) GUIEditor_Edit[1] = guiCreateEdit(306,468,169,23,"",false,wnd) GUIEditor_Edit[2] = guiCreateEdit(306,501,169,23,"",false,wnd) GUIEditor_Label[2] = guiCreateLabel(243,469,110,21,"username",false,wnd) GUIEditor_Label[3] = guiCreateLabel(243,502,110,21,"password",false,wnd) ss = guiCreateStaticImage(1,1,799,599,"images/صوره.png",false) guiSetVisible(wnd,false) addEventHandler("onClientResourceStart", root, function() guiSetVisible(wnd, true) showCursor(true) end) addEventHandler ("onClientGUIClick", root, function ( ) if ( source == GUIEditor.button[1] ) then triggerServerEvent("login", localPlayer, localPlayer, guiGetText ( GUIEditor.edit[1] ), guiGetText ( GUIEditor.edit[2] ) ) elseif ( source == GUIEditor.button[2] ) then triggerServerEvent("register", localPlayer, localPlayer, guiGetText ( GUIEditor.edit[1] ), guiGetText ( GUIEditor.edit[2] ) ) end end ) local username, password = loadLoginFromXML() if not( username == "" or password == "") then guiCheckBoxSetSelected ( GUIEditor_Checkbox[1], true ) guiSetText ( GUIEditor_Button[1], tostring(username)) guiSetText ( GUIEditor_Button[2], tostring(password)) else guiCheckBoxSetSelected ( GUIEditor_Checkbox[1], false ) guiSetText ( GUIEditor_Button[1], tostring(username)) guiSetText ( GUIEditor_Button[2], tostring(password)) end end end function saveLoginToXML(username, password) local xml_save_log_File = xmlLoadFile ("files/xml/userdata.xml") if not xml_save_log_File then xml_save_log_File = xmlCreateFile("files/xml/userdata.xml", "login") end if (username ~= "") then local usernameNode = xmlFindChild (xml_save_log_File, "username", 0) if not usernameNode then usernameNode = xmlCreateChild(xml_save_log_File, "username") end xmlNodeSetValue (usernameNode, tostring(username)) end if (password ~= "") then local passwordNode = xmlFindChild (xml_save_log_File, "password", 0) if not passwordNode then passwordNode = xmlCreateChild(xml_save_log_File, "password") end xmlNodeSetValue (passwordNode, tostring(password)) end xmlSaveFile(xml_save_log_File) xmlUnloadFile (xml_save_log_File) end addEvent("saveLoginToXML", true) addEventHandler("saveLoginToXML", getRootElement(), saveLoginToXML) function resetSaveXML() local xml_save_log_File = xmlLoadFile ("files/xml/userdata.xml") if not xml_save_log_File then xml_save_log_File = xmlCreateFile("files/xml/userdata.xml", "login") end if (username ~= "") then local usernameNode = xmlFindChild (xml_save_log_File, "username", 0) if not usernameNode then usernameNode = xmlCreateChild(xml_save_log_File, "username") end end if (password ~= "") then local passwordNode = xmlFindChild (xml_save_log_File, "password", 0) if not passwordNode then passwordNode = xmlCreateChild(xml_save_log_File, "password") end xmlNodeSetValue (passwordNode, "") end xmlSaveFile(xml_save_log_File) xmlUnloadFile (xml_save_log_File) end addEvent("resetSaveXML", true) addEventHandler("resetSaveXML", getRootElement(), resetSaveXML) if(button == "left" and state == "up") then if (source == shLogin) then username = guiGetText(GUIEditor_Edit[1]) password = guiGetText(GUIEditor_Edit[2]) if guiCheckBoxGetSelected ( GUIEditor_Checkbox[1] ) == true then checksave = true else checksave = false end triggerServerEvent("onRequestLogin",getLocalPlayer(),username,password,checksave) end end end addEvent ( "HideTheWindow", true ) addEventHandler ( "HideTheWindow", root, function ( ) guiSetVisible ( wnd, false ) fadeCamera ( true ) showCursor ( false ) end ) سويت له حفظ بيانات اذا فيه خطا الرجاء التصحيح والعفو ذذ Link to comment
#Al-Ha[J]aRii Posted March 18, 2013 Share Posted March 18, 2013 الكود النهائي function centerWindow( center_window ) local screenW, screenH = guiGetScreenSize( ); local windowW, windowH = guiGetSize( center_window, false ); local x, y = ( screenW - windowW ) / 2, ( screenH - windowH ) / 2; guiSetPosition( center_window, x, y, false ); end GUIEditor_Button = {} GUIEditor_Checkbox = {} GUIEditor_Label = {} GUIEditor_Edit = {} GUIEditor_Image = {} wnd = guiCreateWindow(1,1,799,599,"",false) guiSetAlpha(wnd,1) GUIEditor_Image[1] = guiCreateStaticImage(10,25,780,438,"images/tarkep.png",false,wnd) GUIEditor_Button[1] = guiCreateButton(248,564,94,26,"login",false,wnd) GUIEditor_Button[2] = guiCreateButton(420,565,94,24,"register",false,wnd) GUIEditor_Checkbox[1] = guiCreateCheckBox(438,525,25,38,"",false,false,wnd) guiCheckBoxSetSelected(GUIEditor_Checkbox[1],true) GUIEditor_Label[1] = guiCreateLabel(463,532,142,19,"حفظ كلمة المرور",false,wnd) GUIEditor_Edit[1] = guiCreateEdit(306,468,169,23,"",false,wnd) GUIEditor_Edit[2] = guiCreateEdit(306,501,169,23,"",false,wnd) GUIEditor_Label[2] = guiCreateLabel(243,469,110,21,"username",false,wnd) GUIEditor_Label[3] = guiCreateLabel(243,502,110,21,"password",false,wnd) ss = guiCreateStaticImage(1,1,799,599,"images/صوره.png",false) guiSetVisible(wnd,false) addEventHandler("onClientResourceStart", root, function() guiSetVisible(wnd, true) showCursor(true) end) addEventHandler ("onClientGUIClick", root, function ( ) if ( source == GUIEditor.button[1] ) then triggerServerEvent("login", localPlayer, localPlayer, guiGetText ( GUIEditor.edit[1] ), guiGetText ( GUIEditor.edit[2] ) ) elseif ( source == GUIEditor.button[2] ) then triggerServerEvent("register", localPlayer, localPlayer, guiGetText ( GUIEditor.edit[1] ), guiGetText ( GUIEditor.edit[2] ) ) end end ) local username, password = loadLoginFromXML() if not( username == "" or password == "") then guiCheckBoxSetSelected ( GUIEditor_Checkbox[1], true ) guiSetText ( GUIEditor_Button[1], tostring(username)) guiSetText ( GUIEditor_Button[2], tostring(password)) else guiCheckBoxSetSelected ( GUIEditor_Checkbox[1], false ) guiSetText ( GUIEditor_Button[1], tostring(username)) guiSetText ( GUIEditor_Button[2], tostring(password)) end end end function saveLoginToXML(username, password) local xml_save_log_File = xmlLoadFile ("files/xml/userdata.xml") if not xml_save_log_File then xml_save_log_File = xmlCreateFile("files/xml/userdata.xml", "login") end if (username ~= "") then local usernameNode = xmlFindChild (xml_save_log_File, "username", 0) if not usernameNode then usernameNode = xmlCreateChild(xml_save_log_File, "username") end xmlNodeSetValue (usernameNode, tostring(username)) end if (password ~= "") then local passwordNode = xmlFindChild (xml_save_log_File, "password", 0) if not passwordNode then passwordNode = xmlCreateChild(xml_save_log_File, "password") end xmlNodeSetValue (passwordNode, tostring(password)) end xmlSaveFile(xml_save_log_File) xmlUnloadFile (xml_save_log_File) end addEvent("saveLoginToXML", true) addEventHandler("saveLoginToXML", getRootElement(), saveLoginToXML) function resetSaveXML() local xml_save_log_File = xmlLoadFile ("files/xml/userdata.xml") if not xml_save_log_File then xml_save_log_File = xmlCreateFile("files/xml/userdata.xml", "login") end if (username ~= "") then local usernameNode = xmlFindChild (xml_save_log_File, "username", 0) if not usernameNode then usernameNode = xmlCreateChild(xml_save_log_File, "username") end end if (password ~= "") then local passwordNode = xmlFindChild (xml_save_log_File, "password", 0) if not passwordNode then passwordNode = xmlCreateChild(xml_save_log_File, "password") end xmlNodeSetValue (passwordNode, "") end xmlSaveFile(xml_save_log_File) xmlUnloadFile (xml_save_log_File) end addEvent("resetSaveXML", true) addEventHandler("resetSaveXML", getRootElement(), resetSaveXML) if(button == "left" and state == "up") then if (source == shLogin) then username = guiGetText(GUIEditor_Edit[1]) password = guiGetText(GUIEditor_Edit[2]) if guiCheckBoxGetSelected ( GUIEditor_Checkbox[1] ) == true then checksave = true else checksave = false end triggerServerEvent("onRequestLogin",getLocalPlayer(),username,password,checksave) end end end addEvent ( "HideTheWindow", true ) addEventHandler ( "HideTheWindow", root, function ( ) guiSetVisible ( wnd, false ) fadeCamera ( true ) showCursor ( false ) end ) سويت له حفظ بيانات اذا فيه خطا الرجاء التصحيح والعفو ذذ جرب ذذ function centerWindow( center_window ) local screenW, screenH = guiGetScreenSize( ); local windowW, windowH = guiGetSize( center_window, false ); local x, y = ( screenW - windowW ) / 2, ( screenH - windowH ) / 2; guiSetPosition( center_window, x, y, false ); end GUIEditor_Button = {} GUIEditor_Checkbox = {} GUIEditor_Label = {} GUIEditor_Edit = {} GUIEditor_Image = {} wnd = guiCreateWindow(1,1,799,599,"",false) guiSetAlpha(wnd,1) GUIEditor_Image[1] = guiCreateStaticImage(10,25,780,438,"images/tarkep.png",false,wnd) GUIEditor_Button[1] = guiCreateButton(248,564,94,26,"login",false,wnd) GUIEditor_Button[2] = guiCreateButton(420,565,94,24,"register",false,wnd) GUIEditor_Checkbox[1] = guiCreateCheckBox(438,525,25,38,"",false,false,wnd) guiCheckBoxSetSelected(GUIEditor_Checkbox[1],true) GUIEditor_Label[1] = guiCreateLabel(463,532,142,19,"حفظ كلمة المرور",false,wnd) GUIEditor_Edit[1] = guiCreateEdit(306,468,169,23,"",false,wnd) GUIEditor_Edit[2] = guiCreateEdit(306,501,169,23,"",false,wnd) GUIEditor_Label[2] = guiCreateLabel(243,469,110,21,"username",false,wnd) GUIEditor_Label[3] = guiCreateLabel(243,502,110,21,"password",false,wnd) ss = guiCreateStaticImage(1,1,799,599,"images/صوره.png",false) guiSetVisible(wnd,false) addEventHandler("onClientResourceStart", root, function() guiSetVisible(wnd, true) showCursor(true) end) addEventHandler ("onClientGUIClick", root, function ( ) if ( source == GUIEditor.button[1] ) then triggerServerEvent("login", localPlayer, localPlayer, guiGetText ( GUIEditor.edit[1] ), guiGetText ( GUIEditor.edit[2] ) ) elseif ( source == GUIEditor.button[2] ) then triggerServerEvent("register", localPlayer, localPlayer, guiGetText ( GUIEditor.edit[1] ), guiGetText ( GUIEditor.edit[2] ) ) end end ) local username, password = loadLoginFromXML() if not( username == "" or password == "") then guiCheckBoxSetSelected ( GUIEditor_Checkbox[1], true ) guiSetText ( GUIEditor_Button[1], tostring(username)) guiSetText ( GUIEditor_Button[2], tostring(password)) else guiCheckBoxSetSelected ( GUIEditor_Checkbox[1], false ) guiSetText ( GUIEditor_Button[1], tostring(username)) guiSetText ( GUIEditor_Button[2], tostring(password)) end function saveLoginToXML(username, password) local xml_save_log_File = xmlLoadFile ("files/xml/userdata.xml") if not xml_save_log_File then xml_save_log_File = xmlCreateFile("files/xml/userdata.xml", "login") end if (username ~= "") then local usernameNode = xmlFindChild (xml_save_log_File, "username", 0) if not usernameNode then usernameNode = xmlCreateChild(xml_save_log_File, "username") end xmlNodeSetValue (usernameNode, tostring(username)) end if (password ~= "") then local passwordNode = xmlFindChild (xml_save_log_File, "password", 0) if not passwordNode then passwordNode = xmlCreateChild(xml_save_log_File, "password") end xmlNodeSetValue (passwordNode, tostring(password)) end xmlSaveFile(xml_save_log_File) xmlUnloadFile (xml_save_log_File) end addEvent("saveLoginToXML", true) addEventHandler("saveLoginToXML", getRootElement(), saveLoginToXML) function resetSaveXML() local xml_save_log_File = xmlLoadFile ("files/xml/userdata.xml") if not xml_save_log_File then xml_save_log_File = xmlCreateFile("files/xml/userdata.xml", "login") end Link to comment
CRoW,,# Posted March 18, 2013 Author Share Posted March 18, 2013 بسم الله جاري التجربة ذذ Link to comment
CRoW,,# Posted March 18, 2013 Author Share Posted March 18, 2013 ما اشتغل function centerWindow( center_window ) local screenW, screenH = guiGetScreenSize( ); local windowW, windowH = guiGetSize( center_window, false ); local x, y = ( screenW - windowW ) / 2, ( screenH - windowH ) / 2; guiSetPosition( center_window, x, y, false ); end GUIEditor_Button = {} GUIEditor_Checkbox = {} GUIEditor_Label = {} GUIEditor_Edit = {} GUIEditor_Image = {} wnd = guiCreateWindow(1,1,799,599,"",false) guiSetAlpha(wnd,1) GUIEditor_Image[1] = guiCreateStaticImage(10,25,780,438,"1.png",false,wnd) GUIEditor_Button[1] = guiCreateButton(248,564,94,26,"login",false,wnd) GUIEditor_Button[2] = guiCreateButton(420,565,94,24,"register",false,wnd) GUIEditor_Checkbox[1] = guiCreateCheckBox(438,525,25,38,"",false,false,wnd) guiCheckBoxSetSelected(GUIEditor_Checkbox[1],true) GUIEditor_Label[1] = guiCreateLabel(463,532,142,19,"حفظ كلمة المرور",false,wnd) GUIEditor_Edit[1] = guiCreateEdit(306,468,169,23,"",false,wnd) GUIEditor_Edit[2] = guiCreateEdit(306,501,169,23,"",false,wnd) GUIEditor_Label[2] = guiCreateLabel(243,469,110,21,"username",false,wnd) GUIEditor_Label[3] = guiCreateLabel(243,502,110,21,"password",false,wnd) ss = guiCreateStaticImage(1,1,799,599,"images/صوره.png",false) guiSetVisible(wnd,false) addEventHandler("onClientResourceStart", root, function() guiSetVisible(wnd, true) showCursor(true) end) addEventHandler ("onClientGUIClick", root, function ( ) if ( source == GUIEditor.button[1] ) then triggerServerEvent("login", localPlayer, localPlayer, guiGetText ( GUIEditor.edit[1] ), guiGetText ( GUIEditor.edit[2] ) ) elseif ( source == GUIEditor.button[2] ) then triggerServerEvent("register", localPlayer, localPlayer, guiGetText ( GUIEditor.edit[1] ), guiGetText ( GUIEditor.edit[2] ) ) end end ) local username, password = loadLoginFromXML() if not( username == "" or password == "") then guiCheckBoxSetSelected ( GUIEditor_Checkbox[1], true ) guiSetText ( GUIEditor_Button[1], tostring(username)) guiSetText ( GUIEditor_Button[2], tostring(password)) else guiCheckBoxSetSelected ( GUIEditor_Checkbox[1], false ) guiSetText ( GUIEditor_Button[1], tostring(username)) guiSetText ( GUIEditor_Button[2], tostring(password)) end function saveLoginToXML(username, password) local xml_save_log_File = xmlLoadFile ("files/xml/userdata.xml") if not xml_save_log_File then xml_save_log_File = xmlCreateFile("files/xml/userdata.xml", "login") end if (username ~= "") then local usernameNode = xmlFindChild (xml_save_log_File, "username", 0) if not usernameNode then usernameNode = xmlCreateChild(xml_save_log_File, "username") end xmlNodeSetValue (usernameNode, tostring(username)) end if (password ~= "") then local passwordNode = xmlFindChild (xml_save_log_File, "password", 0) if not passwordNode then passwordNode = xmlCreateChild(xml_save_log_File, "password") end xmlNodeSetValue (passwordNode, tostring(password)) end xmlSaveFile(xml_save_log_File) xmlUnloadFile (xml_save_log_File) end addEvent("saveLoginToXML", true) addEventHandler("saveLoginToXML", getRootElement(), saveLoginToXML) function resetSaveXML() local xml_save_log_File = xmlLoadFile ("files/xml/userdata.xml") if not xml_save_log_File then xml_save_log_File = xmlCreateFile("files/xml/userdata.xml", "login") end Link to comment
#Al-Ha[J]aRii Posted March 18, 2013 Share Posted March 18, 2013 تفضل ~~ Server Side ! addEvent ( "login", true ) addEventHandler ( "login", 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 With User : #00FF00[ " .. user .. " ]!", player, 255, 255, 0 , true ) setElementModel ( player, 287 ) triggerClientEvent ( player, "Hide", player ) else outputChatBox ( "Login Error!", player, 255, 255, 0 ) end else outputChatBox ( "Wrong Username or Password!", player, 255, 255, 0 ) end end ) addEvent ( "register", true ) addEventHandler ( "register", 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 ) setElementModel ( player, 287 ) triggerClientEvent ( player, "Hide", player ) 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 - Please Remember Your User/Password!", player, 255, 255, 0 ) outputChatBox ( "Register Details : [ Username ] : #00FF00" .. user .. " #FFFF1A[ Password ] : #00FF00" .. pass .. "", player, 255, 255, 0 , true ) setElementModel ( player, 287 ) triggerClientEvent ( player, "Hide", player ) else outputChatBox ( "Register/Login error!", player, 255, 255, 0 ) end end end ) Client Side ! function centerWindow( center_window ) local screenW, screenH = guiGetScreenSize( ); local windowW, windowH = guiGetSize( center_window, false ); local x, y = ( screenW - windowW ) / 2, ( screenH - windowH ) / 2; guiSetPosition( center_window, x, y, false ); end GUIEditor_Button = {} GUIEditor_Checkbox = {} GUIEditor_Label = {} GUIEditor_Edit = {} GUIEditor_Image = {} wnd = guiCreateWindow(1,1,799,599,"",false) guiSetAlpha(wnd,1) GUIEditor_Image[1] = guiCreateStaticImage(10,25,780,438,"1.png",false,wnd) GUIEditor_Button[1] = guiCreateButton(248,564,94,26,"login",false,wnd) GUIEditor_Button[2] = guiCreateButton(420,565,94,24,"register",false,wnd) GUIEditor_Checkbox[1] = guiCreateCheckBox(438,525,25,38,"",false,false,wnd) guiCheckBoxSetSelected(GUIEditor_Checkbox[1],true) GUIEditor_Label[1] = guiCreateLabel(463,532,142,19,"حفظ كلمة المرور",false,wnd) GUIEditor_Edit[1] = guiCreateEdit(306,468,169,23,"",false,wnd) GUIEditor_Edit[2] = guiCreateEdit(306,501,169,23,"",false,wnd) GUIEditor_Label[2] = guiCreateLabel(243,469,110,21,"username",false,wnd) GUIEditor_Label[3] = guiCreateLabel(243,502,110,21,"password",false,wnd) ss = guiCreateStaticImage(1,1,799,599,"images/صوره.png",false) guiSetVisible(wnd,false) addEventHandler("onClientResourceStart", root, function() guiSetVisible(wnd, true) showCursor(true) 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