Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[----------------------------------------------------
- -- client script main
- -- @author Banex
- -- @update 25/03/2016
- ----------------------------------------------------]]--
- sx,sy = guiGetScreenSize()
- x,y = (sx/1366), (sy/768)
- messages = {}
- editBox = {}
- editBox.__index = editBox
- editBox.instances = {}
- font2 = dxCreateFont("gfx/Roboto-Bold.ttf", 18)
- function onClientResourceStart()
- tick = getTickCount()
- font = dxCreateFont("gfx/sans-pro-regular.ttf", 18)
- sound = playSound("sfx/music.mp3",true)
- g = {}
- g.user = editBox.new()
- g.user:setPosition(x*400,y*386,x*180,y*40)
- g.user.color = {0, 0, 0, 0} -- {0, 0, 0, 0}
- g.user.font = font
- g.user.text = loadLoginFromXML()
- g.user.visible = true
- g.user.onInput = function()
- -- g.user.color = {87, 95, 104, 160}
- g.user.color = {0, 0, 0, 0}
- end
- g.user.onOutput = function()
- g.user.color ={0, 0, 0, 0}
- end
- g.pass = editBox.new()
- g.pass:setPosition(x*400,y*443,x*180,y*40)
- g.pass.color = {0, 0, 0, 0}
- g.pass.font = font
- g.pass.masked = true
- g.pass.visible = true
- g.pass.onInput = function()
- g.pass.color = {0, 0, 0, 0}
- end
- g.pass.onOutput = function()
- g.pass.color = {0, 0, 0, 0}
- end
- g.rUser = editBox.new()
- g.rUser:setPosition(x*400,y*385,x*180,y*40)
- g.rUser.color = {0, 0, 0, 0}
- g.rUser.font = font
- g.rUser.onInput = function()
- g.rUser.color = {0, 0, 0, 0}
- end
- g.rUser.onOutput = function()
- g.rUser.color = {0, 0, 0, 0}
- end
- g.rPass = editBox.new()
- g.rPass:setPosition(x*400,y*443,x*180,y*40)
- g.rPass.color = {0, 0, 0, 0}
- g.rPass.font = font
- g.rPass.masked = true
- g.rPass.onInput = function()
- g.rPass.color = {0, 0, 0, 0}
- end
- g.rPass.onOutput = function()
- g.rPass.color = {0, 0, 0, 0}
- end
- showChat(false)
- showCursor(true)
- addEventHandler("onClientRender", root, paint)
- end
- addEventHandler("onClientResourceStart",resourceRoot,onClientResourceStart)
- function paint()
- local rh,ry = interpolateBetween(0, (y*370/2)+y*105, 0, y*370, y*105, 0, (getTickCount()-tick)/1400, "Linear")
- local posix, posiy, posiz = interpolateBetween(1296.9630126953, -1400.4029541016, 33.24066925048, 649.66790771484, -1400.8580322266, 28.23228263855, (getTickCount()-tick)/90000, "Linear")
- setCameraMatrix(posix, posiy, posiz, getTickCount()/100, 355.14211)
- exports["fx_blur"]:dxDrawBluredRectangle(0,0,sx,sy, tocolor(255, 255, 255, 255))
- dxDrawRectangle(x*597,y*208,x*391,y*352,tocolor(0,0,0,255))
- local atual = 1
- local limite = 5
- local tempo = 5000
- setTimer(function()
- atual = (atual == limite) and 1 or atual + 1
- end, tempo, 0 )
- dxDrawImage(x*597,y*208,x*391,y*352,"gfx/slider/"..tostring(atual)..".png", 0, 0, 0)
- dxDrawImage(0,0,sx,sy,"gfx/fundo.png",0,0,0)
- if getTickCount()-tick > 0 then -- Tempo para aparecer os itens abaixo:
- local bColor = tocolor(255,255,255)
- if isMouseInPosition(x*394,y*510,x*190,y*31) then
- bColor = tocolor(230,230,255)
- end
- -- dxDrawImage(x*580,y*180,x*198,y*198,"gfx/logo.png", 0, 0, 0)
- --dxDrawRectangle(x*552,y*364,x*49,y*41,tocolor(0,0,0,130))
- -- dxDrawRectangle(x*597,y*370,x*2,y*28,tocolor(255,255,255,255))
- --dxDrawImage(x*550,y*363,x*263,y*44,"gfx/barra.png",0, 0, 0, tocolor(0,0,0,130))
- --dxDrawRectangle(x*552,y*426,x*49,y*41,tocolor(0,0,0,130))
- -- dxDrawRectangle(x*597,y*432,x*2,y*28,tocolor(255,255,255,255))
- --dxDrawImage(x*550,y*425,x*263,y*44,"gfx/barra.png",0, 0, 0, tocolor(0,0,0,130))
- if not inRegisterTab then
- -- dxDrawRectangle(x*552,y*440,x*262,y*44,bColor)
- -- dxDrawBorder(x*552,y*440,x*262,y*44,tocolor(0,0,0,240),1.4)
- dxDrawImage(x*392,y*514,x*190,y*31,"gfx/buttom.png", 0, 0, 0, bColor)
- dxDrawText("Entrar",x*165,y*511,x*552+x*262,y*504+y*44,tocolor(255,255,255),y*0.7,font2,"center","center")
- dxDrawText([[Não tem conta? #365678Registra-se#FFFFFF]],x*210,y*345,x*588+x*192,y*592+y*43,tocolor(255,255,255),y*0.6,font,"center","center",false,false,false,true)
- end
- for k,self in pairs(editBox.instances) do
- if self.visible then
- local px,py,pw,ph = self:getPosition()
- local text = self.masked and string.gsub(self.text,".","•") or self.text
- local alignX = dxGetTextWidth(text,self.scale,self.font) <= pw and "left" or "right"
- dxDrawRectangle(px, py, pw, ph, tocolor(unpack(self.color)))
- dxDrawText(text,px+x*5, py,px-x*5+pw, py+ph,tocolor(unpack(self.textColor)),self.scale,self.font,alignX,"center",true)
- if self.input and dxGetTextWidth(text,self.scale,self.font) <= pw then
- local lx = dxGetTextWidth(text,self.scale,self.font)+px+x*8
- local lx = dxGetTextWidth(text,self.scale,self.font)+px+x*8
- dxDrawLine(lx, py+y*10, lx, py+ph-y*10, tocolor(255,255,255,math.abs(math.sin(getTickCount()/300))*200), 2)
- end
- end
- end
- if not inRegisterTab then
- -- Bordas do icon do login
- -- Barra dps do aqui
- -- dxDrawRectangle(x*555,y*510,x*250,y*1,tocolor(255,255,255,255))
- -- dxDrawBorder(x*552,y*364,x*262,y*41,tocolor(0,0,0,240),1)
- -- dxDrawBorder(x*552,y*426,x*262,y*41,tocolor(0,0,0,240),1)
- else
- dxDrawText([[Voltar ao login? #365678Sim#FFFFFF]],x*169,y*345,x*588+x*192,y*592+y*43,tocolor(255,255,255),y*0.6,font,"center","center",false,false,false,true)
- -- Fundo do icon do registro
- -- dxDrawRectangle(x*552,y*364,x*49,y*41,tocolor(40,45,48,160))
- -- dxDrawImage(x*560,y*369,x*33,y*31,"gfx/user.png")
- -- dxDrawRectangle(x*552,y*426,x*49,y*41,tocolor(40,45,48,160))
- -- Bordas do icon do registro
- -- dxDrawImage(x*565,y*431,x*23,y*31,"gfx/pass.png")
- -- dxDrawBorder(x*552,y*364,x*262,y*41,tocolor(0,0,0,240),1)
- -- dxDrawBorder(x*552,y*426,x*262,y*41,tocolor(0,0,0,240),1)
- -- Botões do registro
- dxDrawImage(x*392,y*514,x*190,y*31,"gfx/buttom.png", 0, 0, 0, bColor)
- dxDrawText("Registrar",x*165,y*511,x*552+x*262,y*504+y*44,tocolor(255,255,255),y*0.7,font2,"center","center")
- -- dxDrawRectangle(x*552,y*504,x*262,y*44,bColor)
- -- dxDrawBorder(x*552,y*504,x*262,y*44,tocolor(0,0,0,240),1.4)
- -- dxDrawText("Registrar",x*552,y*504,x*552+x*262,y*504+y*44,tocolor(255,255,255),y*1,font,"center","center")
- -- dxDrawRectangle(x*552,y*504+65,x*262,y*44,bColor)
- -- dxDrawBorder(x*552,y*504+65,x*262,y*44,tocolor(0,0,0,240),1.4)
- -- dxDrawText("Voltar",x*552,y*504+65*2,x*552+x*262,y*504+y*44,tocolor(255,255,255),y*1,font,"center","center")
- end
- end
- if getKeyState("backspace") then
- for k,self in pairs(editBox.instances) do
- if self.visible and self.input then
- if not keyState then
- keyState = getTickCount() + 400
- self.text = string.sub(self.text,1,string.len(self.text)-1)
- elseif keyState and keyState < getTickCount() then
- keyState = getTickCount()+100
- self.text = string.sub(self.text,1,string.len(self.text)-1)
- end
- return
- end
- end
- keyState = nil
- end
- for i, v in pairs(messages) do
- if v.visible then
- -- dxDrawRectangle(sx-dxGetTextWidth(v.text, 1, "default-bold")-10, 35*i, dxGetTextWidth(v.text, 1, "default-bold")+50, 32,v.color)
- -- dxDrawBorder(sx-dxGetTextWidth(v.text, 1, "default-bold")-10, 35*i, dxGetTextWidth(v.text, 1, "default-bold")+20, 32,tocolor(255,255,255,200),1.6)
- -- dxDrawText(v.text,sx-dxGetTextWidth(v.text,1,"default-bold")-5, 9+35*i, dxGetTextWidth(v.text, 1, "default-bold"), 32, v.color, 1, "default-bold", "left", "top", false, false ,false, true)
- dxDrawText(v.text,x*666,y*110,x*588+x*192,y*592+y*43,v.color,y*0.5,font,"left","center",false,false,false,true)
- end
- end
- end
- -- Botoes
- function onClientClick(button,state,cX,cY)
- if not isCursorShowing() then
- return
- end
- if button == "left" and state == "up" then
- for k,self in pairs(editBox.instances) do
- if self.visible then
- if self.input then
- self.input = nil
- self.onOutput()
- end
- local x,y,w,h = self:getPosition()
- if isMouseInPosition(x,y,w,h) then
- self.input = true
- self.onInput()
- end
- end
- end
- if not inRegisterTab then
- -- dxDrawText([[Registre-se #008BFFaqui#FFFFFF.]],x*898,y*450,x*588+x*192,y*592+y*43,tocolor(255,255,255),y*0.6,font,"center","center",false,false,false,true)
- if isMouseInPosition(x*394,y*514,x*190,y*31) then
- triggerServerEvent("onRequestLogin",localPlayer,g.user.text,g.pass.text)
- -- Posição do botão "Registre-se Aqui!"
- elseif isMouseInPosition(x*515,y*475,x*69,y*29) then
- g.user.visible = false
- g.pass.visible = false
- inRegisterTab = true
- g.rUser.visible = true
- g.rPass.visible = true
- end
- else
- -- Botão para registrar
- if isMouseInPosition(x*394,y*514,x*190,y*31) then
- triggerServerEvent("onRequestRegister",localPlayer,g.rUser.text,g.rPass.text)
- end
- -- Botão para voltar
- --dxDrawText([[#008BFFVoltar#FFFFFF]],x*970,y*450,x*588+x*192,y*592+y*43,tocolor(255,255,255),y*0.6,font,"center","center",false,false,false,true)
- if isMouseInPosition(x*515,y*475,x*31,y*17) then
- inRegisterTab = false
- g.user.visible = true
- g.pass.visible = true
- g.rUser.visible = false
- g.rPass.visible = false
- g.rUser.text = ""
- g.rPass.text = ""
- end
- end
- end
- end
- addEventHandler("onClientClick", root, onClientClick)
- function onClientCharacter(character)
- if not isCursorShowing() then
- return
- end
- for k,self in pairs(editBox.instances) do
- if self.visible and self.input then
- if (string.len(self.text)) < self.maxLength then
- self.text = self.text..character
- end
- end
- end
- end
- addEventHandler("onClientCharacter", root, onClientCharacter)
- function editBox.new()
- local self = setmetatable({}, editBox)
- self.text = ""
- self.maxLength = 20
- self.scale = y*0.8
- self.state = "normal"
- self.font = "sans"
- self.color = {255,255,255,220}
- self.textColor = {255,255,255,220}
- table.insert(editBox.instances, self)
- return self
- end
- function editBox:getPosition()
- return self.x, self.y, self.w, self.h
- end
- function editBox:setPosition(x,y,w,h)
- self.x, self.y, self.w, self.h = x,y,w,h
- return true
- end
- function dxDrawBorder(posX, posY,posW,posH,color,scale)
- dxDrawLine(posX, posY, posX+posW, posY, color, scale,false)
- dxDrawLine(posX, posY, posX, posY+posH, color, scale,false)
- dxDrawLine(posX, posY+posH, posX+posW, posY+posH, color, scale,false)
- dxDrawLine(posX+posW, posY, posX+posW, posY+posH, color, scale,false)
- end
- function isMouseInPosition(x,y,width,height)
- local cx, cy = getCursorPosition()
- local cx, cy = (cx*sx), (cy*sy)
- if (cx >= x and cx <= x + width) and (cy >= y and cy <= y + height) then
- return true
- else
- return false
- end
- end
- function onLogin()
- showChat(true)
- showCursor(false)
- stopSound(sound)
- setCameraTarget(localPlayer, localPlayer)
- removeEventHandler("onClientRender", root, paint)
- removeEventHandler("onClientClick",root,onClientClick)
- removeEventHandler("onClientCharacter",root,onClientCharacter)
- end
- addEvent("onLogin", true)
- addEventHandler("onLogin", localPlayer, onLogin)
- function onRegister()
- g.user.visible = true
- g.pass.visible = true
- g.user.text = ""
- g.pass.text = ""
- inRegisterTab = false
- g.rUser.visible = false
- g.rPass.visible = false
- g.rUser.text = ""
- g.rPass.text = ""
- end
- addEvent("onRegister", true)
- addEventHandler("onRegister", localPlayer, onRegister)
- function loadLoginFromXML()
- local XML = xmlLoadFile ("userdata.xml")
- if not XML then
- XML = xmlCreateFile("userdata.xml", "login")
- end
- local usernameNode = xmlFindChild (XML, "username", 0)
- if usernameNode then
- return xmlNodeGetValue(usernameNode)
- else
- return ""
- end
- xmlUnloadFile ( XML )
- end
- function saveLoginToXML(username)
- local XML = xmlLoadFile ("userdata.xml")
- if not XML then
- XML = xmlCreateFile("userdata.xml", "login")
- end
- if (username ~= "") then
- local usernameNode = xmlFindChild (XML, "username", 0)
- if not usernameNode then
- usernameNode = xmlCreateChild(XML, "username")
- end
- xmlNodeSetValue (usernameNode, tostring(username))
- end
- xmlSaveFile(XML)
- xmlUnloadFile (XML)
- end
- addEvent("saveLoginToXML", true)
- addEventHandler("saveLoginToXML", root, saveLoginToXML)
- function login_text(result, text)
- if result == "sucess" then
- addNotification(text,1)
- elseif result == "error" then
- addNotification(text,2)
- end
- end
- addEvent("login_text",true)
- addEventHandler("login_text",root,login_text)
- function addNotification(text, type)
- text = string.gsub(text,"#%x%x%x%x%x%x","")
- local i = 0
- if text == "" or text == nil or not type then
- return
- else
- for i = 0, #messages do
- if messages[i] then
- i = i+1
- else
- messages[i] = {}
- messages[i].text = text
- messages[i].visible = true
- if type == 1 then
- messages[i].color = tocolor(0,255,0,200)
- elseif type == 2 then
- messages[i].color = tocolor(255,0,0,200)
- end
- setTimer(removeNotify,5000,1,i)
- end
- end
- end
- end
- function removeNotify(i)
- messages[i].visible = false
- messages[i] = nil
- end
- function dxDrawBorder(posX, posY,posW,posH,color,scale)
- dxDrawLine(posX, posY, posX+posW, posY, color, scale,false)
- dxDrawLine(posX, posY, posX, posY+posH, color, scale,false)
- dxDrawLine(posX, posY+posH, posX+posW, posY+posH, color, scale,false)
- dxDrawLine(posX+posW, posY, posX+posW, posY+posH, color, scale,false)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement