papam77 Posted July 16, 2013 Share Posted July 16, 2013 img = { url = {"data/img/map.png","data/img/tune.png","data/img/music.png","data/img/stats.png","data/img/plus.png","data/img/options.png"}, pos = {{sX/2-(((sY/10)+(sY/40))*3),sY},{sX/2-(((sY/10)+(sY/40))*2),sY},{sX/2-((sY/10)+(sY/40)),sY},{sX/2+(sY/40),sY},{sX/2+(((sY/10)+((sY/40)*2))),sY},{sX/2+(((sY/10))*2+(sY/40)*3),sY}}, size = {sY/10,sY/10}, alpha = {150,255,255,255,255,255,255} }, Hello i have problem with this, i need to change userpanel positions, but when i am changing sX it is moving to sides and sY too, how can move it up ? Link to comment
codeluaeveryday Posted July 16, 2013 Share Posted July 16, 2013 You have two options, find where sX and sY variables are created and simply subtract the some random numbers off sY. Alternatively just redefine them: sY = sY - 100 -- Replace this number to suit your position img = { url = {"data/img/map.png","data/img/tune.png","data/img/music.png","data/img/stats.png","data/img/plus.png","data/img/options.png"}, pos = {{sX/2-(((sY/10)+(sY/40))*3),sY},{sX/2-(((sY/10)+(sY/40))*2),sY},{sX/2-((sY/10)+(sY/40)),sY},{sX/2+(sY/40),sY},{sX/2+(((sY/10)+((sY/40)*2))),sY},{sX/2+(((sY/10))*2+(sY/40)*3),sY}}, size = {sY/10,sY/10}, alpha = {150,255,255,255,255,255,255} } Link to comment
papam77 Posted July 16, 2013 Author Share Posted July 16, 2013 Nothing happend. ------------------------------ -- -- Dashboard by Xiti -- ------------------------------ --48,110,255 #306EFF sX,sY = guiGetScreenSize() scale = (sX/1920)*(sY/1200) menu = { anim = false, animate = false, top = { size = {sX,sY/13}, pos = {0,0-sY/13-sY/13/40}, fontS = 6*scale, }, bottom = { size = {sX,sY/10}, pos = {0,sY+sY/10+sY/40}, sY = sY - 50, img = { url = {"data/img/map.png","data/img/tune.png","data/img/music.png","data/img/stats.png","data/img/plus.png","data/img/options.png"}, pos = {{sX/2-(((sY/10)+(sY/40))*3),sY},{sX/2-(((sY/10)+(sY/40))*2),sY},{sX/2-((sY/10)+(sY/40)),sY},{sX/2+(sY/40),sY},{sX/2+(((sY/10)+((sY/40)*2))),sY},{sX/2+(((sY/10))*2+(sY/40)*3),sY}}, size = {sY/10,sY/10}, alpha = {150,255,255,255,255,255,255} }, label = {"Map Shop","Tune","Music","Stats","Donator","Options"} }, alpha = 0, tick = getTickCount(), hover = 0, block = true, } digitalFont = dxCreateFont("data/font/digital.ttf",60*scale) function drawMenu() day,month,year,hours,minutes,seconds,day_name = getServerTime () -- Background -- Bottom bar -- dxDrawRectangle(menu.bottom.pos[1],menu.bottom.pos[2],menu.bottom.size[1],menu.bottom.size[2],tocolor(0,0,0,150),true) -- dxDrawRectangle(menu.bottom.pos[1],menu.bottom.pos[2]-menu.top.size[2]/40,menu.top.size[1],menu.top.size[2]/40,tocolor(48,110,255,120),true) for i=1,#menu.bottom.img.url do dxDrawImage(menu.bottom.img.pos[i][1],menu.bottom.img.pos[i][2],menu.bottom.img.size[1],menu.bottom.img.size[2],menu.bottom.img.url[i],0,0,0,tocolor(255,255,255,menu.bottom.img.alpha[i]),true) end end addEventHandler("onClientRender",getRootElement(),drawMenu) function animateMenu() if not menu.anim then menu.tick = getTickCount() menu.anim = true menu.animate = true showCursor(true) addEventHandler("onClientPreRender",getRootElement(),animMenuOn) addEventHandler("onClientPreRender",getRootElement(),animTopMenuOn) addEventHandler("onClientPreRender",getRootElement(),fadeBackground) else menu.anim = false menu.tick = getTickCount() menu.animate = true window.current = 0 showCursor(false) closeAllPickers() resetAllElementStates() addEventHandler("onClientPreRender",getRootElement(),animMenuOff) addEventHandler("onClientPreRender",getRootElement(),animTopMenuOff) addEventHandler("onClientPreRender",getRootElement(),fadeBackgroundOff) end end function openUserpanel() if not menu.animate then if not menu.block then animateMenu() else outputChatBox("#306EFF[OPEN] #ffffffYou need to be logged to open the userpanel.",255,255,255,true) end end end bindKey("u","down",openUserpanel) function allowBind(bOl) menu.block = not bOl if bOl then startLoginNotification() end end function animMenuOn() local tick = getTickCount() - menu.tick local progress = tick/500 if progress >= 1 then progress = 1 removeEventHandler("onClientPreRender",getRootElement(),animMenuOn) menu.animate = false end menu.bottom.pos[2] = interpolateBetween(sY,0,0,sY-sY/10,0,0,progress,"Linear") for i=1,#menu.bottom.img.url do menu.bottom.img.pos[i][2] = menu.bottom.pos[2] end end function animTopMenuOn() local tick = getTickCount() - menu.tick local progress = tick/500 if progress >= 1 then progress = 1 removeEventHandler("onClientPreRender",getRootElement(),animTopMenuOn) end menu.top.pos[2] = interpolateBetween(0-sY/13,0,0,0,0,0,progress,"Linear") end function fadeBackground() local tick = getTickCount() - menu.tick local progress = tick/500 if progress >= 1 then progress = 1 removeEventHandler("onClientPreRender",getRootElement(),fadeBackground) end menu.alpha = interpolateBetween(0,0,0,90,0,0,progress,"Linear") end function animMenuOff() local tick = getTickCount() - menu.tick local progress = tick/500 if progress >= 1 then progress = 1 removeEventHandler("onClientPreRender",getRootElement(),animMenuOff) menu.animate = false end menu.bottom.pos[2] = interpolateBetween(sY-sY/10,0,0,sY+menu.top.size[2]/40,0,0,progress,"Linear") for i=1,#menu.bottom.img.url do menu.bottom.img.pos[i][2] = menu.bottom.pos[2] end end function animTopMenuOff() local tick = getTickCount() - menu.tick local progress = tick/500 if progress >= 1 then progress = 1 removeEventHandler("onClientPreRender",getRootElement(),animTopMenuOff) end menu.top.pos[2] = interpolateBetween(0,0,0,0-sY/13-menu.top.size[2]/40,0,0,progress,"Linear") end function fadeBackgroundOff() local tick = getTickCount() - menu.tick local progress = tick/500 if progress >= 1 then progress = 1 removeEventHandler("onClientPreRender",getRootElement(),fadeBackgroundOff) end menu.alpha = interpolateBetween(90,0,0,0,0,0,progress,"Linear") end function hoverButtons() if isCursorShowing() and menu.anim then local x,y = getCursorPosition() local x,y = x*sX,y*sY if x>=menu.bottom.img.pos[1][1] and x<=menu.bottom.img.pos[1][1]+menu.bottom.img.size[1] and y>= menu.bottom.img.pos[1][2] then fadeButton(1) elseif x>=menu.bottom.img.pos[2][1] and x<=menu.bottom.img.pos[2][1]+menu.bottom.img.size[1] and y>= menu.bottom.img.pos[1][2] then fadeButton(2) elseif x>=menu.bottom.img.pos[3][1] and x<=menu.bottom.img.pos[3][1]+menu.bottom.img.size[1] and y>= menu.bottom.img.pos[1][2] then fadeButton(3) elseif x>=menu.bottom.img.pos[4][1] and x<=menu.bottom.img.pos[4][1]+menu.bottom.img.size[1] and y>= menu.bottom.img.pos[1][2] then fadeButton(4) elseif x>=menu.bottom.img.pos[5][1] and x<=menu.bottom.img.pos[5][1]+menu.bottom.img.size[1] and y>= menu.bottom.img.pos[1][2] then fadeButton(5) elseif x>=menu.bottom.img.pos[6][1] and x<=menu.bottom.img.pos[6][1]+menu.bottom.img.size[1] and y>= menu.bottom.img.pos[1][2] then fadeButton(6) elseif x>=sX-dxGetTextWidth(day..", "..month.." "..year,menu.top.fontS,"default-bold")-100*scale and x<=sX and y<= menu.top.pos[2]+menu.top.size[2] then fadeButton(7) else fadeButton(0) end end end addEventHandler("onClientRender",getRootElement(),hoverButtons) fade = { current = 0, tick = getTickCount(), } function fadeButton(id) menu.hover = id if fade.current ~= id then fade.current = id fade.tick = getTickCount() end if fade.current ~= 0 then if fade.current ~= 7 then local tick = getTickCount() - fade.tick local progress = tick/1000 if progress >= 1 then progress = 1 end menu.bottom.img.alpha[fade.current] = interpolateBetween(menu.bottom.img.alpha[fade.current],0,0,255,0,0,progress,"Linear") drawLabel(fade.current) for i=1,#menu.bottom.img.alpha do if i ~= id then menu.bottom.img.alpha[i] = interpolateBetween(menu.bottom.img.alpha[i],0,0,150,0,0,progress,"Linear") end end else local tick = getTickCount() - fade.tick local progress = tick/1000 if progress >= 1 then progress = 1 end menu.top.fontS = interpolateBetween(menu.top.fontS,0,0,7*scale,0,0,progress,"Linear") drawLabel(fade.current) for i=1,#menu.bottom.img.alpha do menu.bottom.img.alpha[i] = interpolateBetween(menu.bottom.img.alpha[i],0,0,150,0,0,progress,"Linear") end end else local tick = getTickCount() - fade.tick local progress = tick/1000 if progress >= 1 then progress = 1 end for i=1,#menu.bottom.img.alpha do menu.bottom.img.alpha[i] = interpolateBetween(menu.bottom.img.alpha[i],0,0,150,0,0,progress,"Linear") end menu.top.fontS = interpolateBetween(menu.top.fontS,0,0,6*scale,0,0,progress,"Linear") end end function drawLabel(id) if id ~= 0 and menu.anim then if id ~= 7 then local text = menu.bottom.label[id] local rectX, rectY = dxGetTextWidth(text,3*scale,"default-bold")+(60*scale), dxGetFontHeight(3*scale,"default-bold")+(20*scale) dxDrawRectangle(menu.bottom.img.pos[id][1]+(menu.bottom.img.size[1]/2)-(rectX/2),menu.bottom.img.pos[1][2]-((menu.bottom.img.pos[1][2]/10)/2)-(rectY/2),rectX,rectY,tocolor(0,0,0,200),true) dxDrawText(text,menu.bottom.img.pos[id][1],menu.bottom.img.pos[1][2],menu.bottom.img.pos[id][1]+menu.bottom.img.size[1],menu.bottom.img.pos[1][2]-(menu.bottom.img.pos[1][2]/10),tocolor(48,110,255,255),3*scale,"default-bold","center","center",false,false,true) else local text = "news" local rectX, rectY = dxGetTextWidth(text,3*scale,"default-bold")+(60*scale), dxGetFontHeight(3*scale,"default-bold")+(20*scale) dxDrawRectangle(sX-(dxGetTextWidth(day..", "..month.." "..year,menu.top.fontS,"default-bold")/2)-(100*scale)/2-(rectX)/2,menu.top.pos[2]+menu.top.size[2]+((menu.bottom.img.pos[1][2]/10)/2)-(rectY/2),rectX,rectY,tocolor(0,0,0,200),true) dxDrawText(text,sX-dxGetTextWidth(day..", "..month.." "..year,menu.top.fontS,"default-bold")-100*scale,menu.top.pos[2]+menu.top.size[2],sX,menu.top.pos[2]+menu.top.size[2]+(menu.bottom.img.pos[1][2]/10),tocolor(48,110,255,255),3*scale,"default-bold","center","center",false,false,true) end end end window = { current = 0, tick = getTickCount(), draw = false, close = { hover = false, }, } function openWindow(id) if window.current ~= id then window.current = id window.tick = Link to comment
codeluaeveryday Posted July 16, 2013 Share Posted July 16, 2013 Ofc it wouldn't work, you didn't explain that was in a table... Edit line 11 to your liking. ------------------------------ -- -- Dashboard by Xiti -- ------------------------------ --48,110,255 #306EFF sX,sY = guiGetScreenSize() sY = sY - 100 scale = (sX/1920)*(sY/1200) menu = { anim = false, animate = false, top = { size = {sX,sY/13}, pos = {0,0-sY/13-sY/13/40}, fontS = 6*scale, }, bottom = { size = {sX,sY/10}, pos = {0,sY+sY/10+sY/40}, img = { url = {"data/img/map.png","data/img/tune.png","data/img/music.png","data/img/stats.png","data/img/plus.png","data/img/options.png"}, pos = {{sX/2-(((sY/10)+(sY/40))*3),sY},{sX/2-(((sY/10)+(sY/40))*2),sY},{sX/2-((sY/10)+(sY/40)),sY},{sX/2+(sY/40),sY},{sX/2+(((sY/10)+((sY/40)*2))),sY},{sX/2+(((sY/10))*2+(sY/40)*3),sY}}, size = {sY/10,sY/10}, alpha = {150,255,255,255,255,255,255} }, label = {"Map Shop","Tune","Music","Stats","Donator","Options"} }, alpha = 0, tick = getTickCount(), hover = 0, block = true, } digitalFont = dxCreateFont("data/font/digital.ttf",60*scale) function drawMenu() day,month,year,hours,minutes,seconds,day_name = getServerTime () -- Background -- Bottom bar -- dxDrawRectangle(menu.bottom.pos[1],menu.bottom.pos[2],menu.bottom.size[1],menu.bottom.size[2],tocolor(0,0,0,150),true) -- dxDrawRectangle(menu.bottom.pos[1],menu.bottom.pos[2]-menu.top.size[2]/40,menu.top.size[1],menu.top.size[2]/40,tocolor(48,110,255,120),true) for i=1,#menu.bottom.img.url do dxDrawImage(menu.bottom.img.pos[i][1],menu.bottom.img.pos[i][2],menu.bottom.img.size[1],menu.bottom.img.size[2],menu.bottom.img.url[i],0,0,0,tocolor(255,255,255,menu.bottom.img.alpha[i]),true) end end addEventHandler("onClientRender",getRootElement(),drawMenu) function animateMenu() if not menu.anim then menu.tick = getTickCount() menu.anim = true menu.animate = true showCursor(true) addEventHandler("onClientPreRender",getRootElement(),animMenuOn) addEventHandler("onClientPreRender",getRootElement(),animTopMenuOn) addEventHandler("onClientPreRender",getRootElement(),fadeBackground) else menu.anim = false menu.tick = getTickCount() menu.animate = true window.current = 0 showCursor(false) closeAllPickers() resetAllElementStates() addEventHandler("onClientPreRender",getRootElement(),animMenuOff) addEventHandler("onClientPreRender",getRootElement(),animTopMenuOff) addEventHandler("onClientPreRender",getRootElement(),fadeBackgroundOff) end end function openUserpanel() if not menu.animate then if not menu.block then animateMenu() else outputChatBox("#306EFF[OPEN] #ffffffYou need to be logged to open the userpanel.",255,255,255,true) end end end bindKey("u","down",openUserpanel) function allowBind(bOl) menu.block = not bOl if bOl then startLoginNotification() end end function animMenuOn() local tick = getTickCount() - menu.tick local progress = tick/500 if progress >= 1 then progress = 1 removeEventHandler("onClientPreRender",getRootElement(),animMenuOn) menu.animate = false end menu.bottom.pos[2] = interpolateBetween(sY,0,0,sY-sY/10,0,0,progress,"Linear") for i=1,#menu.bottom.img.url do menu.bottom.img.pos[i][2] = menu.bottom.pos[2] end end function animTopMenuOn() local tick = getTickCount() - menu.tick local progress = tick/500 if progress >= 1 then progress = 1 removeEventHandler("onClientPreRender",getRootElement(),animTopMenuOn) end menu.top.pos[2] = interpolateBetween(0-sY/13,0,0,0,0,0,progress,"Linear") end function fadeBackground() local tick = getTickCount() - menu.tick local progress = tick/500 if progress >= 1 then progress = 1 removeEventHandler("onClientPreRender",getRootElement(),fadeBackground) end menu.alpha = interpolateBetween(0,0,0,90,0,0,progress,"Linear") end function animMenuOff() local tick = getTickCount() - menu.tick local progress = tick/500 if progress >= 1 then progress = 1 removeEventHandler("onClientPreRender",getRootElement(),animMenuOff) menu.animate = false end menu.bottom.pos[2] = interpolateBetween(sY-sY/10,0,0,sY+menu.top.size[2]/40,0,0,progress,"Linear") for i=1,#menu.bottom.img.url do menu.bottom.img.pos[i][2] = menu.bottom.pos[2] end end function animTopMenuOff() local tick = getTickCount() - menu.tick local progress = tick/500 if progress >= 1 then progress = 1 removeEventHandler("onClientPreRender",getRootElement(),animTopMenuOff) end menu.top.pos[2] = interpolateBetween(0,0,0,0-sY/13-menu.top.size[2]/40,0,0,progress,"Linear") end function fadeBackgroundOff() local tick = getTickCount() - menu.tick local progress = tick/500 if progress >= 1 then progress = 1 removeEventHandler("onClientPreRender",getRootElement(),fadeBackgroundOff) end menu.alpha = interpolateBetween(90,0,0,0,0,0,progress,"Linear") end function hoverButtons() if isCursorShowing() and menu.anim then local x,y = getCursorPosition() local x,y = x*sX,y*sY if x>=menu.bottom.img.pos[1][1] and x<=menu.bottom.img.pos[1][1]+menu.bottom.img.size[1] and y>= menu.bottom.img.pos[1][2] then fadeButton(1) elseif x>=menu.bottom.img.pos[2][1] and x<=menu.bottom.img.pos[2][1]+menu.bottom.img.size[1] and y>= menu.bottom.img.pos[1][2] then fadeButton(2) elseif x>=menu.bottom.img.pos[3][1] and x<=menu.bottom.img.pos[3][1]+menu.bottom.img.size[1] and y>= menu.bottom.img.pos[1][2] then fadeButton(3) elseif x>=menu.bottom.img.pos[4][1] and x<=menu.bottom.img.pos[4][1]+menu.bottom.img.size[1] and y>= menu.bottom.img.pos[1][2] then fadeButton(4) elseif x>=menu.bottom.img.pos[5][1] and x<=menu.bottom.img.pos[5][1]+menu.bottom.img.size[1] and y>= menu.bottom.img.pos[1][2] then fadeButton(5) elseif x>=menu.bottom.img.pos[6][1] and x<=menu.bottom.img.pos[6][1]+menu.bottom.img.size[1] and y>= menu.bottom.img.pos[1][2] then fadeButton(6) elseif x>=sX-dxGetTextWidth(day..", "..month.." "..year,menu.top.fontS,"default-bold")-100*scale and x<=sX and y<= menu.top.pos[2]+menu.top.size[2] then fadeButton(7) else fadeButton(0) end end end addEventHandler("onClientRender",getRootElement(),hoverButtons) fade = { current = 0, tick = getTickCount(), } function fadeButton(id) menu.hover = id if fade.current ~= id then fade.current = id fade.tick = getTickCount() end if fade.current ~= 0 then if fade.current ~= 7 then local tick = getTickCount() - fade.tick local progress = tick/1000 if progress >= 1 then progress = 1 end menu.bottom.img.alpha[fade.current] = interpolateBetween(menu.bottom.img.alpha[fade.current],0,0,255,0,0,progress,"Linear") drawLabel(fade.current) for i=1,#menu.bottom.img.alpha do if i ~= id then menu.bottom.img.alpha[i] = interpolateBetween(menu.bottom.img.alpha[i],0,0,150,0,0,progress,"Linear") end end else local tick = getTickCount() - fade.tick local progress = tick/1000 if progress >= 1 then progress = 1 end menu.top.fontS = interpolateBetween(menu.top.fontS,0,0,7*scale,0,0,progress,"Linear") drawLabel(fade.current) for i=1,#menu.bottom.img.alpha do menu.bottom.img.alpha[i] = interpolateBetween(menu.bottom.img.alpha[i],0,0,150,0,0,progress,"Linear") end end else local tick = getTickCount() - fade.tick local progress = tick/1000 if progress >= 1 then progress = 1 end for i=1,#menu.bottom.img.alpha do menu.bottom.img.alpha[i] = interpolateBetween(menu.bottom.img.alpha[i],0,0,150,0,0,progress,"Linear") end menu.top.fontS = interpolateBetween(menu.top.fontS,0,0,6*scale,0,0,progress,"Linear") end end function drawLabel(id) if id ~= 0 and menu.anim then if id ~= 7 then local text = menu.bottom.label[id] local rectX, rectY = dxGetTextWidth(text,3*scale,"default-bold")+(60*scale), dxGetFontHeight(3*scale,"default-bold")+(20*scale) dxDrawRectangle(menu.bottom.img.pos[id][1]+(menu.bottom.img.size[1]/2)-(rectX/2),menu.bottom.img.pos[1][2]-((menu.bottom.img.pos[1][2]/10)/2)-(rectY/2),rectX,rectY,tocolor(0,0,0,200),true) dxDrawText(text,menu.bottom.img.pos[id][1],menu.bottom.img.pos[1][2],menu.bottom.img.pos[id][1]+menu.bottom.img.size[1],menu.bottom.img.pos[1][2]-(menu.bottom.img.pos[1][2]/10),tocolor(48,110,255,255),3*scale,"default-bold","center","center",false,false,true) else local text = "news" local rectX, rectY = dxGetTextWidth(text,3*scale,"default-bold")+(60*scale), dxGetFontHeight(3*scale,"default-bold")+(20*scale) dxDrawRectangle(sX-(dxGetTextWidth(day..", "..month.." "..year,menu.top.fontS,"default-bold")/2)-(100*scale)/2-(rectX)/2,menu.top.pos[2]+menu.top.size[2]+((menu.bottom.img.pos[1][2]/10)/2)-(rectY/2),rectX,rectY,tocolor(0,0,0,200),true) dxDrawText(text,sX-dxGetTextWidth(day..", "..month.." "..year,menu.top.fontS,"default-bold")-100*scale,menu.top.pos[2]+menu.top.size[2],sX,menu.top.pos[2]+menu.top.size[2]+(menu.bottom.img.pos[1][2]/10),tocolor(48,110,255,255),3*scale,"default-bold","center","center",false,false,true) end end end window = { current = 0, tick = getTickCount(), draw = false, close = { hover = false, }, } function openWindow(id) if window.current ~= id then window.current = id window.tick = Link to comment
papam77 Posted July 16, 2013 Author Share Posted July 16, 2013 Doesn't work for animation, because animation is setting up to old position. Link to comment
iPrestege Posted July 16, 2013 Share Posted July 16, 2013 Did you but this userpanel? or download it from the community? Link to comment
papam77 Posted July 16, 2013 Author Share Posted July 16, 2013 It is userpanel by XiTi. It's free on ffs forum. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now