Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- thePlayer = getLocalPlayer()
- local screenWidth,screenHeight = guiGetScreenSize()
- --showChat(false)
- function startup()
- showChat(true)
- setElementHealth(thePlayer,100)
- setElementPosition (thePlayer, 1584.39856, -2654.52710, 13.54688)
- local localPlayerName = getPlayerName(thePlayer)
- outputChatBox("Welcome " .. localPlayerName .. " on my server!")
- -- destroyElement(GUIEditor.window[1])
- -- showCursor(false)
- removeEventHandler("onClientRender", root, logPanel)
- end
- GUIEditor = {
- tab = {},
- tabpanel = {},
- edit = {},
- button = {},
- window = {},
- label = {}
- }
- function loginGUI()
- local screenW, screenH = guiGetScreenSize()
- GUIEditor.window[1] = guiCreateWindow((screenW - 376) / 2, (screenH - 317) / 2, 376, 317, "Welcome", false)
- guiWindowSetSizable(GUIEditor.window[1], false)
- showCursor(true)
- GUIEditor.tabpanel[1] = guiCreateTabPanel(9, 20, 357, 287, false, GUIEditor.window[1])
- GUIEditor.tab[1] = guiCreateTab("Login", GUIEditor.tabpanel[1])
- GUIEditor.label[1] = guiCreateLabel(94, 81, 103, 20, "Username:", false, GUIEditor.tab[1])
- GUIEditor.label[2] = guiCreateLabel(94, 108, 103, 20, "Password:", false, GUIEditor.tab[1])
- GUIEditor.edit[1] = guiCreateEdit(155, 81, 83, 20, "", false, GUIEditor.tab[1])
- GUIEditor.edit[2] = guiCreateEdit(155, 108, 83, 20, "", false, GUIEditor.tab[1])
- GUIEditor.button[1] = guiCreateButton(133, 144, 64, 25, "Login", false, GUIEditor.tab[1])
- GUIEditor.label[3] = guiCreateLabel(97, 179, 200, 20, "", false, GUIEditor.tab[1])
- GUIEditor.tab[2] = guiCreateTab("Register", GUIEditor.tabpanel[1])
- GUIEditor.label[4] = guiCreateLabel(80, 67, 92, 20, "Username:", false, GUIEditor.tab[2])
- GUIEditor.label[5] = guiCreateLabel(80, 92, 92, 20, "Password:", false, GUIEditor.tab[2])
- GUIEditor.label[6] = guiCreateLabel(80, 117, 92, 20, "Password:", false, GUIEditor.tab[2])
- GUIEditor.edit[3] = guiCreateEdit(143, 68, 78, 20, "", false, GUIEditor.tab[2])
- GUIEditor.edit[4] = guiCreateEdit(143, 92, 78, 20, "", false, GUIEditor.tab[2])
- GUIEditor.edit[5] = guiCreateEdit(143, 118, 78, 20, "", false, GUIEditor.tab[2])
- GUIEditor.button[2] = guiCreateButton(107, 151, 75, 23, "Register", false, GUIEditor.tab[2])
- GUIEditor.label[7] = guiCreateLabel(86, 184, 200, 20, "", false, GUIEditor.tab[2])
- GUIEditor.label[8] = guiCreateLabel(80, 37, 140, 20, "Max lenght 10 character!", false, GUIEditor.tab[2])
- guiLabelSetColor(GUIEditor.label[8], 255, 0, 0)
- fixEdit()
- addEventHandler("onClientGUIClick", GUIEditor.button[1], function()
- uname = guiGetText(GUIEditor.edit[1])
- pw = guiGetText (GUIEditor.edit[2])
- if uname == "" or pw == "" then
- guiSetText(GUIEditor.label[3], "Invalid username or password!")
- guiLabelSetColor(GUIEditor.label[3], 255, 0, 0)
- regClear()
- else
- pw = md5(pw)
- triggerServerEvent("onLogining", resourceRoot, uname,pw)
- end
- addEvent("onLogining", true)
- addEventHandler("onLogining", thePlayer, function(labelText, password)
- if labelText == "Successful login! Wait few seconds!" then
- guiSetText(GUIEditor.label[3], labelText)
- guiLabelSetColor(GUIEditor.label[3], 0, 255, 0)
- setTimer ( function()
- startup()
- end, 5000, 1 )
- else
- regClear()
- guiSetText(GUIEditor.label[3], "Invalid username or password!")
- guiLabelSetColor(GUIEditor.label[3], 255, 0, 0)
- end
- end)
- end,false)
- addEventHandler("onClientGUIClick", GUIEditor.button[2], function()
- uname = guiGetText(GUIEditor.edit[3])
- pw = guiGetText (GUIEditor.edit[4])
- pw2 = guiGetText (GUIEditor.edit[5])
- if uname == "" or uname == " " then
- guiSetText(GUIEditor.label[7], "Incorrect username!")
- guiLabelSetColor(GUIEditor.label[7], 255, 0, 0)
- regClear()
- elseif pw ~= pw2 or pw == "" then
- guiSetText(GUIEditor.label[7], "The password don't match!")
- guiLabelSetColor(GUIEditor.label[7], 255, 0, 0)
- regClear()
- else
- local uname = guiGetText(GUIEditor.edit[3])
- pw = md5(pw2)
- outputChatBox(pw)
- triggerServerEvent("onRegister", resourceRoot,uname, pw)
- addEvent("onRegistered", true)
- addEventHandler("onRegistered", thePlayer, function(labelText)
- guiSetText(GUIEditor.label[7], labelText)
- regClear()
- guiLabelSetColor(GUIEditor.label[7], 0, 255, 0)
- end)
- addEvent("onUsed", true)
- addEventHandler("onUsed", thePlayer, function(labelText)
- guiSetText(GUIEditor.label[7], labelText)
- regClear()
- guiLabelSetColor(GUIEditor.label[7], 255, 0, 0)
- end)
- end
- end, false)
- end
- addEventHandler("onClientPlayerJoin", root, loginGUI)
- addCommandHandler("asd", loginGUI )
- ----------------------------------------------------------------------
- function regClear()
- guiSetText(GUIEditor.edit[1], "")
- guiSetText(GUIEditor.edit[2], "")
- guiSetText(GUIEditor.edit[3], "")
- end
- function fixEdit()
- guiEditSetMaxLength(GUIEditor.edit[1], 10)
- guiEditSetMaxLength(GUIEditor.edit[2], 10)
- guiEditSetMaxLength(GUIEditor.edit[3], 10)
- guiEditSetMaxLength(GUIEditor.edit[4], 10)
- guiEditSetMaxLength(GUIEditor.edit[5], 10)
- guiEditSetMasked ( GUIEditor.edit[2], true )
- guiEditSetMasked ( GUIEditor.edit[4], true )
- guiEditSetMasked ( GUIEditor.edit[5], true )
- end
- -------------------------------------------------------------Login Screen
- function isMouseInPosition(a, b, c, d)
- if not isCursorShowing() then return end
- local x, y = getCursorPosition()
- x, y = x*screenWidth, y*screenHeight
- if x >= a and y >= b and x <= a+c and y <= b+d then
- return true
- end
- return false
- end
- function logregPanel()
- stopRender = false
- function logPanel()
- dxDrawImage(screenWidth / 2 -350, screenHeight / 2 -90, 660, 155, "Login_Sys/data/log_panel.png")
- dxDrawImage(screenWidth / 2 -110, screenHeight / 2 -12.5 , 150, 35, "Login_Sys/data/log_panel_edit.png")
- dxDrawImage(screenWidth / 2 -110, screenHeight / 2 +20 , 150, 35, "Login_Sys/data/log_panel_edit.png")
- if( isMouseInPosition(screenWidth / 2 + 40, screenHeight / 2 + 10, 157, 33 ) ) == true then
- dxDrawImage(screenWidth / 2 + 40, screenHeight / 2 + 10, 157, 33, "Login_Sys/data/loginOver.png")
- else
- dxDrawImage(screenWidth / 2 + 40, screenHeight / 2 + 10, 157, 33, "Login_Sys/data/login.png")
- end
- function LoginBTN (button,state)
- stopRender = 0
- if stopRender == 0 then
- if ( isMouseInPosition (screenWidth / 2 + 40, screenHeight / 2 + 10, 157, 33 ) ) then
- if ( button == "left" and state == "up" ) then
- uname = guiGetText(GUIEditor.edit[1])
- pw = guiGetText (GUIEditor.edit[2])
- if uname == "" or pw == "" then
- removeEventHandler("onClientRender", root, erLog)
- addEventHandler("onClientRender", root, erLog)
- regClear()
- outputChatBox("anyád",0,0,255)
- else
- if stopRender == 0 then
- stopRender = 1
- if stopRender == 1 then
- pw = md5(pw)
- triggerServerEvent("onLogining", resourceRoot, uname,pw)
- stopRender = 0
- end
- stopRender = 0
- end
- stopRender = 1
- end
- stopRender = 1
- end
- addEvent("onLogining", true)
- addEventHandler("onLogining", thePlayer, function(labelText, password)
- if stopRender == 1 then
- stopRender = 0
- if stopRender == 0 then
- if labelText == "Successful login! Wait few seconds!" then
- addEventHandler("onClientRender", root, sfLog)
- removeEventHandler("onClientRender", root, erLog)
- outputChatBox("anyád")
- setTimer ( function()
- startup()
- end, 5000, 1 )
- else
- removeEventHandler("onClientRender", root, erLog)
- addEventHandler("onClientRender", root, erLog)
- regClear()
- outputChatBox("anyád",255,0,0)
- end
- end
- stopRender = 0
- end
- end)
- stopRender = 1
- end
- stopRender = 1
- end
- stopRender = 1
- end
- addEventHandler("onClientClick", root, LoginBTN)
- dxDrawText ( guiGetText(GUIEditor.edit[1]), screenWidth / 2 -95, screenHeight / 2 -2 ,100,19, tocolor ( 255, 255, 255, 255 ), 1, "arial" )
- editTextIn = (guiGetText(GUIEditor.edit[2]))
- editTextLength = string.len(editTextIn)
- editTextOut = ""
- for i = 1 , editTextLength do
- editTextOut = (editTextOut .. "*")
- end
- dxDrawText ( editTextOut, screenWidth / 2 -95, screenHeight / 2 + 32 ,100,19, tocolor ( 255, 255, 255, 255 ), 1, "arial" )
- function erLog()
- dxDrawImage(screenWidth / 2 -286, screenHeight / 2 + 80, 572, 60, "Login_Sys/data/invalid_u_p.png")
- end
- function sfLog()
- dxDrawImage(screenWidth / 2 -335, screenHeight / 2 + 80, 670, 60, "Login_Sys/data/successful_login.png")
- end
- stopRender = true
- end
- --Background
- dxDrawRectangle (screenWidth / 2-330, screenHeight / 2-77.5, 660, 155, tocolor ( 0, 0, 0, 150 ) ) --OP cuc mindenhova betenni!!!!
- dxDrawImage(screenWidth / 2-330, screenHeight / 2-77.5, 660, 155, "Login_Sys/data/login_background.png")
- --Login
- if( isMouseInPosition(screenWidth / 2 + 40, screenHeight / 2 + 15, 157, 33 ) ) == true then
- dxDrawImage(screenWidth / 2 + 40, screenHeight / 2 + 15, 157, 33, "Login_Sys/data/loginOver.png")
- addEventHandler("onClientClick", root, function(button, state)
- if stopRender == false then
- if ( isMouseInPosition (screenWidth / 2 + 40, screenHeight / 2 + 15, 157, 33 ) ) then
- if ( button == "left" and state == "up" ) then
- removeEventHandler("onClientRender", root, logregPanel)
- addEventHandler("onClientRender", root, logPanel)
- end
- end
- stopRender = true
- end
- end)
- else
- dxDrawImage(screenWidth / 2 + 40, screenHeight / 2 + 15, 157, 33, "Login_Sys/data/login.png")
- end
- --Register
- if( isMouseInPosition(screenWidth / 2 - 260, screenHeight / 2 + 5, 226, 50 ) ) == true then
- dxDrawImage(screenWidth / 2 - 260, screenHeight / 2 + 5, 226, 50, "Login_Sys/data/registerOver.png")
- else
- dxDrawImage(screenWidth / 2 - 260, screenHeight / 2 + 5, 226, 50, "Login_Sys/data/register.png")
- end
- end
- addEventHandler("onClientResourceStart", resourceRoot,
- function()
- GUIEditor = {
- edit = {}
- }
- GUIEditor.edit[1] = guiCreateEdit(screenWidth / 2 -95, screenHeight / 2 - 4 , 204,20, "", false)
- GUIEditor.edit[2] = guiCreateEdit(screenWidth / 2 -100, screenHeight / 2 +28 , 204, 20, "", false)
- GUIEditor.edit[3] = guiCreateEdit(screenWidth, screenHeight / 2 +28 , 204, 20, "", false)
- guiEditSetMaxLength ( GUIEditor.edit[1], 10 )
- guiEditSetMaxLength ( GUIEditor.edit[2], 10 )
- guiEditSetMaxLength ( GUIEditor.edit[3], 10 )
- guiSetAlpha(GUIEditor.edit[1], 0)
- guiSetAlpha(GUIEditor.edit[2], 0)
- guiSetAlpha(GUIEditor.edit[3], 0)
- end)
- function logClick (button,state)
- if ( isMouseInPosition ( screenWidth / 2 + 40, screenHeight / 2 + 15, 157, 33 ) ) then
- if ( button == "left" and state == "up" ) then
- showCursor(false)
- removeEventHandler("onClientRender", root, logregPanel)
- end
- end
- end
- --addEventHandler("onClientClick", root, logClick)
- function HandleTheRendering ( )
- showCursor(true)
- addEventHandler("onClientRender", root, logregPanel)
- end
- -- addEventHandler("onClientPlayerJoin", root, HandleTheRendering)
- addEventHandler("onClientResourceStart",resourceRoot, HandleTheRendering)
- --------------------------------------------------
- function getPos()
- x,y,z = getElementPosition(thePlayer)
- outputConsole(x .. ", " .. y .. ", " .. z)
- end
- addCommandHandler("gp", getPos)
- function setPos(cmd, x,y,z)
- setElementPosition(thePlayer, x,y,z)
- end
- addCommandHandler("sp", setPos)
- ------------------------------------------------------------
- addEventHandler("onClientPlayerDamage", thePlayer, function()
- playerHP = getElementHealth(thePlayer)
- if playerHP == 0 then
- setTimer( function()
- triggerServerEvent("onPlayerWasteed", thePlayer)
- end, 2000, 1)
- end
- end, false)
- -----------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement