-- Client Side --
GUIEditor_Button = {}
GUIEditor_Checkbox = {}
GUIEditor_Label = {}
GUIEditor_Edit = {}
GUIEditor_Image = {}
function guiCreateWindow( x2, y2, width2, height2, titleBarText2, relative2 )
mainBackground = guiCreateStaticImage ( x2, y2, width2, height2, "1.png", relative2 )
local mainBackgroundLabel = guiCreateLabel ( 0, 0, 250, 100, titleBarText2, false, mainBackground )
guiSetEnabled ( mainBackgroundLabel, false )
return mainBackground
end
addEventHandler("onClientResourceStart", resourceRoot,
function()
showCursor(true)
wnd = guiCreateWindow(0,0,0.9987,0.9983,"",true)
GUIEditor_Image[1] = guiCreateStaticImage(12,21,800,400,"2.png",false,wnd)
guiSetAlpha(wnd,1)
GUIEditor_Edit[1] = guiCreateEdit(295,463,156,22,"",false,wnd)
GUIEditor_Edit[2] = guiCreateEdit(295,489,156,22,"",false,wnd)
guiEditSetMasked(GUIEditor_Edit[2],true)
GUIEditor_Label[1] = guiCreateLabel(231,463,115,20,"username",false,wnd)
GUIEditor_Label[2] = guiCreateLabel(231,492,115,20,"pass",false,wnd)
GUIEditor_Label[3] = guiCreateLabel(298,49,495,34,"LOGIN BY BOLBN",false,wnd)
GUIEditor_Button[1] = guiCreateButton(418,537,94,31,"register",false,wnd)
GUIEditor_Button[2] = guiCreateButton(266,537,94,31,"login",false,wnd)
GUIEditor_Checkbox[1] = guiCreateCheckBox(466,487,172,22,"Remember Me !",false,false,wnd)
GUIEditor_Button[3] = guiCreateButton(93,549,26,22,"AR",false,wnd)
GUIEditor_Button[4] = guiCreateButton(130,549,26,22,"EN",false,wnd)
end
)
addEventHandler("onClientGUIClick", root,
function ()
local user = guiGetText(GUIEditor_Edit[1])
local pass = guiGetText(GUIEditor_Edit[2])
if ( source == GUIEditor_Button[3] ) then
guiSetText(GUIEditor_Label[1],"اسم المستخدم")
guiSetText(GUIEditor_Label[2],"كلمة المرور")
guiSetText(GUIEditor_Button[2],"تسجيل الدخول")
guiSetText(GUIEditor_Button[1],"تسجيل")
elseif ( source == GUIEditor_Button[4] ) then
guiSetText(GUIEditor_Label[1],"username")
guiSetText(GUIEditor_Label[2],"pass")
guiSetText(GUIEditor_Button[2],"Login")
guiSetText(GUIEditor_Button[1],"Register")
elseif ( source == GUIEditor_Button[2] ) then
triggerServerEvent("onlogin",getLocalPlayer(),user,pass)
elseif ( source == GUIEditor_Button[1] ) then
triggerServerEvent("onre",getLocalPlayer(),user,pass)
end
end
)
addEvent("setcol",true)
addEventHandler("setcol",getRootElement(),
function ()
xmlFileHandler(guiCheckBoxGetSelected(GUIEditor_Checkbox[1]))
guiSetVisible(wnd,false)
showCursor(false)
guiSetInputEnabled(false)
end
)
addEventHandler("onClientGUIChanged",root,
function ( element )
if ( element == GUIEditor_Edit[2] ) then
local ID = guiGetText(GUIEditor_Edit[2])
if not tonumber(ID) then
return
guiSetText(GUIEditor_Edit[2],"")
end
end
end
)
function xmlFileHandler(gReturn)
if gReturn == true then
setElementData(localPlayer, "LoginAuto", true)
else
setElementData(localPlayer, "LoginAuto", false)
end
sName = "Login"
xmlFileName = tostring("login_" .. sName .. ".xml")
local xmlFile = xmlLoadFile(xmlFileName)
if not xmlFile then
xmlFile = xmlCreateFile(xmlFileName, "settings")
xmlNodeSetAttribute(xmlFile, "autologin", tostring(getElementData(localPlayer, "LoginAuto")))
end
xmlNodeSetAttribute(xmlFile, "autologin", tostring(getElementData(localPlayer, "LoginAuto")))
xmlNodeSetAttribute(xmlFile, "username", tostring(guiGetText(GUIEditor_Edit[1])))
xmlNodeSetAttribute(xmlFile, "password", tostring(guiGetText(GUIEditor_Edit[2],password)))
xmlSaveFile(xmlFile)
xmlUnloadFile(xmlFile)
end
function XML()
sName = "Login"
xmlFileName = tostring("login_" .. sName .. ".xml")
local xmlFile = xmlLoadFile(xmlFileName)
if xmlFile then
status = xmlNodeGetAttribute(xmlFile, "autologin")
end
if status == "true" then
local username = tostring(xmlNodeGetAttribute(xmlFile, "username"))
local password = tostring(xmlNodeGetAttribute(xmlFile, "password"))
if username ~= "" and password ~= "" then
guiCheckBoxSetSelected(GUIEditor_Checkbox[1],true)
guiSetText(GUIEditor_Edit[1],username)
guiSetText(GUIEditor_Edit[2],password)
end
end
end
setTimer( XML,200, 1)
-- Server Side --
addEvent("onlogin",true)
addEventHandler("onlogin",getRootElement(),
function (user,pass)
local account = getAccount(user,pass)
if ( account ) then
logIn(source,account,pass)
triggerClientEvent(source,"setcol",source)
else
outputChatBox("* Worng Username Or Password",source,255,0,0)
end
end
)
addEvent("onre",true)
addEventHandler("onre",getRootElement(),
function (user,pass)
local account = getAccount(user,pass)
if ( account ) then
outputChatBox("* This Account is Already Used",source,255,0,0)
else
addAccount(user,pass)
outputChatBox("UserName: " .. user .. " PassWord : " .. pass,source,0,150,255)
end
end
)