Jump to content

لوحة التسجيل ماتحفظ الحساب


Recommended Posts

الكود كلنت

--Globals
local lUsername, tUsername, lPassword, tPassword, chkRememberLogin, bLogin, bRegister, defaultingTimer = nil
local newsTitle, newsText, newsAuthor
local loginTitleText = "WnAsH-Time MTA Roleplay"
--Settings block for c_characters.lua/line 87
endCam = {
        [0] = {591.1669921875, -1827.3310546875, 10.137532234191, 570.09375, -1849.947265625, 4.968677997},
        [1] = {2511.8854980469, -1679.1414794922, 17.823833465576, 2425.4426269531, -1641.1086425781, -15.056860923767},
        [2] = {1553.4459228516, -1365.8366699219, 332.95718383789, 1495.1271972656, -1295.9808349609, 291.49520874023},
        [3] = {-2233.2431640625, -1705.6872558594, 484.6149597168, -2268.3579101563, -1797.0213623047, 463.99838256836},
}
startCam = {
        [0] = {1309.4599609375, -2123.7509765625, 106.98361206055, 1309.53515625, -1818.5615234375, 76.211189270 },
        [1] = {2637.0703125, -1719.1510009766, 90.978698730469, 2636.2329101563, -1718.8670654297, 90.511764526367},
        [2] = {1862.1447753906, -1743.5769042969, 616.80279541016, 1807.4505615234, -1676.6506347656, 566.50939941406},
        [3] = {-1553.6662597656, -1547.2840576172, 76.449432373047, -1653.0958251953, -1555.7768554688, 69.997413635254},
}
originalStartCam = {
        [0] = {1309.4599609375, -2123.7509765625, 106.98361206055, 1309.53515625, -1818.5615234375, 76.211189270 },
        [1] = {2637.0703125, -1719.1510009766, 90.978698730469, 2636.2329101563, -1718.8670654297, 90.511764526367},
        [2] = {1862.1447753906, -1743.5769042969, 616.80279541016, 1807.4505615234, -1676.6506347656, 566.50939941406},
        [3] = {-1553.6662597656, -1547.2840576172, 76.449432373047, -1653.0958251953, -1555.7768554688, 69.997413635254},
}
pedPos = {
        [0] = {581.5712890625, -1835.89453125, 5.6328125, 306.9929},
        [1] = {2502.59765625, -1679.40234375, 13.375785827637, 256.50445556641},
        [2] = {1549.615234375, -1362.326171875, 329.45889282227, 202.84092712402},
        [3] = {-2236.76171875, -1710.3046875, 480.88693237305, 310.16250610352},
}
globalspeed = 25 --Higher value = slower
speed = {}
doneCam = {
	[0] = {false, false, false, false, false, false},
	[1] = {false, false, false, false, false, false},
	[2] = {false, false, false, false, false, false},
	[3] = {false, false, false, false, false, false},
}

function getSelectionScreenID()
		return 2
end

--------------------------------------------
function blackoutOnJoin ()
	--
end
addEventHandler ( "onPlayerJoin", getRootElement(), blackoutOnJoin)

addEventHandler("accounts:login:request", getRootElement(),
	function ()
		setElementDimension ( getLocalPlayer(), 0 )
		setElementInterior( getLocalPlayer(), 0 )
		--setElementPosition( getLocalPlayer(), -262, -1143, 24)
		--setCameraMatrix(-262, -1143, 24, -97, -1167, 2)
		setElementPosition( getLocalPlayer(), 1480, -1688, 13 )
		setCameraMatrix (originalStartCam[selectionScreenID][2], originalStartCam[selectionScreenID][2], originalStartCam[selectionScreenID][3], originalStartCam[selectionScreenID][4], originalStartCam[selectionScreenID][5], originalStartCam[selectionScreenID][6])
		guiSetInputEnabled(true)
		clearChat()
		triggerServerEvent("onJoin", getLocalPlayer())
		--LoginScreen_openLoginScreen()
	end
);

--[[ LoginScreen_openLoginScreen( ) - Open the login screen ]]--
local wLogin, lUsername, tUsername, lPassword, tPassword, chkRememberLogin, bLogin, bRegister--[[, updateTimer]] = nil
function LoginScreen_openLoginScreen(title)
	open_log_reg_pannel()
	--[[
	guiSetInputEnabled(true)
	showCursor(true)
	if not title then
		local width, height = guiGetScreenSize()
		local logoW, logoH = 372, 90
		local logoPosX = width/2 - 186
		local logoPosY = height/2- 140
		iLogo = guiCreateStaticImage(logoPosX, logoPosY, logoW, logoH, "img/OGLogo.png", false)
		lUsername = guiCreateLabel(0.4110, 0.4800, 1, 0.5000, "Username", true)
			guiSetFont(lUsername, "default-bold-small")
		tUsername = guiCreateEdit(0.3680, 0.5000, 0.1300, 0.0350, "Username", true)
			guiSetFont(tUsername, "default-bold-small")
			guiEditSetMaxLength(tUsername, 32)
			addEventHandler("onClientGUIAccepted", tUsername, checkCredentials, false)
		lPassword = guiCreateLabel(0.5460, 0.4800, 1, 0.5000, "Password", true)
			guiSetFont(lPassword, "default-bold-small")
		tPassword = guiCreateEdit(0.5000, 0.5000, 0.1300, 0.0350, "Password", true)
			guiSetFont(tPassword, "default-bold-small")
			guiEditSetMasked(tPassword, true)
			guiEditSetMaxLength(tPassword, 64)
			addEventHandler("onClientGUIAccepted", tPassword, checkCredentials, false)
		chkRememberLogin = guiCreateCheckBox(0.4610, 0.5650, 0.1300, 0.0350, "Remember Me", false, true)
			guiSetFont(chkRememberLogin, "default-bold-small")
		bLogin = guiCreateButton(0.4330, 0.5400, 0.0650, 0.0300, "Login", true)
			guiSetFont(bLogin, "default-bold-small")
			addEventHandler("onClientGUIClick", bLogin, checkCredentials, false)
		bRegister = guiCreateButton(0.5000, 0.5400, 0.0650, 0.0300, "Register", true)
			guiSetFont(bRegister, "default-bold-small")
			addEventHandler("onClientGUIClick", bRegister, LoginScreen_Register, false)
			guiSetText(tUsername, tostring( loadSavedData("username", "") ))
			local tHash = tostring( loadSavedData("hashcode", "") )
			guiSetText(tPassword,  tHash)
			if #tHash > 1 then
				guiCheckBoxSetSelected(chkRememberLogin, true)
			end
		newsTitle = getElementData(getResourceRootElement(), "news:title")
		newsText = getElementData(getResourceRootElement(), "news:text")
		newsAuthor = getElementData(getResourceRootElement(), "news:sub")
		addEventHandler("onClientRender", getRootElement(), showLoginTitle)
		triggerEvent("accounts:settings:loadGraphicSettings", getLocalPlayer())
	else
		loginTitleText = title
		addEventHandler("onClientRender", getRootElement(), showLoginTitle)
	end
	]]
end
addEvent("beginLogin", true)
addEventHandler("beginLogin", getRootElement(), LoginScreen_openLoginScreen)

function showLoginTitle()
	--[[
	local screenX, screenY = guiGetScreenSize()
	local alphaAction = 3
	local alphaStep = 50
	local alphaAction = 3
	local alphaStep = 50
	local sWidth,sHeight = guiGetScreenSize()
	if loginTitleText == "Banned." then
		dxDrawText(loginTitleText,(700/1600)*sWidth, (350/900)*sHeight, (900/1600)*sWidth, (450/900)*sHeight, tocolor(255,0,0,255), (sWidth/1600)*2, "default-bold","center","center",false,false,false)
	else
		dxDrawText(loginTitleText,(700/1600)*sWidth, (350/900)*sHeight, (900/1600)*sWidth, (450/900)*sHeight, tocolor(255,255,255,255), (sWidth/1600)*2, "default-bold","center","center",false,false,false)
	end
	alphaStep = alphaStep + alphaAction
	if (alphaStep > 200) or (alphaStep < 50) then
		alphaAction = alphaAction - alphaAction - alphaAction
	end
	dxDrawRectangle( (10/1600)*sWidth, (17/900)*sHeight, (400/1600)*sWidth, (600/900)*sHeight, tocolor(0, 0, 0, 150))
	dxDrawText( newsTitle, (35/1600)*sWidth, (30/900)*sHeight, (375/1600)*sWidth, (550/900)*sHeight, tocolor ( 255, 255, 255, 255 ), 1.5, "default-bold" )
	dxDrawText( "     " .. newsAuthor, (80/1600)*sWidth, (60/900)*sHeight, sWidth, sHeight, tocolor ( 255, 255, 255, 255 ), 1.2, "default-bold", "left", "top", true, false )
	dxDrawText( newsText, (35/1600)*sWidth, (92/900)*sHeight, (375/1600)*sWidth, sHeight,  tocolor ( 255, 255, 255, 255 ), 1, "default-bold", "left", "top", true, true )
	]]
end

function LoginScreen_Register()
	local username = guiGetText(tUsername)
	local password = guiGetText(tPassword)
	if (string.len(username)<3) then
		LoginScreen_showWarningMessage( "Your username must be a minimum of 3 characters!" )
	elseif (string.find(username, ";", 0)) or (string.find(username, "'", 0)) or (string.find(username, "@", 0)) or (string.find(username, ",", 0)) or (string.find(username, " ", 0)) then
		LoginScreen_showWarningMessage("Your username cannot contain ;,@.' or space!")
	elseif (string.len(password)<6) then
	    LoginScreen_showWarningMessage("Your password is too short. \n You must enter 6 or more characters.", 255, 0, 0)
    elseif (string.len(password)>=30) then
        LoginScreen_showWarningMessage("Your password is too long. \n You must enter less than 30 characters.", 255, 0, 0)
    elseif (string.find(password, ";", 0)) or (string.find(password, "'", 0)) or (string.find(password, "@", 0)) or (string.find(password, ",", 0)) then
        LoginScreen_showWarningMessage("Your password cannot contain ;,@'.", 255, 0, 0)
	else
		showChat(true)
		triggerServerEvent("accounts:register:attempt", getLocalPlayer(), username, password)
	end
end

function LoginScreen_RefreshIMG()
	currentslide =  currentslide + 1
	if currentslide > totalslides then
		currentslide = 1
	end
end

--[[ LoginScreen_closeLoginScreen() - Close the loginscreen ]]
function LoginScreen_closeLoginScreen()
	removeEventHandler( "onClientRender", getRootElement(), showLoginTitle )
end

--[[ checkCredentials() - Used to validate and send the contents of the login screen  ]]--
function checkCredentials()
	local username = guiGetText(tUsername)
	local password = guiGetText(tPassword)
	guiSetText(tPassword, "")
	--appendSavedData("hashcode", "")
	if (string.len(username)<3) then
		outputChatBox("Your username is too short. You must enter 3 or more characters.", 255, 0, 0)
	else
		local saveInfo = guiCheckBoxGetSelected(chkRememberLogin)
		triggerServerEvent("accounts:login:attempt", getLocalPlayer(), username, password, saveInfo)

		if (saveInfo) then
			appendSavedData("username", tostring(username))
		else
			appendSavedData("username", "")
		end
	end
end

local warningBox, warningMessage, warningOk = nil
function LoginScreen_showWarningMessage( message )

	if (isElement(warningBox)) then
		destroyElement(warningBox)
	end

	local x, y = guiGetScreenSize()
	warningBox = guiCreateWindow( x*.5-150, y*.5-65, 300, 120, "Attention!", false )
	guiWindowSetSizable( warningBox, false )
	warningMessage = guiCreateLabel( 40, 30, 220, 60, message, false, warningBox )
	guiLabelSetHorizontalAlign( warningMessage, "center", true )
	guiLabelSetVerticalAlign( warningMessage, "center" )
	warningOk = guiCreateButton( 130, 90, 70, 20, "Ok", false, warningBox )
	addEventHandler( "onClientGUIClick", warningOk, function() destroyElement(warningBox) end )
	guiBringToFront( warningBox )
end
addEventHandler("accounts:error:window", getRootElement(), LoginScreen_showWarningMessage)

function defaultLoginText()
	loginTitleText = "WnAsH-Time MTA Roleplay"
end

addEventHandler("accounts:login:attempt", getRootElement(),
	function (statusCode, additionalData)

		if (statusCode == 0) then
			LoginScreen_closeLoginScreen()

			if (isElement(warningBox)) then
				destroyElement(warningBox)
			end

			-- Succesful login
			--[[
			for _, theValue in ipairs(additionalData) do
				setElementData(getLocalPlayer(), theValue[1], theValue[2], false)
			end
			]]

			local newAccountHash = getElementData(getLocalPlayer(), "account:newAccountHash")
			--appendSavedData("hashcode", newAccountHash or "")

			local characterList = getElementData(getLocalPlayer(), "account:characters")

			if #characterList == 0 then
				newCharacter_init()
			else
				Characters_showSelection()
				fadeCamera ( false, 0, 0,0,0 )
			end
		elseif (statusCode > 0) and (statusCode < 5) then
			LoginScreen_showWarningMessage( additionalData )
		elseif (statusCode == 5) then
			LoginScreen_showWarningMessage( additionalData )
			-- TODO: show make app screen?
		end
	end
)

local Window = {}
local Button = {}
local Label = {}
local Edit = {}

function showPasswordUpdate()
	showCursor(true)
	Window[1] = guiCreateWindow(0.3562,0.3997,0.2891,0.2383,"SECURITY NOTICE:",true)
		guiSetInputEnabled ( true)
		Label[1] = guiCreateLabel(0.0378,0.153,0.9324,0.2404,"We have noticed a potential security flaw with your account.\nTo help prevent any loss of data, we highly reccomend that\nyou enter a new password in the box below!",true,Window[1])
			guiLabelSetColor(Label[1],0,200,0)
			guiLabelSetHorizontalAlign(Label[1],"center",false)
		Edit[1] = guiCreateEdit(0.4243,0.4481,0.5351,0.1475,"",true,Window[1])
			guiEditSetMasked(Edit[1], true)
		Edit[2] = guiCreateEdit(0.4243,0.6175,0.5351,0.1475,"",true,Window[1])
			guiEditSetMasked(Edit[2], true)
		Label[2] = guiCreateLabel(0.1649,0.4754,0.2432,0.1038,"New Password:",true,Window[1])
		Label[3] = guiCreateLabel(0.1216,0.6284,0.2784,0.1038,"Confirm Password:",true,Window[1])
		Button[1] = guiCreateButton(0.427,0.8087,0.527,0.1257,"Change Password",true,Window[1])
			addEventHandler("onClientGUIClick", Button[1], function()
				triggerServerEvent("account:forceChange:validate", getLocalPlayer(), guiGetText(Edit[1]), guiGetText(Edit[2]))
			end)
end
addEvent("account:forceChangePassword:GUI", true)
addEventHandler("account:forceChangePassword:GUI", getRootElement(), showPasswordUpdate)

function closePasswordUpdate()
	destroyElement(Window[1])
	showCursor(false)
	guiSetInputEnabled ( false)
end
addEvent("account:forceChange:GUIClose", true)
addEventHandler("account:forceChange:GUIClose", getRootElement(), closePasswordUpdate)

 

آو من المحتمل هذا الكود

--[[
* ***********************************************************************************************************************
* Copyright (c) 2015 AMG Community - All Rights Reserved
* All rights reserved. This program and the accompanying materials are private property belongs to OwlGaming Community
* Unauthorized copying of this file, via any medium is strictly prohibited
* Proprietary and confidential
* ***********************************************************************************************************************
]]

local panel = { 
		login = {}, 
		register = {}, 
		sounds = { 
			{ 'http://files.owlgaming.net/menu.mp3', 1 },
			{ 'http://files.owlgaming.net/gtav.mp3', 0.3 },
			{ 'http://files.owlgaming.net/gtaiv.mp3', 0.3 },
		} 
	}
local sw, sh = guiGetScreenSize()
local fade = { }
local logoScale = 0.5
local logoSize = { sw*logoScale, sw*455/1920*logoScale }
local uFont

function open_log_reg_pannel()
	if not isElement ( panel.login.main ) then
		-- blur screen.
		triggerEvent( 'hud:blur', resourceRoot, 'off', true )
		setTimer( triggerEvent, 8000, 1, 'hud:blur', resourceRoot, 6, true, 0.1, nil )

		-- sound effects.
		local sound = math.random( 1, 3 )
		local bgMusic = playSound ( panel.sounds[ sound ][ 1 ], true )
		if bgMusic then
			setSoundVolume( bgMusic, panel.sounds[ sound ][ 2 ] )
		end
		setElementData(localPlayer, "bgMusic", bgMusic , false)

		-- prepare.
		showChat(false)
		showCursor(true)
		guiSetInputEnabled(true)
		local Width,Height = 350,350
		local X = (sw/2) - (Width/2)
		local Y = (sh/2) - (Height/2)
		ufont = ufont or guiCreateFont( ':interior_system/intNameFont.ttf', 11 )

		panel.login.main = guiCreateStaticImage( X, Y, 350, 350, "/login-panel/login_window.png", false )
		guiSetEnabled (panel.login.main, false)

		--panel.login.logo = guiCreateStaticImage( (sw-logoSize[1])/2, logoSize[2]/2, logoSize[1], logoSize[2], "/login-panel/OwlLogo7.png", false )
		panel.login.logo = guiCreateStaticImage( (sw-logoSize[1])/2, (sh-logoSize[2])/2 , logoSize[1], logoSize[2], "/login-panel/DeerLogo7.png", false )
		local x, y = guiGetPosition( panel.login.logo, false )
		--guiSetPosition( panel.login.logo, x, -logoSize[2], false )
		

		--!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
		panel.login.login = guiCreateStaticImage( X + 23, Y + 349-120, 301, 44, "/login-panel/login.png", false )
		addEventHandler("onClientGUIClick",panel.login.login,onClickBtnLogin, false )
		addEventHandler( "onClientMouseEnter",panel.login.login,LoginSH)
		addEventHandler("onClientMouseLeave",panel.login.login,SErem)

		panel.login.username = guiCreateEdit(X + 20,Y + 220-120,310,35,"",false)
		panel.login.password = guiCreateEdit(X + 20,Y + 295-120,310,35,"",false)
		guiSetFont( panel.login.username, ufont )
		guiSetFont( panel.login.password, ufont )
		guiEditSetMaxLength ( panel.login.username,25)
		guiEditSetMaxLength ( panel.login.password,25)
		guiEditSetMasked ( panel.login.password, true )
		guiSetProperty( panel.login.password, 'MaskCodepoint', '8226' )

		addEventHandler("onClientGUIChanged", panel.login.username, resetLogButtons)
		addEventHandler("onClientGUIChanged", panel.login.password, resetLogButtons)
		addEventHandler( "onClientGUIAccepted", panel.login.username, startLoggingIn)
		addEventHandler( "onClientGUIAccepted", panel.login.password, startLoggingIn)
		--[[
		lbl_about_legth = guiCreateLabel(142,42,184,18,"",false)
		guiLabelSetColor(lbl_about_legth,253,255,68)
		guiLabelSetVerticalAlign(lbl_about_legth,"center")
		guiLabelSetHorizontalAlign(lbl_about_legth,"center",false)
		]]
		panel.login.remember = guiCreateCheckBox(X + 230,Y + 275-120,100,20,"(Remember me!)",false,false)
		guiSetFont(panel.login.remember,"default-small")

		panel.login.error = guiCreateLabel(X,Y + 325-120,364,31,"Error_login_tab",false)
		guiLabelSetColor(panel.login.error,255,0,0)
		guiLabelSetVerticalAlign(panel.login.error,"center")
		guiLabelSetHorizontalAlign(panel.login.error,"center",false)
		guiSetFont(panel.login.error,"default-bold-small")

		panel.login.authen = guiCreateLabel(X,Y + 325-120,364,31,"Authen_login_tab",false)
		guiLabelSetColor(panel.login.authen,0,255,0)
		guiLabelSetVerticalAlign(panel.login.authen,"center")
		guiLabelSetHorizontalAlign(panel.login.authen,"center",false)
		guiSetFont(panel.login.authen,"default-bold-small")


		--!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
		panel.login.register = guiCreateStaticImage( X + 23, Y + 401-120, 301, 44, "/login-panel/signup.png", false ) -- A gomb
		addEventHandler("onClientGUIClick",panel.login.register,OnBtnRegister, false )
		addEventHandler( "onClientMouseEnter",panel.login.register,SignupSH)
		addEventHandler("onClientMouseLeave",panel.login.register,SErem)

		panel.login.toplabel = guiCreateLabel(X - 70,Y + 388+70-120,500,30,"",false)
		guiLabelSetColor(panel.login.toplabel,255,234,55)
		guiLabelSetVerticalAlign(panel.login.toplabel,"center")
		guiLabelSetHorizontalAlign(panel.login.toplabel,"center",false)
		guiSetFont(panel.login.toplabel,"default-bold-small")
		guiSetVisible(panel.login.toplabel,false)

		panel.login.username2 = guiCreateEdit(X + 20,Y + 215-120,310,35,"",false)
		guiEditSetMaxLength ( panel.login.username2,25)
		guiSetVisible(panel.login.username2,false)
		guiSetFont( panel.login.username2, ufont )
		addEventHandler("onClientGUIChanged", panel.login.username2, resetRegButtons)

		panel.login.password2 = guiCreateEdit(X + 20,Y + 290-120,310,35,"",false)
		guiEditSetMaxLength ( panel.login.password2,25)
		guiEditSetMasked ( panel.login.password2, true )
		guiSetProperty(panel.login.password2, 'MaskCodepoint', '8226')
		guiSetVisible(panel.login.password2,false)
		guiSetFont( panel.login.password2, ufont )
		addEventHandler("onClientGUIChanged", panel.login.password2, resetRegButtons)

		panel.login.repassword = guiCreateEdit(X + 20,Y + 365-120,310,35,"",false)
		guiEditSetMaxLength ( panel.login.repassword,25)
		guiEditSetMasked ( panel.login.repassword, true )
		guiSetProperty(panel.login.repassword, 'MaskCodepoint', '8226')
		guiSetVisible(panel.login.repassword,false)
		guiSetEnabled (panel.login.repassword, true)
		guiSetFont( panel.login.repassword, ufont )
		addEventHandler("onClientGUIChanged", panel.login.repassword, resetRegButtons)

		panel.login.email = guiCreateEdit(X + 20,Y + 435-120,310,35,"",false)
		guiEditSetMaxLength ( panel.login.email,100)
		--guiEditSetMasked ( panel.login.email, true )
		guiSetVisible(panel.login.email,false)
		guiSetFont( panel.login.email, ufont )
		guiSetEnabled (panel.login.email, true)
		addEventHandler("onClientGUIChanged", panel.login.email, resetRegButtons)

		--!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
		panel.login.register2 = guiCreateStaticImage( X + 182, Y + 401+6+70-120, 143, 45, "/login-panel/register.png", false )--guiCreateStaticImage( X + 23, Y + 409, 301, 44, "/login-panel/register2.png", false )
		addEventHandler("onClientGUIClick",panel.login.register2,onClickBtnRegister, false )
		addEventHandler( "onClientMouseEnter",panel.login.register2,Register2SH)
		addEventHandler("onClientMouseLeave",panel.login.register2,SErem)
		guiSetVisible(panel.login.register2,false)

		panel.login.cancel = guiCreateStaticImage( X + 23, Y + 401+6+70-120, 143, 45, "/login-panel/cancel.png", false ) -- A gomb
		addEventHandler("onClientGUIClick",panel.login.cancel,onClickCancel, false )
		addEventHandler( "onClientMouseEnter",panel.login.cancel,CancelSH)
		addEventHandler("onClientMouseLeave",panel.login.cancel,SErem)
		guiSetVisible(panel.login.cancel,false)

		showCursor(true)

		guiSetText(panel.login.error, "")
		guiSetText(panel.login.authen, "")

		local username, password = loadLoginFromXML()
		if username ~= "" then
			guiCheckBoxSetSelected ( panel.login.remember, true )
			guiSetText ( panel.login.username, tostring(username))
			guiSetText ( panel.login.password, tostring(password))
		else
			guiCheckBoxSetSelected ( panel.login.remember, false )
			guiSetText ( panel.login.username, tostring(username))
			guiSetText ( panel.login.password, tostring(password))
		end

		guisSetEnabled( 'login', false )
		guisSetPosition( 'login', (sw+Width)/2 )

		-- fade the login tab in.
		setTimer( fade.login, 8000, 1 , (sw+Width)/2 )

		-- dynamic screen effect.
		addEventHandler( 'onClientRender', root, slideScreen )
		
		-- make sure screen isn't black.
		fadeCamera ( true )
	end
end

function guisSetEnabled( part, state )
	for index, gui in pairs( panel[ part ] ) do
		if index ~= 'main' then
			guiSetEnabled( gui , state )
		end
	end
end

function guisSetPosition( part, x_, y_ )
	for index, gui in pairs( panel[ part ] ) do
		if index ~= 'logo' then
			local x, y = guiGetPosition( gui, false )
			if x_ then
				x = x + x_
			end
			if y_ then
				y = y + y_
			end
			guiSetPosition( gui, x, y, false )
		end
	end
end

function fade.render( )
	fade.cur = fade.cur + fade.dir
	fade.logo_start = fade.logo_start + fade.logo_dir
	if math.abs(fade.cur) <= fade.max then
		guisSetPosition( 'login', fade.dir )
		guiSetPosition( panel.login.logo, fade.logo_x, fade.logo_start, false )
	else
		guisSetEnabled( 'login', true )
		removeEventHandler( 'onClientRender', root, fade.render )
	end
end

function fade.login( max )
	fade.cur = 0
	fade.max = max
	fade.dir = -fade.max/50
	fade.logo_start = (sh-logoSize[2])/2
	fade.logo_end = sh - logoSize[2]*3/2
	fade.logo_dir = -(fade.logo_end-fade.logo_start)/50
	fade.logo_x = (sw-logoSize[1])/2
	addEventHandler( 'onClientRender', root, fade.render )
end

local speed = 0.01
local moved = 0.1

function slideScreen()
	local matrix = { getCameraMatrix ( localPlayer ) }
	matrix[1] = matrix[1] + speed
	moved = moved + speed
	if moved > 50 then
		local scr = shuffleScreen()
		moved = 0
		setCameraMatrix ( scr[1], scr[2], scr[3], scr[4], scr[5], scr[6], 0, exports.global:getPlayerFov())
	else
		setCameraMatrix ( unpack(matrix) )
	end
end

function LoginSH ()
	guiStaticImageLoadImage(panel.login.login, "/login-panel/sh.png" )
end

function SignupSH ()
	guiStaticImageLoadImage(panel.login.register, "/login-panel/signup2.png" )
end

function Register2SH ()
	guiStaticImageLoadImage(panel.login.register, "/login-panel/shr.png" )
end

function CancelSH ()
	guiStaticImageLoadImage(panel.login.cancel, "/login-panel/cancel2.png" )
end

function SErem ()
	guiStaticImageLoadImage(panel.login.login, "/login-panel/login.png" )
	guiStaticImageLoadImage(panel.login.register, "/login-panel/signup.png" )
	guiStaticImageLoadImage(panel.login.register2, "/login-panel/register.png" )
	guiStaticImageLoadImage(panel.login.cancel, "/login-panel/cancel.png" )
end

--[[
function start_cl_resource()
	open_log_reg_pannel()
end
addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),start_cl_resource)
]]

