Jump to content

User Panel


Absence2

Recommended Posts

Hello, so I found this neat resource by solidsnake @community.

So I started to configure it and ended up with this:

myWindow = nil 
pressed = false 
----------------------[KEY BINDS]-------------------- 
function bindKeys() 
    bindKey("F7", "down", dx) 
end 
addEventHandler("onClientResourceStart", getRootElement(), bindKeys) 
  
function resetState() 
    pressed = false 
end 
  
  
-- user panel 
  
local rootElement = getRootElement() 
local sw,sh = guiGetScreenSize() 
  
local windowW = 280 
local windowH = 400 
  
local windowTitle        = "User Panel      " 
local windowTitleHeight  = 20 
local windowTitleColor   = tocolor(255,255,255,255) 
local windowTitleBGColor = tocolor(0,0,0,255) 
local windowBGColor      = tocolor(0,0,0,205) 
  
local windowX = sw - 250 - windowW 
local windowY = sh / 2.28 - windowH / 2 
  
local localPlayer = getLocalPlayer ( ) 
  
function dx (thePlayer) 
local playerName = getPlayerName ( getLocalPlayer() ) 
local money = getPlayerMoney(thePlayer) 
local ping = getPlayerPing(getLocalPlayer()) 
local playerX, playerY, playerZ = getElementPosition( getLocalPlayer()) 
local playerZoneName =  getZoneName( playerX, playerY, playerZ ) 
local health = getElementHealth(getLocalPlayer()) 
local armour = getPedArmor( getLocalPlayer() ) 
local weaponType = getPedWeapon ( getLocalPlayer() ) 
  
            if weaponType then 
                weaponType = getWeaponNameFromID( weaponType ) 
                end 
local money = getElementData(localPlayer, "bankmoney") 
  
    local repWinWidth, repWinHeight = 280, 450 
    local repx, repy = guiGetScreenSize() 
    local repWinX = repx/1.95 - (repWinWidth/2) 
    local repWinY = repy/2 - (repWinHeight/2)       
    local x = windowX 
    local y = windowY + windowTitleHeight 
    local h = windowH - windowTitleHeight 
  
    dxDrawRectangle(x,y,windowW,h,windowBGColor) 
    dxDrawLine ( repWinX, repWinY + 28, repWinX+repWinWidth, repWinY + 28, tocolor ( 255, 255, 255, 150 ), 1 )  
        dxDrawLine ( repWinX, repWinY + 81, repWinX+repWinWidth, repWinY + 81, tocolor ( 255, 255, 255, 150 ), 1 )  
        dxDrawLine ( repWinX, repWinY + 355, repWinX+repWinWidth, repWinY + 355, tocolor ( 255, 255, 255, 150 ), 1 )  
    
           dxDrawText("Location: "  ..playerZoneName,sw/2.88, sh/1.34, sw, sh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) 
        
        dxDrawText("Ping: " ..ping,sw/1.68, sh/6.9, sw,sh,tocolor(255,255,0,190),0.5,"bankgothic","left","top",false,false,false) 
        
        dxDrawText("Health: "..health,sw/2.88, sh/4.85, sw,sh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) 
        
        dxDrawText(""  ..playerName,sw/2.85, sh/6.9, sw,sh,tocolor(255,255,0,190),0.5,"bankgothic","left","top",false,false,false) 
        
        dxDrawText("Bank ".. money, sw/2.88, sh/4.3, sw,sh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) 
        dxDrawText("Armour ".. armour, sw/2.88, sh/5.6, sw,sh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) 
        dxDrawText("Skin: " .. getPedSkin ( getLocalPlayer() ) , sw/1.78, sh/4.85, sw,sh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) 
        dxDrawText("Weapon: " .. weaponType, sw/2, sh/4.3, sw,sh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) 
  
        
dxDrawText(windowTitle,windowX,windowY,windowX+windowW,windowY+windowTitleHeight,windowTitleColor,0.5,"bankgothic","left","center") 
    
local veh = getPedOccupiedVehicle(localPlayer) 
if veh then 
local vehicle = getVehicleName(veh,thePlayer)       
        dxDrawText("Vehicle Name: " ..vehicle,sw/2.88, sh/1.39, sw,sh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) 
    else 
        dxDrawText("Vehicle Name: None",sw/2.88, sh/1.39, sw,sh,tocolor(255,255,255,205),0.5,"bankgothic","left","top",false,false,false) 
    end 
end 
  
function HandleTheRendering () 
addEventHandler("onClientRender",rootElement, dx) 
end 
addEventHandler("onClientResourceStart",rootElement, HandleTheRendering) 
  
            showCursor ( true ) 
        else 
            destroyElement(myWindow) 
            myWindow = nil 
            showCursor(false) 
        end 
    end 
end 

So I need some help with it, for starters, how do I hide it so it shows if you press F7?

Edit: I guess this is right but I have an error:

lua:92:'' expected near 'else'

Link to comment

I am working on it, been putting in a lot of time in this.

This is what I got now (Window shows if I press F7) but it doesn't stay up. (It hides after a second or two), (I'm trying to make it visible until I release the F7 key.

myWindow = nil 
pressed = false 
----------------------[KEY BINDS]-------------------- 
function bindKeys() 
    bindKey("F7", "down", dx) 
end 
addEventHandler("onClientResourceStart", getRootElement(), bindKeys) 
  
function resetState() 
    pressed = false 
end 
  
---------------------------[user Panel]-------------------- 
  
  
  
local rootElement = getRootElement() 
local sw,sh = guiGetScreenSize() 
  
local windowW = 280 
local windowH = 400 
  
local windowTitle        = "User Panel      " 
local windowTitleHeight  = 20 
local windowTitleColor   = tocolor(255,255,255,255) 
local windowTitleBGColor = tocolor(0,0,0,255) 
local windowBGColor      = tocolor(0,0,0,205) 
  
local windowX = sw - 250 - windowW 
local windowY = sh / 2.28 - windowH / 2 
  
local localPlayer = getLocalPlayer ( ) 
  
function dx (thePlayer) 
    if not (pressed) then 
        pressed = true 
        setTimer(resetState, 50, 1) 
        if ( myWindow == nil ) then 
local playerName = getPlayerName ( getLocalPlayer() ) 
local money = getPlayerMoney(thePlayer) 
local ping = getPlayerPing(getLocalPlayer()) 
local playerX, playerY, playerZ = getElementPosition( getLocalPlayer()) 
local playerZoneName =  getZoneName( playerX, playerY, playerZ ) 
local health = getElementHealth(getLocalPlayer()) 
local armour = getPedArmor( getLocalPlayer() ) 
local weaponType = getPedWeapon ( getLocalPlayer() ) 
  
            if weaponType then 
                weaponType = getWeaponNameFromID( weaponType ) 
                end 
local money = getElementData(localPlayer, "bankmoney") 
  
    local repWinWidth, repWinHeight = 280, 450 
    local repx, repy = guiGetScreenSize() 
    local repWinX = repx/1.95 - (repWinWidth/2) 
    local repWinY = repy/2 - (repWinHeight/2)       
    local x = windowX 
    local y = windowY + windowTitleHeight 
    local h = windowH - windowTitleHeight 
  
 addEventHandler("onClientResourceStart",resourceRoot, 
    function() 
        GUIEditor_Memo = {} 
  
  
  
        GUIEditor_Memo[1] = guiCreateMemo(277,185,269,214,"Recent Server Updates\n\nIllegal secrets\n\nShop stands\n\nNew HUD\n\nHelpchat on F1\n\nUser Panel\n\nNew exteriors/interiors\n\nMinor bug fixes\n\nMechanic Job fixed\n(You can only use it inside interiors)\n((There's garages for this, due to non-rp))\n\nVehicle Color Fix, Furnite Shops added\n(Blue doll blip on F11)",false) 
    
  
    end 
) 
    dxDrawRectangle(x,y,windowW,h,windowBGColor) 
    dxDrawLine ( repWinX, repWinY + 28, repWinX+repWinWidth, repWinY + 28, tocolor ( 255, 255, 255, 150 ), 1 ) 
        dxDrawLine ( repWinX, repWinY + 81, repWinX+repWinWidth, repWinY + 81, tocolor ( 255, 255, 255, 150 ), 1 ) 
    dxDrawLine ( repWinX, repWinY + 102, repWinX+repWinWidth, repWinY + 102, tocolor ( 255, 255, 255, 150 ), 1 ) 
        dxDrawLine ( repWinX, repWinY + 355, repWinX+repWinWidth, repWinY + 355, tocolor ( 255, 255, 255, 150 ), 1 ) 
    
           dxDrawText("Location: "  ..playerZoneName,sw/2.88, sh/1.34, sw, sh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) 
  
        dxDrawText("Ping: " ..ping,sw/1.68, sh/6.9, sw,sh,tocolor(255,255,0,190),0.5,"bankgothic","left","top",false,false,false) 
        dxDrawText("Health: "..health,sw/2.88, sh/4.85, sw,sh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) 
        dxDrawText("Recent Updates & Announcements",275.0,158.0,543.0,175.0,tocolor(255,255,0,190),0.6,"pricedown","center","top",false,false,false) 
        dxDrawText(""  ..playerName,sw/2.85, sh/6.9, sw,sh,tocolor(255,255,0,190),0.5,"bankgothic","left","top",false,false,false) 
  
        dxDrawText("Bank ".. money, sw/2.88, sh/4.3, sw,sh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) 
        dxDrawText("Armour ".. armour, sw/2.88, sh/5.6, sw,sh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) 
        dxDrawText("Skin: " .. getElementModel ( getLocalPlayer() ) , sw/1.78, sh/4.85, sw,sh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) 
        dxDrawText("Weapon: " .. weaponType, sw/2, sh/4.3, sw,sh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) 
  
  
        
dxDrawText(windowTitle,windowX,windowY,windowX+windowW,windowY+windowTitleHeight,windowTitleColor,0.5,"bankgothic","left","center") 
    
local veh = getPedOccupiedVehicle(localPlayer) 
if veh then 
local vehicle = getVehicleName(veh,thePlayer)       
        dxDrawText("Vehicle Name: " ..vehicle,sw/2.88, sh/1.39, sw,sh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) 
    else 
        dxDrawText("Vehicle Name: None",sw/2.88, sh/1.39, sw,sh,tocolor(255,255,255,205),0.5,"bankgothic","left","top",false,false,false) 
            end 
            end 
 function HandleTheRendering () 
addEventHandler("onClientRender",rootElement, dx) 
end 
addEventHandler("onClientResourceStart",rootElement, HandleTheRendering) 
  
            showCursor ( true ) 
        else 
            destroyElement(myWindow) 
            myWindow = nil 
            showCursor(false) 
        end 
    end 
  

Link to comment
local bState, bDraw 
  
local sMsg =  
[[Recent Server Updates 
  
Illegal secrets 
  
Shop stands 
  
New HUD 
  
Helpchat on F1 
  
User Panel 
  
New exteriors/interiors 
  
Minor bug fixes 
  
Mechanic Job fixed 
(You can only use it inside interiors) 
(There's garages for this, due to non-rp)) 
  
Vehicle Color Fix, Furnite Shops added 
(Blue doll blip on F11) 
]] 
  
local nSw,nSh = guiGetScreenSize( ) 
  
local nWindowW = 280 
local nWindowH = 400 
  
local sWindowTitle       = "User Panel      " 
local nWindowTitleHeight  = 20 
local nWindowTitleColor   = tocolor( 255,255,255,255 ) 
--local windowTitleBGColor = tocolor( 0,0,0,255 ) 
local nWindowBGColor      = tocolor( 0,0,0,205 ) 
  
local nWindowX = nSw - 250 - nWindowW 
local nWindowY = nSh / 2.28 - nWindowH / 2 
  
local nRepWinWidth, nRepWinHeight = 280, 450 
local nRepWinX = nSw / 1.95 - ( nRepWinWidth / 2 ) 
local nRepWinY = nSh / 2 - ( nRepWinHeight / 2 )       
local nX = nWindowX 
local nY = nWindowY + nWindowTitleHeight 
local nH = nWindowH - nWindowTitleHeight 
     
local uRoot = guiCreateMemo( 277,185,269,214,sMsg,false ) 
guiSetVisible( uRoot,false ) 
  
function fPress( ) 
    bState = not bState 
    guiSetVisible( uRoot,bState ) 
    showCursor ( not isCursorShowing( ) ) 
    bDraw = not bDraw 
end  
  
function fDraw( ) 
    if bDraw then 
        local playerName = getPlayerName ( localPlayer ) 
        local money = getPlayerMoney( localPlayer ) 
        local ping = getPlayerPing( localPlayer ) 
        local playerX, playerY, playerZ = getElementPosition( localPlayer ) 
        local playerZoneName =  getZoneName( playerX, playerY, playerZ ) 
        local health = getElementHealth( localPlayer ) 
        local armour = getPedArmor( localPlayer ) 
        local weaponType = getPedWeapon ( localPlayer ) 
      
        if weaponType then 
            weaponType = getWeaponNameFromID( weaponType ) 
        else 
            weaponType = '' 
        end 
        --local money = getElementData( localPlayer, "bankmoney" ) 
         
        dxDrawRectangle( nX,nY,nWindowW,nH,nWindowBGColor ) 
        dxDrawLine ( nRepWinX, nRepWinY + 28, nRepWinX + nRepWinWidth, nRepWinY + 28, tocolor ( 255, 255, 255, 150 ), 1 ) 
        dxDrawLine ( nRepWinX, nRepWinY + 81, nRepWinX + nRepWinWidth, nRepWinY + 81, tocolor ( 255, 255, 255, 150 ), 1 ) 
        dxDrawLine ( nRepWinX, nRepWinY + 102, nRepWinX + nRepWinWidth, nRepWinY + 102, tocolor ( 255, 255, 255, 150 ), 1 ) 
        dxDrawLine ( nRepWinX, nRepWinY + 355, nRepWinX + nRepWinWidth, nRepWinY + 355, tocolor ( 255, 255, 255, 150 ), 1 ) 
        
        dxDrawText( "Location: "  ..tostring( playerZoneName ),nSw/2.88, nSh/1.34, nSw, nSh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) 
      
        dxDrawText( "Ping: " ..tostring( ping ),nSw/1.68, nSh/6.9, nSw,nSh,tocolor(255,255,0,190),0.5,"bankgothic","left","top",false,false,false) 
        dxDrawText( "Health: "..tostring( health ),nSw/2.88, nSh/4.85, nSw,nSh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) 
        dxDrawText( "Recent Updates & Announcements",275.0,158.0,543.0,175.0,tocolor(255,255,0,190),0.6,"pricedown","center","top",false,false,false) 
        dxDrawText( ""  ..playerName,nSw/2.85, nSh/6.9, nSw,nSh,tocolor(255,255,0,190),0.5,"bankgothic","left","top",false,false,false) 
      
        dxDrawText( "Bank ".. money, nSw/2.88, nSh/4.3, nSw,nSh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) 
        dxDrawText( "Armour ".. tostring( armour ), nSw/2.88, nSh/5.6, nSw,nSh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) 
        dxDrawText( "Skin: " .. tostring( getElementModel ( localPlayer ) ) , nSw/1.78, nSh/4.85, nSw,nSh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) 
        dxDrawText( "Weapon: " .. weaponType, nSw/2, nSh/4.3, nSw,nSh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) 
      
      
            
        dxDrawText( sWindowTitle,nWindowX,nWindowY,nWindowX + nWindowW,nWindowY + nWindowTitleHeight,nWindowTitleColor,0.5,"bankgothic","left","center") 
        
        local veh = getPedOccupiedVehicle( localPlayer ) 
        if veh then 
            local vehicle = getVehicleName( veh,localPlayer )       
            dxDrawText( "Vehicle Name: " ..vehicle,nSw/2.88, nSh/1.39, nSw,nSh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false ) 
        else 
            dxDrawText( "Vehicle Name: None",nSw/2.88, nSh/1.39, nSw,nSh,tocolor(255,255,255,205),0.5,"bankgothic","left","top",false,false,false ) 
        end 
    end  
end 
  
bindKey( 'F7', 'down', fPress )  
addEventHandler( 'onClientRender',root,fDraw ) 
  
  
  
  
 

Updated.

Rewrited :S

Don't worry about red lines it's syntax bug in forum.

Link to comment
local bState, bDraw 
  
local sMsg =  
[[Recent Server Updates 
  
Illegal secrets 
  
Shop stands 
  
New HUD 
  
Helpchat on F1 
  
User Panel 
  
New exteriors/interiors 
  
Minor bug fixes 
  
Mechanic Job fixed 
(You can only use it inside interiors) 
(There's garages for this, due to non-rp)) 
  
Vehicle Color Fix, Furnite Shops added 
(Blue doll blip on F11) 
]] 
  
local nSw,nSh = guiGetScreenSize( ) 
  
local nWindowW = 280 
local nWindowH = 400 
  
local sWindowTitle       = "User Panel      " 
local nWindowTitleHeight  = 20 
local nWindowTitleColor   = tocolor( 255,255,255,255 ) 
--local windowTitleBGColor = tocolor( 0,0,0,255 ) 
local nWindowBGColor      = tocolor( 0,0,0,205 ) 
  
local nWindowX = nSw - 250 - nWindowW 
local nWindowY = nSh / 2.28 - nWindowH / 2 
  
local nRepWinWidth, nRepWinHeight = 280, 450 
local nRepWinX = nSw / 1.95 - ( nRepWinWidth / 2 ) 
local nRepWinY = nSh / 2 - ( nRepWinHeight / 2 )       
local nX = nWindowX 
local nY = nWindowY + nWindowTitleHeight 
local nH = nWindowH - nWindowTitleHeight 
     
local uRoot = guiCreateMemo( 277,185,269,214,sMsg,false ) 
guiSetVisible( uRoot,false ) 
  
function fPress( ) 
    bState = not bState 
    guiSetVisible( uRoot,bState ) 
    showCursor ( not isCursorShowing( ) ) 
    bDraw = not bDraw 
end  
  
function fDraw( ) 
    if bDraw then 
        local playerName = getPlayerName ( localPlayer ) 
        local money = getPlayerMoney( localPlayer ) 
        local ping = getPlayerPing( localPlayer ) 
        local playerX, playerY, playerZ = getElementPosition( localPlayer ) 
        local playerZoneName =  getZoneName( playerX, playerY, playerZ ) 
        local health = getElementHealth( localPlayer ) 
        local armour = getPedArmor( localPlayer ) 
        local weaponType = getPedWeapon ( localPlayer ) 
      
        if weaponType then 
            weaponType = getWeaponNameFromID( weaponType ) 
        else 
            weaponType = '' 
        end 
        --local money = getElementData( localPlayer, "bankmoney" ) 
         
        dxDrawRectangle( nX,nY,nWindowW,nH,nWindowBGColor ) 
        dxDrawLine ( nRepWinX, nRepWinY + 28, nRepWinX + nRepWinWidth, nRepWinY + 28, tocolor ( 255, 255, 255, 150 ), 1 ) 
        dxDrawLine ( nRepWinX, nRepWinY + 81, nRepWinX + nRepWinWidth, nRepWinY + 81, tocolor ( 255, 255, 255, 150 ), 1 ) 
        dxDrawLine ( nRepWinX, nRepWinY + 102, nRepWinX + nRepWinWidth, nRepWinY + 102, tocolor ( 255, 255, 255, 150 ), 1 ) 
        dxDrawLine ( nRepWinX, nRepWinY + 355, nRepWinX + nRepWinWidth, nRepWinY + 355, tocolor ( 255, 255, 255, 150 ), 1 ) 
        
        dxDrawText( "Location: "  ..tostring( playerZoneName ),nSw/2.88, nSh/1.34, nSw, nSh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) 
      
        dxDrawText( "Ping: " ..tostring( ping ),nSw/1.68, nSh/6.9, nSw,nSh,tocolor(255,255,0,190),0.5,"bankgothic","left","top",false,false,false) 
        dxDrawText( "Health: "..tostring( health ),nSw/2.88, nSh/4.85, nSw,nSh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) 
        dxDrawText( "Recent Updates & Announcements",275.0,158.0,543.0,175.0,tocolor(255,255,0,190),0.6,"pricedown","center","top",false,false,false) 
        dxDrawText( ""  ..playerName,nSw/2.85, nSh/6.9, nSw,nSh,tocolor(255,255,0,190),0.5,"bankgothic","left","top",false,false,false) 
      
        dxDrawText( "Bank ".. money, nSw/2.88, nSh/4.3, nSw,nSh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) 
        dxDrawText( "Armour ".. tostring( armour ), nSw/2.88, nSh/5.6, nSw,nSh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) 
        dxDrawText( "Skin: " .. tostring( getElementModel ( localPlayer ) ) , nSw/1.78, nSh/4.85, nSw,nSh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) 
        dxDrawText( "Weapon: " .. weaponType, nSw/2, nSh/4.3, nSw,nSh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) 
      
      
            
        dxDrawText( sWindowTitle,nWindowX,nWindowY,nWindowX + nWindowW,nWindowY + nWindowTitleHeight,nWindowTitleColor,0.5,"bankgothic","left","center") 
        
        local veh = getPedOccupiedVehicle( localPlayer ) 
        if veh then 
            local vehicle = getVehicleName( veh,localPlayer )       
            dxDrawText( "Vehicle Name: " ..vehicle,nSw/2.88, nSh/1.39, nSw,nSh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false ) 
        else 
            dxDrawText( "Vehicle Name: None",nSw/2.88, nSh/1.39, nSw,nSh,tocolor(255,255,255,205),0.5,"bankgothic","left","top",false,false,false ) 
        end 
    end  
end 
  
bindKey( 'F7', 'down', fPress )  
addEventHandler( 'onClientRender',root,fDraw ) 
  
  
  
  
  
 

Updated.

Rewrited :S

Don't worry about red lines it's syntax bug in forum.

Works like a charm, thank you!

I just have a problem with the 'window' and 'memo' as it places itself on different spots on other resolutions

Link to comment
Works like a charm, thank you!

No problem.

I just have a problem with the 'window' and 'memo' as it places itself on different spots on other resolutions

Use argument relative in function guiCreateMemo to true ( not false ).

I think better "recreate" it in guieditor ( change pos ) .

And for dx drawing use this functions:

function dxDrawRelativeText( text,posX,posY,right,bottom,color,scale,mixed_font,alignX,alignY,clip,wordBreak,postGUI ) 
    local resolutionX = 1280  
    local resolutionY = 1024  
    local sWidth,sHeight = guiGetScreenSize( ) 
    return dxDrawText(  
        tostring(text), 
        ( posX/resolutionX )*sWidth, 
        ( posY/resolutionY )*sHeight, 
        ( right/resolutionX )*sWidth, 
        ( bottom/resolutionY)*sHeight, 
        color,( sWidth/resolutionX )*scale, 
        mixed_font, 
        alignX, 
        alignY, 
        clip, 
        wordBreak, 
        postGUI 
    ) 
end 

  
function dxDrawRelativeImage( posX, posY, width, height, mixed,rotation,rotationCenterOffsetX,rotationCenterOffsetY,color,postGUI ) 
    local resolutionX = 1280  
    local resolutionY = 1024  
    local sWidth,sHeight = guiGetScreenSize( ) 
    return dxDrawImage (  
        ( posX/resolutionX )*sWidth, 
        ( posY/resolutionY )*sHeight, 
        ( width/resolutionX )*sWidth, 
        ( height/resolutionY )*sHeight, 
        mixed, 
        rotation, 
        rotationCenterOffsetX, 
        rotationCenterOffsetY, 
        color, 
        postGUI 
    ) 
end 
  

  
function dxDrawRelativeRectangle( posX, posY, width, height,color,postGUI ) 
    local resolutionX = 1280  
    local resolutionY = 1024 
    local sWidth,sHeight = guiGetScreenSize( ) 
    return dxDrawRectangle(  
        ( posX/resolutionX )*sWidth, 
        ( posY/resolutionY )*sHeight, 
        ( width/resolutionX )*sWidth, 
        ( height/resolutionY )*sHeight, 
        color, 
        postGUI 
    ) 
end 
  

In resolutionX and resolutionY change your resolution.

Link to comment

You mean like this, right? And will this work?

local bState, bDraw 
  
local sMsg = 
[[Recent Server Updates 
  
Illegal Gun Vendors 
  
Shop stands 
  
New HUD 
  
Helpchat on F1 
  
User Panel 
  
New exteriors/interiors 
  
Minor bug fixes 
  
Mechanic Job fixed 
(You can only use it inside interiors) 
(There's garages for this, due to non-rp) 
  
Vehicle Color Fix, Furnite Shops added 
(Blue doll blip on F11) 
]] 
  
local nSw,nSh = guiGetScreenSize( ) 
  
local nWindowW = 280 
local bState, bDraw 
  
local sMsg = 
[[Recent Server Updates 
  
Illegal Gun Vendors 
  
Shop stands 
  
New HUD 
  
Helpchat on F1 
  
User Panel 
  
New exteriors/interiors 
  
Minor bug fixes 
  
Mechanic Job fixed 
(You can only use it inside interiors) 
(There's garages for this, due to non-rp)) 
  
Vehicle Color Fix, Furnite Shops added 
(Blue doll blip on F11) 
]] 
  
local nSw,nSh = guiGetScreenSize( ) 
  
local nWindowW = 380 
local nWindowH = 400 
  
local sWindowTitle       = "User Control Panel" 
local nWindowTitleHeight  = 20 
local nWindowTitleColor   = tocolor( 255,255,255,255 ) 
--local windowTitleBGColor = tocolor( 0,0,0,255 ) 
local nWindowBGColor      = tocolor( 0,0,0,205 ) 
  
local nWindowX = nSw - 250 - nWindowW 
local nWindowY = nSh / 2.28 - nWindowH / 2 
  
local nRepWinWidth, nRepWinHeight = 280, 450 
local nRepWinX = nSw / 2 - ( nRepWinWidth / 2 ) 
local nRepWinY = nSh / 2 - ( nRepWinHeight / 2 )       
local nX = nWindowX 
local nY = nWindowY + nWindowTitleHeight 
local nH = nWindowH - nWindowTitleHeight 
    
   local x,y = guiGetScreenSize() 
local uRoot = guiCreateMemo( x/2.8, y/2.8, x/3.5, y/3.4,sMsg,false ) 
guiSetVisible( uRoot,false ) 
  
  
function fPress( ) 
   bState = not bState 
   guiSetVisible( uRoot,bState ) 
   showCursor ( not isCursorShowing( ) ) 
   bDraw = not bDraw 
end 
  
function fDraw( ) 
   if bDraw then 
       local playerName = getPlayerName ( localPlayer ) 
       local money = getPlayerMoney( localPlayer ) 
       local ping = getPlayerPing( localPlayer ) 
       local playerX, playerY, playerZ = getElementPosition( localPlayer ) 
       local playerZoneName =  getZoneName( playerX, playerY, playerZ ) 
       local health = getElementHealth( localPlayer ) 
       local armour = getPedArmor( localPlayer ) 
       local weaponType = getPedWeapon ( localPlayer ) 
    
       if weaponType then 
           weaponType = getWeaponNameFromID( weaponType ) 
       else 
           weaponType = '' 
       end 
       local money = getElementData( localPlayer, "bankmoney" ) 
        
local rootElement = getRootElement() 
local x,y = guiGetScreenSize()  -- Get players resolution. 
  
        dxDrawRectangle ( x/2.93, y/5.1, x/3.13, y/1.87, tocolor ( 255, 255, 255, 50 ) ) 
    dxDrawRectangle ( x/2.9, y/5, x/3.2, y/1.9, tocolor ( 0, 0, 0, 200 ) ) 
       dxDrawLine ( nRepWinX, nRepWinY + 15, nRepWinX + nRepWinWidth, nRepWinY + 15, tocolor ( 255, 255, 255, 150 ), 1 ) 
       dxDrawLine ( nRepWinX, nRepWinY + 81, nRepWinX + nRepWinWidth, nRepWinY + 81, tocolor ( 255, 255, 255, 150 ), 1 ) 
       dxDrawLine ( nRepWinX, nRepWinY + 102, nRepWinX + nRepWinWidth, nRepWinY + 102, tocolor ( 255, 255, 255, 150 ), 1 ) 
       dxDrawLine ( nRepWinX, nRepWinY + 355, nRepWinX + nRepWinWidth, nRepWinY + 355, tocolor ( 255, 255, 255, 150 ), 1 ) 
      
       dxDrawText( "Location: "  ..tostring( playerZoneName ),nSw/2.88, nSh/1.43, nSw, nSh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) 
    
       dxDrawText( "Ping: " ..tostring( ping ),nSw/1.7, nSh/4.85, nSw,nSh,tocolor(255,255,0,190),0.5,"bankgothic","left","top",false,false,false) 
       dxDrawText( " Health: "..tostring( health ),nSw/2.88, nSh/3.7, nSw,nSh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) 
       dxDrawText( "  Recent Updates & Announcements",nSw/2.85, nSh/3.15, nSw,nSh,tocolor(255,255,0,190),0.5,"bankgothic","left","top",false,false,false) 
       dxDrawText( ""  ..playerName,nSw/2.85, nSh/4.85, nSw,nSh,tocolor(255,255,0,190),0.5,"bankgothic","left","top",false,false,false) 
    
       dxDrawText( " Bank ".. money, nSw/2.88, nSh/3.4, nSw,nSh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) 
       dxDrawText( " Armour ".. tostring( armour ), nSw/2.88, nSh/4.1, nSw,nSh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) 
       dxDrawText( "Skin: " .. tostring( getElementModel ( localPlayer ) ) , nSw/2, nSh/3.7, nSw,nSh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) 
       dxDrawText( "Weapon: " .. weaponType, nSw/2, nSh/3.4, nSw,nSh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) 
    
    
          
       dxDrawText( sWindowTitle,nWindowX,nWindowY,nWindowX + nWindowW,nWindowY + nWindowTitleHeight,nWindowTitleColor,0.5,"bankgothic","left","center") 
      
       local veh = getPedOccupiedVehicle( localPlayer ) 
       if veh then 
           local vehicle = getVehicleName( veh,localPlayer )       
           dxDrawText( "Vehicle Name: " ..vehicle,nSw/2.88, nSh/1.485, nSw,nSh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false ) 
       else 
           dxDrawText( "Vehicle Name: None",nSw/2.88, nSh/1.485, nSw,nSh,tocolor(255,255,255,205),0.5,"bankgothic","left","top",false,false,false ) 
       end 
   end 
end 
  
bindKey( 'F7', 'down', fPress ) 
addEventHandler( 'onClientRender',root,fDraw ) 
  
  
  
  

Link to comment
This bad code :) believe me.

Use my code.

I say what need create you.

I used that because your codes was hard and I couldn't understand them :oops:

By the way! Those Lines doesn't fit well with different resolutions, any suggestions?

EDIT:

I'm adding a couple of things now, but I need help because I got lost again :lol:

I'm trying to add so it displays jobs. There is 7 jobs in total.

This is my code right now:

mysql = exports.mysql 
  
local bState, bDraw 
  
local sMsg = 
[[Recent Server Updates 
  
Illegal Gun Vendors 
  
Shop stands 
  
New HUD 
  
Helpchat on F1 
  
User Panel 
  
New exteriors/interiors 
  
Minor bug fixes 
  
Mechanic Job fixed 
(You can only use it inside interiors) 
(There's garages for this, due to non-rp) 
  
Vehicle Color Fix, Furnite Shops added 
(Blue doll blip on F11) 
]] 
  
local nSw,nSh = guiGetScreenSize( ) 
  
local nWindowW = 280 
local bState, bDraw 
  
local sMsg = 
[[Recent Server Updates 
  
Illegal Gun Vendors 
  
Shop stands 
  
New HUD 
  
Helpchat on F1 
  
User Panel 
  
New exteriors/interiors 
  
Minor bug fixes 
  
Mechanic Job fixed 
(You can only use it inside interiors) 
(There's garages for this, due to non-rp)) 
  
Vehicle Color Fix, Furnite Shops added 
(Blue doll blip on F11) 
]] 
  
local nSw,nSh = guiGetScreenSize( ) 
  
local nWindowW = 380 
local nWindowH = 400 
  
local sWindowTitle       = "" 
local nWindowTitleHeight  = 20 
local nWindowTitleColor   = tocolor( 255,255,255,255 ) 
--local windowTitleBGColor = tocolor( 0,0,0,255 ) 
local nWindowBGColor      = tocolor( 0,0,0,205 ) 
  
local nWindowX = nSw - 250 - nWindowW 
local nWindowY = nSh / 2.28 - nWindowH / 2 
  
local nRepWinWidth, nRepWinHeight = 280, 450 
local nRepWinX = nSw / 2 - ( nRepWinWidth / 2 ) 
local nRepWinY = nSh / 2 - ( nRepWinHeight / 2 )       
local nX = nWindowX 
local nY = nWindowY + nWindowTitleHeight 
local nH = nWindowH - nWindowTitleHeight 
    
   local x,y = guiGetScreenSize() 
local uRoot = guiCreateMemo( x/2.8, y/2.8, x/3.5, y/3.4,sMsg,false ) 
guiSetVisible( uRoot,false ) 
  
  
function fPress( ) 
   bState = not bState 
   guiSetVisible( uRoot,bState ) 
   showCursor ( not isCursorShowing( ) ) 
   bDraw = not bDraw 
end 
  
function fDraw( ) 
   if bDraw then 
       local playerName = getPlayerName ( localPlayer ) 
       local money = getPlayerMoney( localPlayer ) 
       local ping = getPlayerPing( localPlayer ) 
       local playerX, playerY, playerZ = getElementPosition( localPlayer ) 
       local playerZoneName =  getZoneName( playerX, playerY, playerZ ) 
       local health = getElementHealth( localPlayer ) 
       local armour = getPedArmor( localPlayer ) 
       local weaponType = getPedWeapon ( localPlayer ) 
    local admin = getElementData(getLocalPlayer(), "adminlevel") 
    local donator = tonumber(getElementData(getLocalPlayer(), "donatorlevel")) 
    local muted = getElementData(getLocalPlayer(), "muted") 
            local job = getElementData(getLocalPlayer(), "job") 
  
    
       if weaponType then 
           weaponType = getWeaponNameFromID( weaponType ) 
       else 
           weaponType = '' 
       end 
       local money = getElementData( localPlayer, "bankmoney" ) 
        
local rootElement = getRootElement() 
local x,y = guiGetScreenSize()  -- Get players resolution. 
  
        dxDrawRectangle ( x/2.93, y/5.1, x/3.13, y/1.87, tocolor ( 255, 255, 255, 50 ) ) 
    dxDrawRectangle ( x/2.9, y/5, x/3.2, y/1.9, tocolor ( 0, 0, 0, 200 ) ) 
        dxDrawRectangle ( x/3.02, y/1.37, x/2.963, y/8.4, tocolor ( 255, 255, 255, 50 ) ) 
        dxDrawRectangle ( x/3, y/1.36, x/3, y/9, tocolor ( 0, 0, 0, 200 ) ) 
  
              dxDrawText( "Job: "  ..tostring( job ),nSw/2.88, nSh/1.27, nSw, nSh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) 
    
       dxDrawText( "Location: "  ..tostring( playerZoneName ),nSw/2.88, nSh/1.43, nSw, nSh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) 
    
       dxDrawText( "Ping: " ..tostring( ping ),nSw/1.84, nSh/4.85, nSw,nSh,tocolor(255,255,0,190),0.5,"bankgothic","left","top",false,false,false) 
    if (admin==0) then 
       dxDrawText( "Admin: No (LVL:" ..tostring(admin).. ")",nSw/2.88, nSh/1.35, nSw,nSh,tocolor(255,255,255,190),1,"default-bold","left","top",false,false,false) 
       else 
           dxDrawText( "Admin: Yes (LVL:" ..tostring(admin).. ")",nSw/2.88, nSh/1.35, nSw,nSh,tocolor(255, 194, 14,255),1,"default-bold","left","top",false,false,false) 
           end 
            if (donator==0) then 
       dxDrawText( "Donator: No (LVL:" ..tostring(donator)..")",nSw/1.98, nSh/1.35, nSw,nSh,tocolor(167, 133, 63,255),1,"default-bold","left","top",false,false,false) 
       else 
           dxDrawText( "Donator: Yes (LVL:" ..tostring(donator)..")",nSw/1.98, nSh/1.35, nSw,nSh,tocolor(167, 133, 63,255),1,"default-bold","left","top",false,false,false) 
           end 
           
            
        if (muted==0) then 
      dxDrawText( "Muted: No",nSw/2.88, nSh/1.31, nSw,nSh,tocolor(0,192,0,190),1,"default-bold","left","top",false,false,false) 
        else 
              dxDrawText( "Muted: Yes",nSw/2.88, nSh/1.31, nSw,nSh,tocolor(200,0,0,190),1,"default-bold","left","top",false,false,false) 
      end 
       
      dxDrawText( " Health: "..tostring( health ),nSw/2.88, nSh/3.7, nSw,nSh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) 
       dxDrawText( ""  ..playerName,nSw/2.85, nSh/4.85, nSw,nSh,tocolor(255,255,0,190),0.5,"bankgothic","left","top",false,false,false) 
    
       dxDrawText( " Bank ".. money, nSw/2.88, nSh/3.4, nSw,nSh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) 
       dxDrawText( " Armour ".. tostring( armour ), nSw/2.88, nSh/4.1, nSw,nSh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) 
       dxDrawText( "Skin: " .. tostring( getElementModel ( localPlayer ) ) , nSw/2, nSh/3.7, nSw,nSh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) 
       dxDrawText( "Weapon: " .. weaponType, nSw/2, nSh/3.4, nSw,nSh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) 
    
    
          
       dxDrawText( sWindowTitle,nWindowX,nWindowY,nWindowX + nWindowW,nWindowY + nWindowTitleHeight,nWindowTitleColor,0.5,"bankgothic","left","center") 
      
       local veh = getPedOccupiedVehicle( localPlayer ) 
       if veh then 
           local vehicle = getVehicleName( veh,localPlayer )       
           dxDrawText( "Vehicle Name: " ..vehicle,nSw/2.88, nSh/1.485, nSw,nSh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false ) 
       else 
           dxDrawText( "Vehicle Name: None",nSw/2.88, nSh/1.485, nSw,nSh,tocolor(255,255,255,205),0.5,"bankgothic","left","top",false,false,false ) 
       end 
   end 
end 
  
bindKey( 'F7', 'down', fPress ) 
addEventHandler( 'onClientRender',root,fDraw ) 
  
  
  
  

This is the "job code":

function acceptJob(button, state) 
    if (button=="left") then 
        local row, col = guiGridListGetSelectedItem(jobList) 
        local job = getElementData(getLocalPlayer(), "job") 
         
        if (row==-1) or (col==-1) then 
            outputChatBox("Please select a job first!", 255, 0, 0) 
        elseif (job>0) then 
            outputChatBox("You are already employed, please quit your other job first (( /quitjob )).", 255, 0, 0) 
        else 
            local job = 0 
            local jobtext = guiGridListGetItemText(jobList, guiGridListGetSelectedItem(jobList), 1) 
             
            if ( jobtext=="Delivery Driver" or jobtext=="Taxi Driver" or jobtext=="Bus Driver" ) then  -- Driving job, requires the license 
                local carlicense = getElementData(getLocalPlayer(), "license.car") 
                if (carlicense~=1) then 
                    outputChatBox("You require a drivers license to do this job.", 255, 0, 0) 
                    return 
                end 
            end 
             
            if (jobtext=="Delivery Driver") then 
                displayTruckerJob() 
                job = 1 
            elseif (jobtext=="Taxi Driver") then 
                job = 2 
                displayTaxiJob() 
            elseif  (jobtext=="Bus Driver") then 
                job = 3 
                displayBusJob() 
            elseif (jobtext=="City Maintenance") then 
                job = 4 
            elseif (jobtext=="Mechanic") then 
                displayMechanicJob() 
                triggerServerEvent("giveMechanicJob", getLocalPlayer()) 
                job = 5 
            elseif (jobtext=="Locksmith") then 
                displayLocksmithJob() 
                job = 6 
            end 
             
            triggerServerEvent("acceptJob", getLocalPlayer(), job) 
             
            destroyElement(jobList) 
            destroyElement(bAcceptJob) 
            destroyElement(bCancel) 
            destroyElement(wEmployment) 
            wEmployment, jobList, bAcceptJob, bCancel = nil, nil, nil, nil 
            showCursor(false) 
        end 
    end 
end 

I'm using thingies from that one to implant in the User Panel (First script) but I don't know how to add them up together.

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...