Jump to content

help


Jacobob14

Recommended Posts

help because I do not update the list of players: (

function() 
grid = guiCreateGridList(423, 276, 159, 207, false) 
guiGridListSetSelectionMode(grid,2) 
    guiSetVisible(grid, false) 
addEventHandler ( "onClientGUIClick", grid, click ) 
local name = guiGridListGetItemText(grid, row, col) 
local column = guiGridListAddColumn( grid, "Nombre del Jugador", 0.9 ) 
if ( column ) then 
for id, player in ipairs(getElementsByType("player")) do 
    local row = guiGridListAddRow ( grid ) 
       guiGridListSetItemText ( grid, row, column, getPlayerName ( player ):gsub ( "#%x%x%x%x%x%x", "" ), false, false ) 
       guiGridListSetItemData ( grid, row, column, getPlayerName ( player ) ) 
        end 
    end 
end) 
  
function click () 
       local playerName = guiGridListGetItemData ( grid, guiGridListGetSelectedItem ( grid ), 1 ) 
       guiSetText ( edit, playerName ) 
end 
  
function showPanel1() 
    guiSetVisible(closed, true) 
    guiSetVisible(Reclutar, true) 
    guiSetVisible(Expulsar, true) 
    guiSetVisible(Permisos, true) 
    guiSetVisible(qpermisos, true) 
    guiSetVisible(edit, true) 
    guiSetVisible(grid, true) 
    showCursor(true) 
playSound("open.ogg") 
    addEventHandler("onClientRender", root, draw1) 
end 
addEvent( "showPanel1", true ) 
addEventHandler ( "showPanel1", getRootElement(), showPanel1) 
  
function onGuiClick (button, state, absoluteX, absoluteY) 
    if (source == closed) then 
    guiSetVisible (closed, false) 
    guiSetVisible(closed, false) 
    guiSetVisible(Reclutar, false) 
    guiSetVisible(Expulsar, false) 
    guiSetVisible(Permisos, false) 
    guiSetVisible(qpermisos, false) 
    guiSetVisible(edit, false) 
    guiSetVisible(grid, false) 
    playSound("open.ogg") 
    showCursor (false) 
    elseif (source == qpermisos) then 
    local name = guiGetText ( edit ) 
    local target = getPlayerFromName(name) 
    triggerServerEvent ("remove1", getLocalPlayer(), target) 
    elseif (source == Reclutar) then 
    local name = guiGetText ( edit ) 
    local target = getPlayerFromName(name) 
    triggerServerEvent("Moderator1", getLocalPlayer(), target) 
    playSound("sec.wav",false) 
    elseif (source == Permisos) then 
    local name = guiGetText ( edit ) 
    local target = getPlayerFromName(name) 
    triggerServerEvent("SuperModerator1", getLocalPlayer(), target) 
    playSound("sec.wav",false) 
    elseif (source == Expulsar) then 
    local name = guiGetText ( edit ) 
    local target = getPlayerFromName(name) 
    triggerServerEvent("Admin1", getLocalPlayer(), target) 
    playSound("sec.wav",false) 
end 
end 
addEventHandler ("onClientGUIClick", getRootElement(), onGuiClick) 
  
function GetPermission() 
triggerServerEvent ("OpenPanel1", getLocalPlayer(), OpenPanel1) 
end 
  
  
  
function nopsound () 
playSound("np.mp3",false) 
end 
addEvent( "nopsound", true ) 
addEventHandler ( "nopsound", getRootElement(), nopsound) 
  
function removedsound () 
playSound("removed.wav",false) 
end 
addEvent( "removedsound", true ) 
addEventHandler ( "removedsound", getRootElement(), removedsound) 
  
  
  
function list ( ) 
    guiGridListClear ( grid ) 
    for id, players in ipairs ( getElementsByType ( "player" ) ) do 
        local row = guiGridListAddRow ( grid ) 
        guiGridListSetItemText ( grid, row, 1, getPlayerName ( players ):gsub ( "#%x%x%x%x%x%x", "" ), false, false ) 
        guiGridListSetItemData ( grid, row, 1, getPlayerName ( player ) ) 
    end 
end 
addEventHandler ( "onClientPlayerJoin", getRootElement(), list ) 
addEventHandler ( "onClientPlayerQuit", getRootElement(), list ) 
addEventHandler ( "onClientPlayerChangeNick", getRootElement(), list ) 

Link to comment
You can use this and be sure to replace gridList and column with your.
function updateList(old, new) 
    if eventName == "onClientPlayerJoin"  then 
        local row = guiGridListAddRow(gridList) 
        guiGridListSetItemText(gridList, row, column, getPlayerName(source), false, false) 
    elseif eventName == "onClientPlayerQuit"  then 
        for i=0, guiGridListGetRowCount(gridList) do 
            if guiGridListGetItemText(gridList, i, column) == getPlayerName(source) then 
                guiGridListRemoveRow(gridList, i) 
            end 
        end 
    elseif eventName == "onClientPlayerChangeNick"  then 
        for i=0, guiGridListGetRowCount(gridList) do 
            if guiGridListGetItemText(gridList, i, column) == old then 
                guiGridListSetItemText(gridList, i, column, new, false, false) 
            end 
        end 
    end 
end 
addEventHandler("onClientPlayerJoin", root, updateList) 
addEventHandler("onClientPlayerQuit", root, updateList) 
addEventHandler("onClientPlayerChangeNick", root, updateList) 

Link to comment
addEventHandler("onClientResourceStart",resourceRoot, 
function() 
grid = guiCreateGridList(423, 276, 159, 207, false) 
guiGridListSetSelectionMode(grid,2) 
    guiSetVisible(grid, false) 
addEventHandler ( "onClientGUIClick", grid, click ) 
local name = guiGridListGetItemText(grid, row, col) 
local column = guiGridListAddColumn( grid, "Nombre del Jugador", 0.9 ) 
if ( column ) then 
for id, player in ipairs(getElementsByType("player")) do 
    local row = guiGridListAddRow ( grid ) 
       guiGridListSetItemText ( grid, row, column, getPlayerName ( player ):gsub ( "#%x%x%x%x%x%x", "" ), false, false ) 
       guiGridListSetItemData ( grid, row, column, getPlayerName ( player ) ) 
        end 
    end 
end) 
  
function click () 
       local playerName = guiGridListGetItemData ( grid, guiGridListGetSelectedItem ( grid ), 1 ) 
       guiSetText ( edit, playerName ) 
end 
  
function showPanel1() 
    guiSetVisible(closed, true) 
    guiSetVisible(Reclutar, true) 
    guiSetVisible(Expulsar, true) 
    guiSetVisible(Permisos, true) 
    guiSetVisible(qpermisos, true) 
    guiSetVisible(edit, true) 
    guiSetVisible(grid, true) 
    showCursor(true) 
playSound("open.ogg") 
    addEventHandler("onClientRender", root, draw1) 
end 
addEvent( "showPanel1", true ) 
addEventHandler ( "showPanel1", getRootElement(), showPanel1) 
  
function onGuiClick (button, state, absoluteX, absoluteY) 
    if (source == closed) then 
    guiSetVisible (closed, false) 
    guiSetVisible(closed, false) 
    guiSetVisible(Reclutar, false) 
    guiSetVisible(Expulsar, false) 
    guiSetVisible(Permisos, false) 
    guiSetVisible(qpermisos, false) 
    guiSetVisible(edit, false) 
    guiSetVisible(grid, false) 
    playSound("open.ogg") 
    showCursor (false) 
    elseif (source == qpermisos) then 
    local name = guiGetText ( edit ) 
    local target = getPlayerFromName(name) 
    triggerServerEvent ("remove1", getLocalPlayer(), target) 
    elseif (source == Reclutar) then 
    local name = guiGetText ( edit ) 
    local target = getPlayerFromName(name) 
    triggerServerEvent("Moderator1", getLocalPlayer(), target) 
    playSound("sec.wav",false) 
    elseif (source == Permisos) then 
    local name = guiGetText ( edit ) 
    local target = getPlayerFromName(name) 
    triggerServerEvent("SuperModerator1", getLocalPlayer(), target) 
    playSound("sec.wav",false) 
    elseif (source == Expulsar) then 
    local name = guiGetText ( edit ) 
    local target = getPlayerFromName(name) 
    triggerServerEvent("Admin1", getLocalPlayer(), target) 
    playSound("sec.wav",false) 
end 
end 
addEventHandler ("onClientGUIClick", getRootElement(), onGuiClick) 
  
function GetPermission() 
triggerServerEvent ("OpenPanel1", getLocalPlayer(), OpenPanel1) 
end 
  
  
  
function nopsound () 
playSound("np.mp3",false) 
end 
addEvent( "nopsound", true ) 
addEventHandler ( "nopsound", getRootElement(), nopsound) 
  
function removedsound () 
playSound("removed.wav",false) 
end 
addEvent( "removedsound", true ) 
addEventHandler ( "removedsound", getRootElement(), removedsound) 
  
  
  
function updateList(old, new) 
    if eventName == "onClientPlayerJoin"  then 
        local row = guiGridListAddRow( grid ) 
        guiGridListSetItemText( grid, row, column, getPlayerName(source), false, false) 
    elseif eventName == "onClientPlayerQuit"  then 
        for i=0, guiGridListGetRowCount( grid ) do 
            if guiGridListGetItemText( grid, i, column) == getPlayerName(source) then 
                guiGridListRemoveRow( grid, i) 
            end 
        end 
    elseif eventName == "onClientPlayerChangeNick"  then 
        for i=0, guiGridListGetRowCount( grid ) do 
            if guiGridListGetItemText( grid, i, column) == old then 
                guiGridListSetItemText( grid, i, column, new, false, false) 
            end 
        end 
    end 
end 
addEventHandler("onClientPlayerJoin", root, updateList) 
addEventHandler("onClientPlayerQuit", root, updateList) 
addEventHandler("onClientPlayerChangeNick", root, updateList) 

Link to comment
addEventHandler("onClientResourceStart",resourceRoot, 
function() 
grid = guiCreateGridList(423, 276, 159, 207, false) 
guiGridListSetSelectionMode(grid,2) 
    guiSetVisible(grid, false) 
addEventHandler ( "onClientGUIClick", grid, click ) 
column = guiGridListAddColumn( grid, "Nombre del Jugador", 0.9 ) 
if ( column ) then 
for id, player in ipairs(getElementsByType("player")) do 
    local row = guiGridListAddRow ( grid ) 
       guiGridListSetItemText ( grid, row, column, getPlayerName ( player ):gsub ( "#%x%x%x%x%x%x", "" ), false, false ) 
       guiGridListSetItemData ( grid, row, column, getPlayerName ( player ) ) 
        end 
    end 
end) 
  
function click () 
       local playerName = guiGridListGetItemData ( grid, guiGridListGetSelectedItem ( grid ), 1 ) 
       guiSetText ( edit, playerName ) 
end 
  
function showPanel1() 
    guiSetVisible(closed, true) 
    guiSetVisible(Reclutar, true) 
    guiSetVisible(Expulsar, true) 
    guiSetVisible(Permisos, true) 
    guiSetVisible(qpermisos, true) 
    guiSetVisible(edit, true) 
    guiSetVisible(grid, true) 
    showCursor(true) 
playSound("open.ogg") 
    addEventHandler("onClientRender", root, draw1) 
end 
addEvent( "showPanel1", true ) 
addEventHandler ( "showPanel1", getRootElement(), showPanel1) 
  
function onGuiClick (button, state, absoluteX, absoluteY) 
    if (source == closed) then 
    guiSetVisible (closed, false) 
    guiSetVisible(closed, false) 
    guiSetVisible(Reclutar, false) 
    guiSetVisible(Expulsar, false) 
    guiSetVisible(Permisos, false) 
    guiSetVisible(qpermisos, false) 
    guiSetVisible(edit, false) 
    guiSetVisible(grid, false) 
    playSound("open.ogg") 
    showCursor (false) 
    elseif (source == qpermisos) then 
    local name = guiGetText ( edit ) 
    local target = getPlayerFromName(name) 
    triggerServerEvent ("remove1", getLocalPlayer(), target) 
    elseif (source == Reclutar) then 
    local name = guiGetText ( edit ) 
    local target = getPlayerFromName(name) 
    triggerServerEvent("Moderator1", getLocalPlayer(), target) 
    playSound("sec.wav",false) 
    elseif (source == Permisos) then 
    local name = guiGetText ( edit ) 
    local target = getPlayerFromName(name) 
    triggerServerEvent("SuperModerator1", getLocalPlayer(), target) 
    playSound("sec.wav",false) 
    elseif (source == Expulsar) then 
    local name = guiGetText ( edit ) 
    local target = getPlayerFromName(name) 
    triggerServerEvent("Admin1", getLocalPlayer(), target) 
    playSound("sec.wav",false) 
end 
end 
addEventHandler ("onClientGUIClick", getRootElement(), onGuiClick) 
  
function GetPermission() 
triggerServerEvent ("OpenPanel1", getLocalPlayer(), OpenPanel1) 
end 
  
function nopsound () 
playSound("np.mp3",false) 
end 
addEvent( "nopsound", true ) 
addEventHandler ( "nopsound", getRootElement(), nopsound) 
  
function removedsound () 
playSound("removed.wav",false) 
end 
addEvent( "removedsound", true ) 
addEventHandler ( "removedsound", getRootElement(), removedsound) 
  
function updateList(old, new) 
    if eventName == "onClientPlayerJoin"  then 
        local row = guiGridListAddRow(grid) 
        guiGridListSetItemText(grid, row, column, getPlayerName(source):gsub("#%x%x%x%x%x%x", ""), false, false) 
        guiGridListSetItemData(grid, row, column, getPlayerName(source)) 
    elseif eventName == "onClientPlayerQuit"  then 
        for i=0, guiGridListGetRowCount( grid ) do 
            if guiGridListGetItemText(grid, i, column) == getPlayerName(source):gsub("#%x%x%x%x%x%x", "") then 
                guiGridListRemoveRow(grid, i) 
            end 
        end 
    elseif eventName == "onClientPlayerChangeNick"  then 
        for i=0, guiGridListGetRowCount(grid) do 
            if guiGridListGetItemText(grid, i, column) == old:gsub("#%x%x%x%x%x%x", "") then 
                guiGridListSetItemText(grid, i, column, new:gsub("#%x%x%x%x%x%x", ""), false, false) 
                guiGridListSetItemData(grid, i, column, new) 
            end 
        end 
    end 
end 
addEventHandler("onClientPlayerJoin", root, updateList) 
addEventHandler("onClientPlayerQuit", root, updateList) 
addEventHandler("onClientPlayerChangeNick", root, updateList) 

Edited by Guest
Link to comment

Did you tested the script by yourself or together with someone else? "onClientPlayerJoin" and "onClientPlayerQuit" will not trigger for the source player which is you in this case, it will only trigger for you when another player join or quit from the server, just asking since the updated code from TAPL seems ok.

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