Jump to content

[HELP] AdminTeam list from mysql by gui


Estevez

Recommended Posts

so can somebody help me ?

Clear the grid list before adding new rows all what you need is

guiGridListClear() 

like this

local ateamablak = nil 
  
function listAllOfAdminRender(anick, alvl) 
    if (ateamablak == nil) then 
        guiSetInputEnabled(true) 
        local sx,sy = guiGetScreenSize () 
        local width = 250 
        local height = 400 
        local ateamablak = guiCreateWindow (sx/2-width/2,sy/2-height/2,width,height,"servername - adminteam",false) 
        local Bezaras = guiCreateButton (10,height-30,width-20,22,"Close",false,ateamablak) 
        local lista = guiCreateGridList (10,25,width-20,height-60,false,ateamablak) 
        local d3 = guiGridListAddColumn (lista,"Rang",0.35) 
        local d2 = guiGridListAddColumn (lista,"Név",0.43) 
        guiWindowSetMovable(ateamablak, false) 
        guiWindowSetSizable(ateamablak, false) 
        guiGridListClear(lista) 
        local row = guiGridListAddRow ( lista ) 
        guiGridListSetItemText ( lista, row, d2, anick, false, false ) 
        guiGridListSetItemText ( lista, row, d3, alvl, false, false ) 
  
        guiBringToFront (Bezaras) 
        guiSetVisible (ateamablak, true) 
  
        addEventHandler ("onClientGUIClick", Bezaras, function(button, state) 
            if (button == "left") then 
                if (state == "up") then 
                    guiSetVisible(ateamablak, false) 
                    showCursor (false) 
                    guiSetInputEnabled(false) 
                    ateamablak = nil 
                end 
            end 
        end, false) 
    else 
        local lathato = guiGetVisible (ateamablak) 
        if (lathato == false) then 
            guiSetVisible( ateamablak, true) 
            showCursor (true) 
        else 
            showCursor(false) 
        end 
    end 
end 
addEvent("listAllOfAdminRender", true) 
addEventHandler("listAllOfAdminRender", resourceRoot, listAllOfAdminRender) 

Link to comment
i dont get warnings/errors in debugscript 3

my problem looks like this: ( i've moved the windows so that u can see my problem. )

http://prntscr.com/7adlee

-- Client Side

local sx,sy = guiGetScreenSize () 
local width = 250 
local height = 400 
  
addEventHandler("onClientResourceStart",resourceRoot, 
function() 
    ateamablak = guiCreateWindow (sx/2-width/2,sy/2-height/2,width,height,"servername - adminteam",false) 
    Bezaras = guiCreateButton (10,height-30,width-20,22,"Close",false,ateamablak) 
    lista = guiCreateGridList (10,25,width-20,height-60,false,ateamablak) 
    d3 = guiGridListAddColumn (lista,"Rang",0.35) 
    d2 = guiGridListAddColumn (lista,"Név",0.43) 
    guiWindowSetMovable(ateamablak, false) 
    guiWindowSetSizable(ateamablak, false) 
    guiSetVisible(ateamablak, false) 
    addEventHandler ("onClientGUIClick", Bezaras, CloseGui,false) 
end  
) 
  
function listAllOfAdminRender(table) 
        guiSetVisible( ateamablak, true) 
        showCursor (true) 
        guiSetInputEnabled(true) 
        guiGridListClear(lista) 
        for k,v in pairs(table) do 
        local row = guiGridListAddRow ( lista ) 
        guiGridListSetItemText ( lista, row, d2, v[1], false, false ) 
        guiGridListSetItemText ( lista, row, d3, v[2], false, false ) 
    end 
end 
addEvent("listAllOfAdminRender", true) 
addEventHandler("listAllOfAdminRender", resourceRoot, listAllOfAdminRender) 
  
function CloseGui(button, state) 
    if (button == "left") and (state == "up") then 
        guiSetVisible(ateamablak, false) 
        showCursor (false) 
        guiSetInputEnabled(false)    
    end 
end 

-- Server side

local connection = dbConnect( "mysql", exports.roleplay_global:getSQLData() ) 
  
function listAllOfAdmin(player) 
    admins = {} 
    local query = dbQuery(connection,"SELECT * FROM `account` WHERE `admin` >= '1'") 
    local result = dbPoll(query, -1) 
    local aNick, adminLevel 
    if result then 
        for k, data in ipairs (result) do 
            aNick = data["anick"] 
            adminLevel = data["admin"] 
            table.insert(admins,{aNick,adminLevel}) 
            triggerClientEvent(player,"listAllOfAdminRender", resourceRoot, admins) 
        end 
    else 
        return 
    end 
    dbFree(query) 
end 
addCommandHandler("asd", listAllOfAdmin) 

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