Jump to content

Top Gui


Memory

Recommended Posts

Hello, please, help me with Top ten Gui.

I confused in this and in triggerServerEvent and triggerClientEvent.

Client

local TOPTEN = {} 
local GUI = {} 
  
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function() 
    triggerServerEvent("onClientRequestTopTen", getLocalPlayer()) 
    toptenGUI() 
    bindKey("F1", "down", toggleGUI) 
end) 
  
  
function toggleGUI() 
    if guiGetVisible(GUI.wdw) then 
        guiSetVisible(GUI.wdw, false) 
        showCursor(false) 
    else 
        triggerServerEvent("onClientRequestTopTen", getLocalPlayer()) 
        guiGridListClear(GUI.list) 
        for _, v in ipairs( aQuery ) do 
            local row = guiGridListAddRow(GUI.list) 
            guiGridListSetItemText(GUI.list, row, 1, v[ 'nick' ], false, false) 
            guiGridListSetItemText(GUI.list, row, 2, v[ 'points' ], false, false) 
        end 
        showCursor(true) 
        guiSetVisible(GUI.wdw, true) 
    end 
end 
  
function toptenGUI() 
    GUI.wdw = guiCreateWindow(0.300, 0.330, 0.400, 0.400, "Top ten", true) 
    guiWindowSetSizable(GUI.wdw, false) 
    guiWindowSetMovable(GUI.wdw, false) 
  
    GUI.list = guiCreateGridList(0, 0.11, 1, 0.750, true, GUI.wdw) 
    guiGridListAddColumn(GUI.list, "name", 0.6) 
    guiGridListAddColumn(GUI.list, "points", 0.3) 
  
    GUI.close = guiCreateButton(0, 0.890, 1, 0.060, "exit", true, GUI.wdw) 
    addEventHandler("onClientGUIClick", GUI.close, toggleGUI, false) 
  
    guiSetAlpha(GUI.wdw, 0.6) 
    guiSetFont(GUI.list, "default-small") 
    guiSetFont(GUI.close, "default-small") 
    guiSetVisible(GUI.wdw, false) 
end 
  

Server

function sortplayers( pPlayer ) 
        local aQuery = executeSQLQuery( 'SELECT points, nick FROM `Points` ORDER BY `points` DESC LIMIT 10' ) 
        if type( aQuery ) == 'table' and #aQuery > 0 then 
            for _, v in ipairs( aQuery ) do 
                outputChatBox( "#00FF00".._..": #FFFFFF".. v[ 'nick' ] .. " #00FF00- " .. v[ 'points' ], pPlayer, 255,255,255,true ) 
            end 
        end 
    end 
addEvent("onClientRequestTopTen", true) 
addEventHandler("onClientRequestTopTen", getRootElement(), sortplayers) 

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...