Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- showPlayerHudComponent("all",false)
- infoTable = {}
- Login_Edit = {}
- marwinButtons = {}
- sx,sy = guiGetScreenSize()
- font = {}
- scale = 1
- if sx < 1152 then
- scale = sx/1152
- end
- font[-1] = guiCreateFont("font2.ttf",8*scale)
- font[0] = guiCreateFont("font.ttf",14*scale)
- font[1] = guiCreateFont("font.ttf",18*scale)
- font[2] = guiCreateFont("font.ttf",20*scale)
- font[3] = guiCreateFont("font.ttf",24*scale)
- font[5] = guiCreateFont("font3.ttf",25*scale)
- font[6] = guiCreateFont("font3.ttf",18*scale)
- font[7] = guiCreateFont("font3.ttf",20*scale)
- function createMarwinButton(x,y,widht,height,text,bool,parent,info)
- button = guiCreateStaticImage(x,y,widht,height,"images/button_standard.png",bool,parent or nil)
- table.insert(marwinButtons,button)
- guiBringToFront(button)
- label = guiCreateLabel(0,0,1,1,text,bool,button)
- guiBringToFront(label)
- setElementData(label,"parent",button)
- setElementData(button,"info",info)
- guiSetFont(label,font[1])
- guiLabelSetVerticalAlign(label,"center")
- guiLabelSetHorizontalAlign(label,"center")
- addEventHandler("onClientMouseEnter",label,markButton,false)
- addEventHandler("onClientMouseLeave",label,unmarkButton,false)
- return label
- end
- function markButton()
- parent = getElementData(source,"parent")
- guiStaticImageLoadImage(parent,"images/button_mouse.png")
- setElementData(localPlayer,"clickedButton",parent)
- playSound("sounds/button.mp3")
- end
- function unmarkButton(b,s)
- parent = getElementData(source,"parent")
- guiStaticImageLoadImage(parent,"images/button_standard.png")
- setElementData(localPlayer,"clickedButton",false)
- end
- function build_loginWin()
- guiSetInputMode("no_binds_when_editing")
- showCursor(true)
- oldFile = xmlLoadFile("preferencesL.xml")
- confFile = xmlLoadFile("@preferencesL.xml")
- if not confFile and oldFile then
- confFile = xmlCreateFile("@preferencesL.xml","user")
- local usr = xmlNodeGetAttribute(oldFile,"username")
- local pass = xmlNodeGetAttribute(oldFile,"pass")
- xmlNodeSetAttribute(confFile,"username",usr)
- xmlNodeSetAttribute(confFile,"pass",pass)
- xmlSaveFile(confFile)
- end
- if oldFile then
- xmlUnloadFile(oldFile)
- end
- confFile = xmlLoadFile("@preferencesL.xml")
- if confFile then
- infoTable.account = xmlNodeGetAttribute(confFile,"username")
- infoTable.pass = xmlNodeGetAttribute(confFile,"pass")
- else
- confFile = xmlCreateFile("@preferencesL.xml","user")
- xmlNodeSetAttribute(confFile,"username","")
- xmlNodeSetAttribute(confFile,"pass","")
- infoTable.account = getPlayerName(localPlayer)
- infoTable.pass = ""
- end
- xmlSaveFile(confFile)
- staticimage = guiCreateStaticImage(0.00,0.00,1.00,1.00,"images/w1.png",true)
- background_front = guiCreateStaticImage(0.2,0.25,0.6,0.5,"images/background_1.png",true)
- servrInfo = guiCreateLabel(0.025,0.1,0.325,0.3,"",true,background_front)
- guiSetFont(servrInfo,font[1])
- guiLabelSetHorizontalAlign(servrInfo,"center")
- guiLabelSetColor(servrInfo,77,253,0)
- loginButton = createMarwinButton(0.10,0.83,0.17,0.10,"Logar",true,background_front,"login")
- Login_Edit[1] = guiCreateEdit(0.10,0.48,0.17,0.05,infoTable.account,true,background_front)
- Login_Edit[2] = guiCreateEdit(0.10,0.60,0.17,0.05,infoTable.pass,true,background_front)
- guiEditSetMasked(Login_Edit[2],true)
- registerButton = createMarwinButton(0.45,0.825,0.175,0.1,"Registre",true,background_front,"register")
- Login_Edit[3] = guiCreateEdit(0.45,0.48,0.175,0.055,"",true,background_front)
- Login_Edit[4] = guiCreateEdit(0.45,0.600,0.175,0.055,"",true,background_front)
- guiEditSetMasked(Login_Edit[4],true)
- Login_Edit[5] = guiCreateEdit(0.45,0.75,0.175,0.055,"",true,background_front)
- guiEditSetMasked(Login_Edit[5],true)
- bebe = guiCreateLabel(0.45,0.41,0.17,0.07,"NOME:",true,background_front)
- guiSetFont(bebe,"default-small")
- guiLabelSetVerticalAlign(bebe,"center")
- guiLabelSetHorizontalAlign(bebe,"center")
- kkk = guiCreateLabel(0.10,0.41,0.17,0.07,"NOME:",true,background_front)
- guiSetFont(kkk,"default-small")
- guiLabelSetVerticalAlign(kkk,"center")
- guiLabelSetHorizontalAlign(kkk,"center")
- mlq = guiCreateLabel(0.45,0.68,0.17,0.07,"REPITA A SENHA:",true,background_front)
- guiSetFont(mlq,"default-small")
- guiLabelSetVerticalAlign(mlq,"center")
- guiLabelSetHorizontalAlign(mlq,"center")
- ppk = guiCreateLabel(0.10,0.53,0.17,0.07,"SENHA:",true,background_front)
- guiSetFont(ppk,"default-small")
- guiLabelSetVerticalAlign(ppk,"center")
- guiLabelSetHorizontalAlign(ppk,"center")
- jj = guiCreateLabel(0.45,0.53,0.17,0.07,"SENHA:",true,background_front)
- guiSetFont(jj,"default-small")
- guiLabelSetVerticalAlign(jj,"center")
- guiLabelSetHorizontalAlign(jj,"center")
- end
- function clickPanelButton(button,state)
- if button == "left" and state == "up" then
- local element = getElementData(localPlayer,"clickedButton")
- if element then
- local info = getElementData(element,"info")
- if info and info == "login" then
- local username = guiGetText(Login_Edit[1])
- local password = guiGetText(Login_Edit[2])
- if tostring(username) ~= "" and tostring(password) ~= "" then
- triggerServerEvent("onClientSendLoginDataToServer",localPlayer,username,password)
- else
- outputChatBox("[Login]#FF9900 Missing Password or Username!",255,255,255,true)
- end
- elseif info and info == "guest" then
- showLoginWindow(false)
- elseif info and info == "register" then
- local username = guiGetText(Login_Edit[3])
- local pass1 = guiGetText(Login_Edit[4])
- local pass2 = guiGetText(Login_Edit[5])
- if tostring(username) ~= "" then
- if tostring(pass1) ~= "" then
- if pass1 == pass2 then
- triggerServerEvent("onClientSendRegisterDataToServer",localPlayer,username,pass1)
- else
- outputChatBox("[Registrar]#FF9900 Passwords not not match!",255,255,255,true)
- end
- else
- outputChatBox("[Registrar]#FF9900 No password was entered!",255,255,255,true)
- end
- else
- outputChatBox("[Registrar]#FF9900 No username was entered!",255,255,255,true)
- end
- end
- end
- end
- end
- addEventHandler("onClientClick",getRootElement(),clickPanelButton)
- function onClientGetNews(text1,text2,text3,text4,bool1,bool2,bool3,bool4)
- local text1 = string.gsub(text1,"<br>","\n")
- local text2 = string.gsub(text2,"<br>","\n")
- local text3 = string.gsub(text3,"<br>","\n")
- local text4 = string.gsub(text4,"<br>","\n")
- guiSetText(news1,text1)
- guiSetText(news2,text2)
- guiSetText(news3,text3)
- guiSetText(news4,text4)
- guiSetVisible(news_box1_new,true)
- guiSetVisible(news_box2_new,true)
- guiSetVisible(news_box3_new,true)
- guiSetVisible(news_box4_new,true)
- end
- addEvent("onClientGetNews",true)
- addEventHandler("onClientGetNews",getRootElement(),onClientGetNews)
- addEventHandler("onClientResourceStart",resourceRoot,function()
- build_loginWin()
- guiSetVisible(background_front,false)
- showLoginWindow(true)
- guiSetInputMode("no_binds_when_editing")
- fadeCamera(true)
- setCameraMatrix(-600.26165771484,2465.2221679688,84.374351501465,-509.05456542969,2477.0661621094,74.689407348633)
- triggerServerEvent("requestServerNews",localPlayer)
- end)
- function hideLoginWindow(accountName,pass)
- showLoginWindow(false)
- toggleSavePassword(accountName,pass)
- end
- addEvent("onPlayerDoneLogin",true)
- addEventHandler("onPlayerDoneLogin",getRootElement(),hideLoginWindow)
- function toggleSavePassword(name,pass)
- confFile = xmlLoadFile("@preferencesL.xml")
- xmlNodeSetAttribute(confFile,"username",name)
- xmlNodeSetAttribute(confFile,"pass",pass)
- xmlSaveFile(confFile)
- end
- function showLoginWindow(bool)
- setElementData(localPlayer,"clickedButton",false)
- showCursor(bool)
- if bool then
- guiSetPosition(background_front,0.2,-0.75,true)
- addEventHandler("onClientRender",getRootElement(),rollLoginPanel)
- rollProgress = 1
- rollIn = true
- guiSetInputMode("no_binds_when_editing")
- else
- guiSetPosition(background_front,0.2,0.25,true)
- addEventHandler("onClientRender",getRootElement(),rollLoginPanel)
- rollProgress = 0
- rollIn = false
- guiSetInputMode("allow_binds")
- end
- randomDirAnim = math.random() > 0.5 and -1 or 1
- useXAxis = true
- animType = useXAxis and "InBounce" or "InElastic"
- end
- function rollLoginPanel()
- local eval
- if rollIn then
- if rollProgress > 0 then
- rollProgress = (rollProgress*1000 - 15) / 1000
- if rollProgress < 0 then
- rollProgress = 0
- end
- eval = getEasingValue(rollProgress,animType)
- else
- removeEventHandler("onClientRender",getRootElement(),rollLoginPanel)
- return
- end
- elseif rollProgress < 1 then
- rollProgress = (rollProgress*100 + 3) / 100
- if rollProgress > 1 then
- rollProgress = 1
- end
- eval = getEasingValue(rollProgress,"InQuad")
- else
- removeEventHandler("onClientRender",getRootElement(),rollLoginPanel)
- return
- end
- if useXAxis then
- guiSetPosition(background_front,0.2,0.25 + randomDirAnim*eval,true)
- guiSetPosition(staticimage,0.0,0.0 + randomDirAnim*eval,true)
- else
- guiSetPosition(background_front,0.2 + randomDirAnim*eval,0.25,true)
- end
- guiSetVisible(background_front,true)
- guiSetVisible(staticimage,true)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement