Jump to content

Panel Help


K4stic

Recommended Posts

Posted

help pls it's refresh only the userPanelGrid1 and no refresh the userPanelGrid2

function playerGridUpdate() 
    if (alreadyHandled) then return false end 
    for key,player in pairs(getElementsByType("player")) do 
        local row = guiGridListAddRow(userPanelGrid1) 
        local row2 = guiGridListAddRow(userPanelGrid2) 
        guiGridListSetItemText(userPanelGrid1, row, playerCol, getPlayerName(player), false, false) 
        guiGridListSetItemText(userPanelGrid2, row2, playerCol2, getPlayerName(player), false, false) 
    end 
    alreadyHandled = true 
end 
  
function playerGridJoinUpdate() 
    if (tostring(guiGetText(userPanelEdit2)) == "") then 
        local row = guiGridListAddRow(userPanelGrid1) 
        local row2 = guiGridListAddRow(userPanelGrid2) 
        guiGridListSetItemText(userPanelGrid1, row, playerCol, getPlayerName(source), false, false) 
        guiGridListSetItemText(userPanelGrid2, row2, playerCol2, getPlayerName(source), false, false) 
    end 
end 
addEventHandler("onClientPlayerJoin", root, playerGridJoinUpdate) 
  
  
function playerGridQuitUpdate() 
    local count = guiGridListGetRowCount(userPanelGrid1) 
    for i = 0, count do 
        local item = guiGridListGetItemText(userPanelGrid1, i, 1) 
        if (item == getPlayerName(source)) then 
            guiGridListRemoveRow(userPanelGrid1, i) 
            guiGridListRemoveRow(userPanelGrid2, i) 
        end 
    end 
end 
addEventHandler("onClientPlayerQuit", root, playerGridQuitUpdate) 
  
function playerGridRenameUpdate(old, new) 
    local count = guiGridListGetRowCount(userPanelGrid1) 
    for i = 0, count do 
        local item = guiGridListGetItemText(userPanelGrid1, i, 1) 
                local item = guiGridListGetItemText(userPanelGrid2, i, 1) 
        if (item == old) or (item1 == old) then 
            guiGridListSetItemText(userPanelGrid1, i, 1, new, false, false) 
            guiGridListSetItemText(userPanelGrid2, i, 1, new, false, false) 
        end 
    end 
end 
addEventHandler("onClientPlayerChangeNick", root, playerGridRenameUpdate) 
playerGridUpdate() 

Posted

Sorry to interrupt, But you can refresh players by adding the refresh to the open panel function, Like this :

function getAllPlayers ( ) 
    for key,player in pairs(getElementsByType("player")) do 
        local row = guiGridListAddRow(userPanelGrid1) 
        local row2 = guiGridListAddRow(userPanelGrid2) 
        guiGridListSetItemText(userPanelGrid1, row, playerCol, getPlayerName(player), false, false) 
        guiGridListSetItemText(userPanelGrid2, row2, playerCol2, getPlayerName(player), false, false) 
    end 
end 
  
  
bindKey ( 'F2', 'down', function ( ) 
    for key,player in ipairs ( getElementsByType ( 'player' ) ) do 
        if guiGetVisible ( yourWindowName ) then 
            guiSetVisible ( yourWindowName, false ) 
            showCursor ( false ) 
            guiGridListClear ( userPanelGrid1 ) 
            guiGridListClear ( userPanelGrid1 ) 
        else 
            guiSetVisible ( yourWindowName, true ) 
            showCursor ( true ) 
            getAllPlayers ( ) 
        end 
    end 
end ) 

Posted
#Pai_[N] can i use the also
"onClientRender" 

to refresh grid list?

maybe you can try like this :

addEventHandler("onClientRender", root, 
function () 
    if(guiGetVisible(Widnow)~=false)then 
-- the what fuck you wan't 
   end 
end 
) 
Posted (edited)

Guys Officialy i can say because i test it!

Now you can use

"onClientRender" 

To refresh your Grid list's

this is my example of my code:

addEventHandler("onClientRender", root, 
function() 
    guiGridListClear( userPanelGrid1 ) 
    guiGridListClear( userPanelGrid2 ) 
    for key,player in pairs(getElementsByType("player")) do 
    local row = guiGridListAddRow(userPanelGrid1) 
    local row2 = guiGridListAddRow(userPanelGrid2) 
    guiGridListSetItemText(userPanelGrid1, row, playerCol, getPlayerName(player), false, false) 
    guiGridListSetItemText(userPanelGrid2, row2, playerCol2, getPlayerName(player), false, false) 
    end 
end ) 

this is useful to no use Timers and server have LAG so Try it :)

Edited by Guest
Posted

Of course not, if you are clearing/adding items every render, you won't be able to click any of them.

What you must do is: load them when the resource starts, then when a player joins/leaves/changes nick, update him on the grid list, this has been already asked on other topics, search for them.

Posted
Sorry to interrupt, But you can refresh players by adding the refresh to the open panel function, Like this :
function getAllPlayers ( ) 
    for key,player in pairs(getElementsByType("player")) do 
        local row = guiGridListAddRow(userPanelGrid1) 
        local row2 = guiGridListAddRow(userPanelGrid2) 
        guiGridListSetItemText(userPanelGrid1, row, playerCol, getPlayerName(player), false, false) 
        guiGridListSetItemText(userPanelGrid2, row2, playerCol2, getPlayerName(player), false, false) 
    end 
end 
  
  
bindKey ( 'F2', 'down', function ( ) 
    for key,player in ipairs ( getElementsByType ( 'player' ) ) do 
        if guiGetVisible ( yourWindowName ) then 
            guiSetVisible ( yourWindowName, false ) 
            showCursor ( false ) 
            guiGridListClear ( userPanelGrid1 ) 
            guiGridListClear ( userPanelGrid1 ) 
        else 
            guiSetVisible ( yourWindowName, true ) 
            showCursor ( true ) 
            getAllPlayers ( ) 
        end 
    end 
end ) 

@Solidsnake14 : Does my code above work ?

Posted

so this is ok?

function getgridlist() 
    guiGridListClear( userPanelGrid1 ) 
    guiGridListClear( userPanelGrid2 ) 
    for key,player in pairs(getElementsByType("player")) do 
    local row = guiGridListAddRow(userPanelGrid1) 
    local row2 = guiGridListAddRow(userPanelGrid2) 
    guiGridListSetItemText(userPanelGrid1, row, playerCol, getPlayerName(player), false, false) 
    guiGridListSetItemText(userPanelGrid2, row2, playerCol2, getPlayerName(player), false, false) 
    end 
end 
addEventHandler("onClientPlayerJoin", root, getgridlist) 
addEventHandler("onClientPlayerQuit", root, getgridlist) 
addEventHandler("onClientPlayerChangeNick", root, getgridlist) 

Posted

There's no need to clear it all, you can just update the player that actually left/joined/changed nick.

Search on the forums, there's a script for this.

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