function loadLoginFromXML()
	local xml_save_log_File = xmlLoadFile ("/login-panel/rememberme.xml")
    if not xml_save_log_File then
        xml_save_log_File = xmlCreateFile("/login-panel/rememberme.xml", "login")
    end
    local usernameNode = xmlFindChild (xml_save_log_File, "username", 0)
    local passwordNode = xmlFindChild (xml_save_log_File, "password", 0)
    local username, password = usernameNode and exports.global:decryptString(xmlNodeGetValue(usernameNode), localPlayer) or "", passwordNode and exports.global:decryptString(xmlNodeGetValue(passwordNode), localPlayer) or ""
    xmlUnloadFile ( xml_save_log_File )
    return username, password
end

function saveLoginToXML(username, password)
    local xml_save_log_File = xmlLoadFile ("/login-panel/rememberme.xml")
    if not xml_save_log_File then
        xml_save_log_File = xmlCreateFile("/login-panel/rememberme.xml", "login")
    end
	if (username ~= "") then
		local usernameNode = xmlFindChild (xml_save_log_File, "username", 0)
		local passwordNode = xmlFindChild (xml_save_log_File, "password", 0)
		if not usernameNode then
			usernameNode = xmlCreateChild(xml_save_log_File, "username")
		end
		if not passwordNode then
			passwordNode = xmlCreateChild(xml_save_log_File, "password")
		end
		xmlNodeSetValue (usernameNode, exports.global:encryptString(username, localPlayer))
		xmlNodeSetValue (passwordNode, exports.global:encryptString(password, localPlayer))
	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 ("/login-panel/rememberme.xml")
    if xml_save_log_File then
		fileDelete ("/login-panel/rememberme.xml")
		xmlUnloadFile ( xml_save_log_File )
	end
end
addEvent("resetSaveXML", true)
addEventHandler("resetSaveXML", getRootElement(), resetSaveXML)

function onClickBtnLogin(button,state)
	if(button == "left" and state == "up") then
		if (source == panel.login.login) then
			startLoggingIn()
		end
	end
end

local loginClickTimer = nil
function startLoggingIn()
	if not getElementData(localPlayer, "clickedLogin") then
		setElementData(localPlayer, "clickedLogin", true, false)
		if isTimer(loginClickTimer) then
			killTimer(loginClickTimer)
		end
		loginClickTimer = setTimer(setElementData, 1000, 1, localPlayer, "clickedLogin", nil, false)

		username = guiGetText(panel.login.username)
		password = guiGetText(panel.login.password)
			if guiCheckBoxGetSelected ( panel.login.remember ) == true then
				checksave = true
			else
				checksave = false
			end
		playSoundFrontEnd ( 6 )
		guiSetEnabled(panel.login.login, false)
		guiSetAlpha(panel.login.login, 0.3)
		triggerServerEvent("accounts:login:attempt", getLocalPlayer(), username, password, checksave)
		authen_msg("Login", "Sending request to server..")
	else
		Error_msg("Login", "Slow down..")
	end
end

function hideLoginPanel(keepBG)
	showCursor(true)
	if keepBG then
		for name, gui in pairs( panel.login ) do
			if name ~= 'logo' then
				guiSetVisible( gui, false)
			end
		end
	else
		for name, gui in pairs( panel.login ) do
			if gui and isElement( gui ) then
				destroyElement( gui )
				gui = nil
			end
		end
		triggerEvent( 'hud:blur', resourceRoot, 'off', true )
		removeEventHandler( 'onClientRender', root, slideScreen )
	end
end
addEvent("hideLoginPanel", true)
addEventHandler("hideLoginPanel", getRootElement(), hideLoginPanel)


function OnBtnRegister ()
	switchToRegisterPanel() -- Disabled registration
	playSoundFrontEnd ( 2 )
	--guiSetText(panel.login.error, "Please register on Owlgaming.net/register.php")
end

function onClickCancel()
	switchToLoginPanel()
	playSoundFrontEnd ( 2 )
end

function switchToLoginPanel()
	guiSetText(panel.login.error, "")
	guiSetText(panel.login.authen, "")
	guiSetText(panel.login.toplabel, "")

	guiSetSize(panel.login.main, 350,350, false)
	guiStaticImageLoadImage(panel.login.main, "login-panel/Login_window.png" )
	guiSetVisible(panel.login.register2, false)
	guiSetVisible(panel.login.cancel,false)
	guiSetVisible(panel.login.toplabel,false)
	guiSetVisible(panel.login.repassword,false)
	guiSetEnabled (panel.login.repassword, false)
	guiSetVisible(panel.login.email,false)
	guiSetEnabled (panel.login.email, false)
	guiSetVisible(panel.login.password2,false)
	guiSetVisible(panel.login.username2,false)
	guiSetVisible(panel.login.register, true)
	guiSetVisible(panel.login.login, true)
	guiSetVisible(panel.login.password, true)
	guiSetVisible(panel.login.username, true)
	guiSetVisible(panel.login.remember, true)
	showCursor(true)
end

function switchToRegisterPanel()
	guiSetText(panel.login.error, "")
	guiSetText(panel.login.authen, "")
	guiSetText(panel.login.toplabel, "")

	guiSetSize(panel.login.main, 350,421, false)
	guiStaticImageLoadImage(panel.login.main, "login-panel/register_window.png" )
	guiSetVisible(panel.login.register2, true)
	guiSetVisible(panel.login.cancel,true)
	guiSetVisible(panel.login.toplabel,true)
	guiSetVisible(panel.login.repassword,true)
	guiSetEnabled (panel.login.repassword, true)
	guiSetVisible(panel.login.password2,true)
	guiSetVisible(panel.login.username2,true)
	guiSetVisible(panel.login.email,true)
	guiSetEnabled (panel.login.email, true)
	guiSetVisible(panel.login.register, false)
	guiSetVisible(panel.login.login, false)
	guiSetVisible(panel.login.password, false)
	guiSetVisible(panel.login.username, false)
	guiSetVisible(panel.login.remember, false)
	showCursor(true)
	setElementData(localPlayer, "switched", true, false)
end

function onClickBtnRegister(button,state)
	username = guiGetText(panel.login.username2)
	password = guiGetText(panel.login.password2)
	passwordConfirm = guiGetText(panel.login.repassword)
	email = guiGetText(panel.login.email)
	registerValidation(username, password, passwordConfirm,email)

	--playSoundFrontEnd ( 6 )
	guiSetEnabled(panel.login.register, false)
	guiSetAlpha(panel.login.register, 0.3)
end

function registerValidation(username, password, passwordConfirm, email)
	if not username or username == "" or not password or password == "" or not passwordConfirm or passwordConfirm == "" or not email or email == ""  then
		guiSetText(panel.login.toplabel, "Please fill out all fields.")
		guiLabelSetColor ( panel.login.toplabel, 255, 0, 0 )
		playSoundFrontEnd ( 4 )
	elseif string.len(username) < 3 then
		guiSetText(panel.login.toplabel, "Username must be 3 characters or longer.")
		guiLabelSetColor ( panel.login.toplabel, 255, 0, 0 )
		playSoundFrontEnd ( 4 )
	elseif string.len(username) >= 19 then
		guiSetText(panel.login.toplabel, "Username must be less then 20 characters long.")
		guiLabelSetColor ( panel.login.toplabel, 255, 0, 0 )
		playSoundFrontEnd ( 4 )
	elseif string.find(password, "'") or string.find(password, '"') then
		guiSetText(panel.login.toplabel, "Password must not contain ' or "..'"')
		guiLabelSetColor ( panel.login.toplabel, 255, 0, 0 )
		playSoundFrontEnd ( 4 )
	elseif string.len(password) < 8 then
		guiSetText(panel.login.toplabel, "Password must be 8 characters or longer.")
		guiLabelSetColor ( panel.login.toplabel, 255, 0, 0 )
		playSoundFrontEnd ( 4 )
	elseif password ~= passwordConfirm then
		guiSetText(panel.login.toplabel, "Passwords mismatched!")
		guiLabelSetColor ( panel.login.toplabel, 255, 0, 0 )
		playSoundFrontEnd ( 4 )
	elseif string.match(username,"%W") then
		guiSetText(panel.login.toplabel, "\"!@#$\"%'^&*()\" are not allowed in username.")
		guiLabelSetColor ( panel.login.toplabel, 255, 0, 0 )
		playSoundFrontEnd ( 4 )
	else
		local validEmail, reason = exports.global:isEmail(email)
		if not validEmail then
			guiSetText(panel.login.toplabel, reason)
			guiLabelSetColor ( panel.login.toplabel, 255, 0, 0 )
			playSoundFrontEnd ( 4 )
		else
			triggerServerEvent("accounts:register:attempt",getLocalPlayer(),username,password,passwordConfirm, email)
			authen_msg("Register", "Sending request to server.")
		end
	end
end

function registerComplete(username, pw, email)
	guiSetText(panel.login.username, username)
	guiSetText(panel.login.password, pw)
	playSoundFrontEnd(13)
	displayRegisterConpleteText(username, email)
end
addEvent("accounts:register:complete",true)
addEventHandler("accounts:register:complete",getRootElement(),registerComplete)

function displayRegisterConpleteText(username)
	local GUIEditor = {
	    button = {},
	    window = {},
	    label = {}
	}

	local extend = 100
	local yoffset = 150

	GUIEditor.window[1] = guiCreateWindow(667, 381, 357, 189+extend, "Congratulations! Account has been successfully created!", false)
	exports.global:centerWindow(GUIEditor.window[1])
	--local x, y = guiGetPosition(GUIEditor.window[1], false)
	--guiSetPosition(GUIEditor.window[1], x, y+yoffset, false)
	guiSetAlpha(GUIEditor.window[1], 1)
    guiWindowSetMovable(GUIEditor.window[1], false)
    guiWindowSetSizable(GUIEditor.window[1], false)
    guiSetProperty(GUIEditor.window[1], "AlwaysOnTop", "True")
    local temp = "An email contains instructions to activate your account has been dispatched, please check your email's inbox.\n\nIf for some reasons you don't receive the email, please check your junk box or try to dispatch another activation email at http://owlgaming.net/activate.php?username="..username
    GUIEditor.label[1] = guiCreateLabel(8, 50, 339, 121+extend, "Your IGaming MTA account for '"..username.."' is  ready for action!", false, GUIEditor.window[1])
    guiLabelSetHorizontalAlign(GUIEditor.label[1], "left", true)

    GUIEditor.button[1] = guiCreateButton(10, 153+extend, 337, 26, "Close !", false, GUIEditor.window[1])
    addEventHandler("onClientGUIClick", GUIEditor.button[1], function()
    	if source == GUIEditor.button[1] then
    		if isElement(GUIEditor.window[1]) then
    			destroyElement(GUIEditor.window[1])
    			GUIEditor = nil
    			switchToLoginPanel()

    		end
    	else
    		cancelEvent()
    	end
    end, false )
end

function Error_msg(Tab, Text)
showCursor(true)
	if Tab == "Login" then
		playSoundFrontEnd ( 4)
		guiSetVisible(panel.login.register, true)
		guiSetVisible(panel.login.login, true)
		guiSetVisible(panel.login.password, true)
		guiSetVisible(panel.login.username, true)
		guiSetVisible(panel.login.remember, true)
		guiSetVisible(panel.login.main, true)

		guiSetText(panel.login.authen, "")
		guiSetText(panel.login.error, tostring(Text))
		--setTimer(function() guiSetText(panel.login.error, "") end,3000,1)
	else
		playSoundFrontEnd ( 4)
		guiSetText(panel.login.toplabel, tostring(Text))
		guiLabelSetColor ( panel.login.toplabel, 255, 0, 0 )
	end
end
addEvent("set_warning_text",true)
addEventHandler("set_warning_text",getRootElement(),Error_msg)

function authen_msg(Tab, Text)
showCursor(true)
	if Tab == "Login" then
		if panel.login.authen and isElement(panel.login.authen) and guiGetVisible(panel.login.authen) then
			--playSoundFrontEnd ( 12)
			guiSetVisible(panel.login.register, true)
			guiSetVisible(panel.login.login, true)
			guiSetVisible(panel.login.password, true)
			guiSetVisible(panel.login.username, true)
			guiSetVisible(panel.login.remember, true)
			guiSetVisible(panel.login.main, true)

			guiSetText(panel.login.error, "")
			guiSetText(panel.login.authen, tostring(Text))
			--setTimer(function() guiSetText(panel.login.authen, "") end,3000,1)
		end
	else
		--playSoundFrontEnd ( 12 )
		guiSetText(panel.login.toplabel, tostring(Text))
		guiLabelSetColor ( panel.login.toplabel, 255, 255, 255 )
	end
end
addEvent("set_authen_text",true)
addEventHandler("set_authen_text",getRootElement(),authen_msg)


function hideLoginWindow()
	showCursor(false)
	hideLoginPanel()
end
addEvent("hideLoginWindow", true)
addEventHandler("hideLoginWindow", getRootElement(), hideLoginWindow)

function CursorError ()
showCursor(false)
end
addCommandHandler("showc", CursorError)

function resetRegButtons ()
	guiSetEnabled(panel.login.register2, true)
	guiSetAlpha(panel.login.register2, 1)
end

function resetLogButtons()
	guiSetEnabled(panel.login.login, true)
	guiSetAlpha(panel.login.login, 1)
end


local screenStandByCurrent = 0
local screenStandByComplete = 2
local screenStandByShowing = false
function screenStandBy(action, value) -- Maxime / 2015.3.25
	if action == "add" then
		screenStandByCurrent = screenStandByCurrent + 1
		if screenStandByShowing then
			authen_msg("Login", "Loading prerequisite resources.."..screenStandBy("getPercentage").."%")
		end
		return screenStandByCurrent
	elseif action == "getCurrent" then
		return screenStandByCurrent
	elseif action == "getState" then
		return screenStandByShowing
	elseif action == "setState" then
		screenStandByShowing = value
		if screenStandByShowing then
			authen_msg("Login", "Loading prerequisite resources.."..screenStandBy("getPercentage").."%")
		end
		screenStandByCurrent = 0
		return true
	elseif action == "getPercentage" then
		local percentage = math.floor(screenStandByCurrent/screenStandByComplete*100)
		if screenStandByShowing then
			authen_msg("Login", "Loading prerequisite resources.."..percentage.."%")
		end
		return percentage
	end
end
addEvent("screenStandBy",true)
addEventHandler("screenStandBy",root,screenStandBy)

addEventHandler ( "onClientElementDataChange", localPlayer,
function ( dataName )
	if getElementType ( localPlayer ) == "player" and dataName == "loggedin" then
		showChat(getElementData(localPlayer, "loggedin") == 1)
	end
end )

--

 

Link to comment

مسروقة ؟
ي بوي لا تدرك آلهيآط هذي حياة واقعية بس فيه مشكلة باللوحة

انا مشتري السيرفر من استضافة وجآني كذا

مو عآجبك لا تساعد

  • Confused 1
Link to comment
23 hours ago, i,xAhmed said:

مسروقة ؟
ي بوي لا تدرك آلهيآط هذي حياة واقعية بس فيه مشكلة باللوحة

انا مشتري السيرفر من استضافة وجآني كذا

مو عآجبك لا تساعد

حبيبي هو مايقصد آهانتك .. او الهيآط 
المودات المستعملة في سيرفرك مب انت سارقها صحيح بس الاستضافة الي شاري منها يمكن سرقتها :/
( هذا على حسب ظنه )

بس لمعلوميتك .. كل سيرفرات الحياة الواقعية تعتبر سيرفرات بمودات مسروقة ( اتكلم عن العرب ) والمودات مأخوذة من سيرفر اسمه أول قيمنق
لكن استثني القليل من سيرفرات حياة الواقعية الي ما اخذت او سرقت المودات هذه ..

-----------

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


 

  • Like 1
Link to comment
On ١٠‏/٥‏/٢٠١٨ at 12:12, iMr.WiFi..! said:

حبيبي هو مايقصد آهانتك .. او الهيآط 
المودات المستعملة في سيرفرك مب انت سارقها صحيح بس الاستضافة الي شاري منها يمكن سرقتها :/
( هذا على حسب ظنه )

بس لمعلوميتك .. كل سيرفرات الحياة الواقعية تعتبر سيرفرات بمودات مسروقة ( اتكلم عن العرب ) والمودات مأخوذة من سيرفر اسمه أول قيمنق
لكن استثني القليل من سيرفرات حياة الواقعية الي ما اخذت او سرقت المودات هذه ..

-----------

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


 

من آلممكن , لاكن انا م سرقت ولا اخذت مودات

Link to comment
  • 2 weeks later...

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