Advertisement
Guest User

Untitled

a guest
Jun 3rd, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 9.02 KB | None | 0 0
  1. showPlayerHudComponent("all",false)
  2.  
  3. infoTable = {}
  4. Login_Edit = {}
  5. marwinButtons = {}
  6. sx,sy = guiGetScreenSize()
  7. font = {}
  8. scale = 1
  9.  
  10. if sx < 1152 then
  11.     scale = sx/1152
  12. end
  13.  
  14. font[-1] = guiCreateFont("font2.ttf",8*scale)
  15. font[0] = guiCreateFont("font.ttf",14*scale)
  16. font[1] = guiCreateFont("font.ttf",18*scale)
  17. font[2] = guiCreateFont("font.ttf",20*scale)
  18. font[3] = guiCreateFont("font.ttf",24*scale)
  19. font[5] = guiCreateFont("font3.ttf",25*scale)
  20. font[6] = guiCreateFont("font3.ttf",18*scale)
  21. font[7] = guiCreateFont("font3.ttf",20*scale)
  22.  
  23. function createMarwinButton(x,y,widht,height,text,bool,parent,info)
  24.     button = guiCreateStaticImage(x,y,widht,height,"images/button_standard.png",bool,parent or nil)
  25.     table.insert(marwinButtons,button)
  26.     guiBringToFront(button)
  27.     label = guiCreateLabel(0,0,1,1,text,bool,button)
  28.     guiBringToFront(label)
  29.     setElementData(label,"parent",button)
  30.     setElementData(button,"info",info)
  31.     guiSetFont(label,font[1])
  32.     guiLabelSetVerticalAlign(label,"center")
  33.     guiLabelSetHorizontalAlign(label,"center")
  34.     addEventHandler("onClientMouseEnter",label,markButton,false)
  35.     addEventHandler("onClientMouseLeave",label,unmarkButton,false)
  36.     return label
  37. end
  38.  
  39. function markButton()
  40.     parent = getElementData(source,"parent")
  41.     guiStaticImageLoadImage(parent,"images/button_mouse.png")
  42.     setElementData(localPlayer,"clickedButton",parent)
  43.     playSound("sounds/button.mp3")
  44. end
  45.  
  46. function unmarkButton(b,s)
  47.     parent = getElementData(source,"parent")
  48.     guiStaticImageLoadImage(parent,"images/button_standard.png")
  49.     setElementData(localPlayer,"clickedButton",false)
  50. end
  51.  
  52. function build_loginWin()
  53.     guiSetInputMode("no_binds_when_editing")
  54.     showCursor(true)
  55.     oldFile = xmlLoadFile("preferencesL.xml")
  56.     confFile = xmlLoadFile("@preferencesL.xml")
  57.     if not confFile and oldFile then
  58.         confFile = xmlCreateFile("@preferencesL.xml","user")
  59.         local usr = xmlNodeGetAttribute(oldFile,"username")
  60.         local pass = xmlNodeGetAttribute(oldFile,"pass")
  61.         xmlNodeSetAttribute(confFile,"username",usr)
  62.         xmlNodeSetAttribute(confFile,"pass",pass)
  63.         xmlSaveFile(confFile)
  64.     end
  65.     if oldFile then
  66.         xmlUnloadFile(oldFile)
  67.     end
  68.     confFile = xmlLoadFile("@preferencesL.xml")
  69.     if confFile then
  70.         infoTable.account = xmlNodeGetAttribute(confFile,"username")
  71.         infoTable.pass = xmlNodeGetAttribute(confFile,"pass")
  72.     else
  73.         confFile = xmlCreateFile("@preferencesL.xml","user")
  74.         xmlNodeSetAttribute(confFile,"username","")
  75.         xmlNodeSetAttribute(confFile,"pass","")
  76.         infoTable.account = getPlayerName(localPlayer)
  77.         infoTable.pass = ""
  78.     end
  79.     xmlSaveFile(confFile)
  80.     staticimage = guiCreateStaticImage(0.00,0.00,1.00,1.00,"images/w1.png",true)
  81.    
  82.     background_front = guiCreateStaticImage(0.2,0.25,0.6,0.5,"images/background_1.png",true)
  83.    
  84.     servrInfo = guiCreateLabel(0.025,0.1,0.325,0.3,"",true,background_front)
  85.     guiSetFont(servrInfo,font[1])
  86.     guiLabelSetHorizontalAlign(servrInfo,"center")
  87.     guiLabelSetColor(servrInfo,77,253,0)
  88.    
  89.     loginButton = createMarwinButton(0.10,0.83,0.17,0.10,"Logar",true,background_front,"login")
  90.    
  91.     Login_Edit[1] = guiCreateEdit(0.10,0.48,0.17,0.05,infoTable.account,true,background_front)
  92.    
  93.     Login_Edit[2] = guiCreateEdit(0.10,0.60,0.17,0.05,infoTable.pass,true,background_front)    
  94.     guiEditSetMasked(Login_Edit[2],true)
  95.    
  96.     registerButton = createMarwinButton(0.45,0.825,0.175,0.1,"Registre",true,background_front,"register")  
  97.    
  98.     Login_Edit[3] = guiCreateEdit(0.45,0.48,0.175,0.055,"",true,background_front)
  99.    
  100.     Login_Edit[4] = guiCreateEdit(0.45,0.600,0.175,0.055,"",true,background_front)
  101.     guiEditSetMasked(Login_Edit[4],true)
  102.    
  103.     Login_Edit[5] = guiCreateEdit(0.45,0.75,0.175,0.055,"",true,background_front)
  104.     guiEditSetMasked(Login_Edit[5],true)
  105.    
  106.     bebe = guiCreateLabel(0.45,0.41,0.17,0.07,"NOME:",true,background_front)
  107.     guiSetFont(bebe,"default-small")
  108.     guiLabelSetVerticalAlign(bebe,"center")
  109.     guiLabelSetHorizontalAlign(bebe,"center")
  110.  
  111.     kkk = guiCreateLabel(0.10,0.41,0.17,0.07,"NOME:",true,background_front)
  112.     guiSetFont(kkk,"default-small")
  113.     guiLabelSetVerticalAlign(kkk,"center")
  114.     guiLabelSetHorizontalAlign(kkk,"center")
  115.  
  116.     mlq = guiCreateLabel(0.45,0.68,0.17,0.07,"REPITA A SENHA:",true,background_front)
  117.     guiSetFont(mlq,"default-small")
  118.     guiLabelSetVerticalAlign(mlq,"center")
  119.     guiLabelSetHorizontalAlign(mlq,"center")
  120.  
  121.     ppk = guiCreateLabel(0.10,0.53,0.17,0.07,"SENHA:",true,background_front)
  122.     guiSetFont(ppk,"default-small")
  123.     guiLabelSetVerticalAlign(ppk,"center")
  124.     guiLabelSetHorizontalAlign(ppk,"center")
  125.  
  126.     jj = guiCreateLabel(0.45,0.53,0.17,0.07,"SENHA:",true,background_front)
  127.     guiSetFont(jj,"default-small")
  128.     guiLabelSetVerticalAlign(jj,"center")
  129.     guiLabelSetHorizontalAlign(jj,"center")
  130. end
  131.  
  132. function clickPanelButton(button,state)
  133.     if button == "left" and state == "up" then
  134.         local element = getElementData(localPlayer,"clickedButton")
  135.         if element then
  136.             local info = getElementData(element,"info")
  137.             if info and info == "login" then
  138.                 local username = guiGetText(Login_Edit[1])
  139.                 local password = guiGetText(Login_Edit[2])
  140.                 if tostring(username) ~= "" and tostring(password) ~= "" then
  141.                     triggerServerEvent("onClientSendLoginDataToServer",localPlayer,username,password)
  142.                 else
  143.                     outputChatBox("[Login]#FF9900 Missing Password or Username!",255,255,255,true)
  144.                 end
  145.             elseif info and info == "guest" then
  146.                 showLoginWindow(false)
  147.             elseif info and info == "register" then
  148.                 local username = guiGetText(Login_Edit[3])
  149.                 local pass1 = guiGetText(Login_Edit[4])
  150.                 local pass2 = guiGetText(Login_Edit[5])
  151.                 if tostring(username) ~= "" then
  152.                     if tostring(pass1) ~= "" then
  153.                         if pass1 == pass2 then
  154.                             triggerServerEvent("onClientSendRegisterDataToServer",localPlayer,username,pass1)
  155.                         else
  156.                             outputChatBox("[Registrar]#FF9900 Passwords not not match!",255,255,255,true)
  157.                         end
  158.                     else
  159.                         outputChatBox("[Registrar]#FF9900 No password was entered!",255,255,255,true)
  160.                     end
  161.                 else
  162.                     outputChatBox("[Registrar]#FF9900 No username was entered!",255,255,255,true)
  163.                 end
  164.             end
  165.         end
  166.     end
  167. end
  168. addEventHandler("onClientClick",getRootElement(),clickPanelButton)
  169.  
  170. function onClientGetNews(text1,text2,text3,text4,bool1,bool2,bool3,bool4)
  171.     local text1 = string.gsub(text1,"<br>","\n")
  172.     local text2 = string.gsub(text2,"<br>","\n")
  173.     local text3 = string.gsub(text3,"<br>","\n")
  174.     local text4 = string.gsub(text4,"<br>","\n")
  175.     guiSetText(news1,text1)
  176.     guiSetText(news2,text2)
  177.     guiSetText(news3,text3)
  178.     guiSetText(news4,text4)
  179.     guiSetVisible(news_box1_new,true)
  180.     guiSetVisible(news_box2_new,true)
  181.     guiSetVisible(news_box3_new,true)
  182.     guiSetVisible(news_box4_new,true)
  183. end
  184. addEvent("onClientGetNews",true)
  185. addEventHandler("onClientGetNews",getRootElement(),onClientGetNews)
  186.  
  187. addEventHandler("onClientResourceStart",resourceRoot,function()
  188.     build_loginWin()
  189.     guiSetVisible(background_front,false)
  190.     showLoginWindow(true)
  191.     guiSetInputMode("no_binds_when_editing")
  192.     fadeCamera(true)
  193.     setCameraMatrix(-600.26165771484,2465.2221679688,84.374351501465,-509.05456542969,2477.0661621094,74.689407348633)
  194.     triggerServerEvent("requestServerNews",localPlayer)
  195. end)
  196.  
  197. function hideLoginWindow(accountName,pass)
  198.     showLoginWindow(false)
  199.     toggleSavePassword(accountName,pass)
  200. end
  201. addEvent("onPlayerDoneLogin",true)
  202. addEventHandler("onPlayerDoneLogin",getRootElement(),hideLoginWindow)
  203.  
  204. function toggleSavePassword(name,pass)
  205.     confFile = xmlLoadFile("@preferencesL.xml")
  206.     xmlNodeSetAttribute(confFile,"username",name)
  207.     xmlNodeSetAttribute(confFile,"pass",pass)
  208.     xmlSaveFile(confFile)
  209. end
  210.  
  211. function showLoginWindow(bool)
  212.     setElementData(localPlayer,"clickedButton",false)
  213.     showCursor(bool)
  214.     if bool then
  215.         guiSetPosition(background_front,0.2,-0.75,true)
  216.         addEventHandler("onClientRender",getRootElement(),rollLoginPanel)
  217.         rollProgress = 1
  218.         rollIn = true
  219.         guiSetInputMode("no_binds_when_editing")
  220.     else
  221.         guiSetPosition(background_front,0.2,0.25,true)
  222.         addEventHandler("onClientRender",getRootElement(),rollLoginPanel)
  223.         rollProgress = 0
  224.         rollIn = false
  225.         guiSetInputMode("allow_binds")
  226.     end
  227.     randomDirAnim = math.random() > 0.5 and -1 or 1
  228.     useXAxis = true
  229.     animType = useXAxis and "InBounce" or "InElastic"
  230. end
  231.  
  232. function rollLoginPanel()
  233.     local eval
  234.     if rollIn then
  235.         if rollProgress > 0 then
  236.             rollProgress = (rollProgress*1000 - 15) / 1000
  237.             if rollProgress < 0 then
  238.                 rollProgress = 0
  239.             end
  240.             eval = getEasingValue(rollProgress,animType)
  241.         else
  242.             removeEventHandler("onClientRender",getRootElement(),rollLoginPanel)
  243.             return
  244.         end
  245.     elseif rollProgress < 1 then
  246.         rollProgress = (rollProgress*100 + 3) / 100
  247.         if rollProgress > 1 then
  248.             rollProgress = 1
  249.         end
  250.         eval = getEasingValue(rollProgress,"InQuad")
  251.     else
  252.         removeEventHandler("onClientRender",getRootElement(),rollLoginPanel)
  253.         return
  254.     end
  255.     if useXAxis then
  256.         guiSetPosition(background_front,0.2,0.25 + randomDirAnim*eval,true)
  257.         guiSetPosition(staticimage,0.0,0.0 + randomDirAnim*eval,true)
  258.     else
  259.         guiSetPosition(background_front,0.2 + randomDirAnim*eval,0.25,true)
  260.     end
  261.     guiSetVisible(background_front,true)
  262.     guiSetVisible(staticimage,true)
  263. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement