Jump to content

طلب مساعدة في كود


w7sH

Recommended Posts

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

عندي مشكلة بسيطة في لوحة التسجيل وهي مشكلة في تسجيل الدخول التلقائي + حفظ الحساب

يعني اذا حطيت صح على الشيك بوكس وطلعت ودخلت مايحفظ الحساب معك مع ان الاكواد صحيحة بس مدري وش المشكلة؟

والمشكلة الآخرى مسوي شيك بوكس ثاني لـ التسجيل التلقائي ولا ضبطت معي

الأكواد
كلنكت

GUIEditor = {
    checkbox = {},
    staticimage = {},
    edit = {},
    button = {},
    window = {},
    label = {}
}
addEventHandler("onClientResourceStart", resourceRoot,
    function()
	triggerServerEvent ( "On", localPlayer )
		local screenW, screenH = guiGetScreenSize()
        GUIEditor.window[1] = guiCreateWindow((screenW - 590) / 2, (screenH - 428) / 2, 590, 428, "Login System", false)
        guiWindowSetSizable(GUIEditor.window[1], false)

        GUIEditor.staticimage[1] = guiCreateStaticImage(9, 23, 571, 232, "Login.png", false, GUIEditor.window[1])
        GUIEditor.edit[1] = guiCreateEdit(178, 283, 233, 23, "", false, GUIEditor.window[1])
        GUIEditor.label[1] = guiCreateLabel(178, 259, 233, 24, "UserName:", false, GUIEditor.window[1])
        guiSetFont(GUIEditor.label[1], "default-bold-small")
        guiLabelSetHorizontalAlign(GUIEditor.label[1], "center", false)
        guiLabelSetVerticalAlign(GUIEditor.label[1], "center")
        GUIEditor.label[2] = guiCreateLabel(178, 306, 233, 24, "PassWord:", false, GUIEditor.window[1])
        guiSetFont(GUIEditor.label[2], "default-bold-small")
        guiLabelSetHorizontalAlign(GUIEditor.label[2], "center", false)
        guiLabelSetVerticalAlign(GUIEditor.label[2], "center")
        GUIEditor.edit[2] = guiCreateEdit(178, 330, 233, 23, "", false, GUIEditor.window[1])
        GUIEditor.checkbox[1] = guiCreateCheckBox(178, 354, 107, 16, "Show Password", false, false, GUIEditor.window[1])
        guiSetFont(GUIEditor.checkbox[1], "default-bold-small")
        GUIEditor.checkbox[2] = guiCreateCheckBox(326, 354, 85, 16, "Rember Me", false, false, GUIEditor.window[1])
        guiSetFont(GUIEditor.checkbox[2], "default-bold-small")
        GUIEditor.checkbox[3] = guiCreateCheckBox(178, 312, 82, 12, "Auto Login", true, false, GUIEditor.window[1])
        guiSetFont(GUIEditor.checkbox[3], "default-bold-small")  
        GUIEditor.button[1] = guiCreateButton(178, 380, 113, 27, "Register", false, GUIEditor.window[1])
        guiSetFont(GUIEditor.button[1], "default-bold-small")
        guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFFFFFFF")
        GUIEditor.button[2] = guiCreateButton(298, 380, 113, 27, "Login", false, GUIEditor.window[1])
        guiSetFont(GUIEditor.button[2], "default-bold-small")
        guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FFFFFFFF")    
		guiEditSetMasked(GUIEditor.edit[2], true)
		showChat ( false )
		setTimer ( function ( )
			fadeCamera ( true )
			local x, y, z, x1, y1, z1 = unpack ( TabelCamera [ math.random ( #TabelCamera ) ] )
			setCameraMatrix ( x, y, z, x1, y1, z1 )
			guiSetVisible ( GUIEditor.window[1], true )
		end, 2500, 1 )
showCursor ( true )

    end
)


addEventHandler ( "onClientGUIClick", root,
	function ( )
		if guiCheckBoxGetSelected ( GUIEditor.checkbox[1] ) then
			guiEditSetMasked ( GUIEditor.edit[2], false )
		else
			guiEditSetMasked ( GUIEditor.edit[2], true )
		end
		if source == GUIEditor.button[1] then
			if not guiGetText ( GUIEditor.edit[1] ) ~= "" and guiGetText ( GUIEditor.edit[2] ) ~= "" then
				triggerServerEvent ( "onRegister", localPlayer, guiGetText ( GUIEditor.edit[1] ), guiGetText ( GUIEditor.edit[2] ) )
			else
				exports ["guimessages"] : outputClient ( "# - [ #ffffff * Worng Username Or Password#ff0000 ] - #" , 255, 0, 0, true )
			end
		elseif source == GUIEditor.button[2] then
			if not guiGetText ( GUIEditor.edit[1] ) ~= "" and guiGetText ( GUIEditor.edit[2] ) ~= "" then
				if guiCheckBoxGetSelected ( GUIEditor.checkbox[2] ) then
					triggerServerEvent ( "onLogin", localPlayer, guiGetText ( GUIEditor.edit[1] ), guiGetText ( GUIEditor.edit[2] ), "True" )
				else
					triggerServerEvent ( "onLogin", localPlayer, guiGetText ( GUIEditor.edit[1] ), guiGetText ( GUIEditor.edit[2] ), "False" )
				end
			else
				exports ["guimessages"] : outputClient ( "# - [ #ffffff * Worng Username Or Password#ff0000 ] - #" , 255, 0, 0, true )
			end
		end
	end
)

addEvent ( "Yes", true )
addEventHandler ( "Yes", root,
	function ( )
		showCursor ( false )
		guiSetVisible ( GUIEditor.window[1], false )
		showChat ( true )
		setCameraTarget ( localPlayer )
	end
)

addEvent ( "setInfo", true )
addEventHandler ( "setInfo", root,
	function ( UserName, PassWord )
		guiSetText ( GUIEditor.edit[1], UserName )
		guiSetText ( GUIEditor.edit[2], PassWord )
	end
)

 

سيرفر

 

local Table = {
	{ x, y, z },
	{ x, y, z },
	{ x, y, z },
	{ x, y, z },
	{ x, y, z },
	{ x, y, z },
}

addEventHandler( "onResourceStart", resourceRoot,
	function ( )
		executeSQLQuery ( "CREATE TABLE IF NOT EXISTS SaveAccount ( PlayerSerial, UserName, PassWord )" )
		executeSQLQuery ( "CREATE TABLE IF NOT EXISTS AutoLogin ( PlayerSerial, AutoLogin )" )
	end
)
addEvent( "onRegister", true )
addEventHandler ( "onRegister", root,
	function ( User, PassWord )
		local Account = addAccount ( tostring ( User ), tostring ( PassWord ) )
		if Account then
			exports ["guimessages"] : outputServer ( source, "UserName: ".. User , 0, 255, 0, true )
			exports ["guimessages"] : outputServer ( source, "PassWord: ".. PassWord , 0, 255, 0, true )
		else
			exports ["guimessages"] : outputServer ( source, "# - [ #ffffff * This account already exists#ff0000 ] - #" , 255, 0, 0, true )
		end
	end
)

addEvent( "onLogin", true )
addEventHandler ( "onLogin", root,
	function ( User, PassWord, Text )
		local Account = getAccount ( tostring ( User ), tostring ( PassWord ) )
		local SQL = executeSQLQuery ( "SELECT * FROM SaveAccount WHERE PlayerSerial = ? ", getPlayerSerial ( client ) )
		local SQL1 = executeSQLQuery ( "SELECT * FROM AutoLogin WHERE PlayerSerial = ? ", getPlayerSerial ( client ) )
		if Account then
			if Text == "True" then
				if #SQL == 0 then
					executeSQLQuery ( "INSERT INTO AutoLogin ( PlayerSerial, AutoLogin ) VALUES ( ?, ? ) ", getPlayerSerial ( client ), "1" )
					executeSQLQuery ( "INSERT INTO SaveAccount ( PlayerSerial, UserName, PassWord ) VALUES ( ?, ?, ? ) ", getPlayerSerial ( client ), tostring ( User ), tostring ( PassWord ) )
				else
					executeSQLQuery ( "UPDATE SaveAccount SET PlayerSerial = ?, UserName = ?, PassWord = ? ", getPlayerSerial ( client ), tostring ( User ), tostring ( PassWord ) )
					executeSQLQuery ( "UPDATE AutoLogin SET PlayerSerial = ?, AutoLogin = ?", getPlayerSerial ( client ), "1" )
				end
			else
				if #SQL1 == 0 then
					executeSQLQuery ( "INSERT INTO AutoLogin ( PlayerSerial, AutoLogin ) VALUES ( ?, ? ) ", getPlayerSerial ( client ), "1" )
				else
					executeSQLQuery ( "UPDATE AutoLogin SET PlayerSerial = ?, AutoLogin = ?", getPlayerSerial ( client ), "1" )
				end
			end
			logIn ( client, Account, PassWord )
			triggerClientEvent ( source, "Yes", source )
			exports ["guimessages"] : outputServer ( source, "# - [ #ffffff Welcome To Server#ff0000 ] - #" , 255, 0, 0, true )
			local x, y, z = unpack ( Table [ math.random ( #Table ) ] )
			setElementPosition ( source, x, y, z )
		else
			exports ["guimessages"] : outputServer ( source, "# - [ #ffffff * Worng Username Or Password#ff0000 ] - #" , 255, 0, 0, true )
		end
	end
)

addEvent( "On", true )
addEventHandler ( "On", root,
	function ( )
		local SQLListe = executeSQLQuery ( "SELECT * FROM SaveAccount WHERE PlayerSerial = ? ", getPlayerSerial ( client ) )
		local SQLListe1 = executeSQLQuery ( "SELECT * FROM AutoLogin WHERE PlayerSerial = ? ", getPlayerSerial ( client ) )
		if #SQLListe ~= 0 then
			if #SQLListe1 ~= 0 then
				triggerClientEvent ( client, "Yes", client )
				local Account = getAccount ( tostring ( SQLListe [ 1 ] [ "UserName"] ), tostring ( SQLListe [ 1 ] [ "PassWord"] ) )
				logIn ( client, Account, tostring ( SQLListe [ 1 ] [ "PassWord"] ) )
				exports ["guimessages"] : outputServer ( client, "# - [ #ffffff Welcome To Server#ff0000 ] - #" , 255, 0, 0, true )
				local x, y, z = unpack ( Table [ math.random ( #Table ) ] )
				setElementPosition ( source, x, y, z )
			else
				triggerClientEvent ( client, "setInfo", client, SQLListe [ 1 ] [ "UserName"], SQLListe [ 1 ] [ "PassWord"] )
			end
		end
	end
)

addCommandHandler ( "DELETE",
	function ( PlayerSource )
		local SQL = executeSQLQuery ( "SELECT * FROM AutoLogin WHERE PlayerSerial = ? ", getPlayerSerial ( PlayerSource ) )
		if #SQL == 0 then
			exports ["guimessages"] : outputServer ( PlayerSource, "# - [ #ffffff * لقد تم الحذف من قبل#ff0000 ] - #" , 255, 0, 0, true )
		else
			executeSQLQuery ( "DELETE FROM `AutoLogin` WHERE playerSerial = ?", getPlayerSerial ( PlayerSource ) )
			exports ["guimessages"] : outputServer ( PlayerSource, "# - [ #ffffff * تم الحذف بنجاح#ff0000 ] - #" , 255, 0, 0, true )
		end
	end
)

 

Link to comment
1 hour ago, Master_MTA said:

يالطيب وين الايفينت حق onPlayerJoin???

عشان يسجله اصلا

ظننتك خبير بس خاب ظني أهئ

onResourceStart

تطبق عندما اللاعب يدخل و عند تشغيل المود

Link to comment
1 minute ago, #BrosS said:

احذف حسابك من المنتدى يرحم أمك

كل ردودك خارجة عن عالم البرمجة ولا حتى نظرة قليلة

 

خارجة عن عالم البرمجة؟
onResourceStart بتبدا لما السيرفر يشتغل عليه المود
وهاده سيرفر سايد بس
onClientResourceStart
الايفنت يتفعل لما يشتغل الرسيورس عند (الاعب) عشان كدة لما يدخل الاعب الريسورس يشتغل عنده

حسن ردك بعدين

Link to comment
1 hour ago, #BrosS said:

ظننتك خبير بس خاب ظني أهئ

onResourceStart

تطبق عندما اللاعب يدخل و عند تشغيل المود

حبيب قلبي شف وش حاط بعدها وبعدين كلمني اللي حاطه بهذا الايفينت

انه ينشا تيبل مب يسجل اللاعب لول

+

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

لو كنت قلت

onClientResourceStart

كنت مشيتها لك بتراقر للسيرفر باللوكال بلاير لكن كلامك خارج عن المنطق

1 hour ago, #BrosS said:

جربت لوحتك وكودك كل شي شغال

:|

مستحيل كل شي شغال؟

وين الايفينت حق التسجيل حقه

وين

login????????????

---------------

اعذرني صاحب الموضوع ما شفت السطر 11 بكلنت

المهم الخطا الشائع انك كنت مسوي تيبل من قبل بنفس الاسم ثم عدلت على الكولمن حقه

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

مره وحده

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