abu5lf Posted April 18, 2012 Share Posted April 18, 2012 (edited) function onUpdateMoneyplayersList() playerName = getPlayerName ( getLocalPlayer() ) playerList = guiCreateGridList(17,59,166,327,false,WinSend) guiGridListSetSelectionMode(playerList,2) -- Create a players column in the list local column = guiGridListAddColumn( playerList, "Player", 0.85 ) if ( column ) then for id, playeritem in ipairs(getElementsByType("player")) do local row = guiGridListAddRow ( playerList ) guiGridListSetItemText ( playerList, row, column, getPlayerName ( playeritem ), false, false ) end addEventHandler ( "onClientGUIClick", playerList, click ) end if ( source == bhsh ) then guiGridListClear ( playerList ); local sName = guiGetText ( source ); if ( sName ~= "" ) then for _, pPlayer in ipairs ( getElementsByType 'player' ) do if string.find ( getPlayerName ( pPlayer ):lower ( ), sName:lower ( ), 1, true ) then -- local row = guiGridListAddRow ( playerlist ); guiGridListSetItemText ( playerlist, row, column, getPlayerName ( pPlayer ), false, false ); end end end end end addEventHandler ( "onClientResourceStart", getRootElement(), onUpdateMoneyplayersList) addEventHandler("onClientPlayerJoin", getRootElement(), onUpdateMoneyplayersList) addEventHandler("onClientPlayerQuit", getRootElement(), onUpdateMoneyplayersList) addEventHandler("onClientPlayerChangeNick", getRootElement(), onUpdateMoneyplayersList) addEventHandler("onClientGUIChanged", getRootElement(), onUpdateMoneyplayersList) Find edit of the player is not working correctly Edited December 25, 2012 by Guest Link to comment
Alpha Posted April 19, 2012 Share Posted April 19, 2012 It's so messy. Where is function click? And you commented guiGridListAddRow function. function onUpdateMoneyplayersList() playerName = getPlayerName ( getLocalPlayer() ) playerList = guiCreateGridList(17,59,166,327,false,WinSend) guiGridListSetSelectionMode(playerList,2) -- Create a players column in the list local column = guiGridListAddColumn( playerList, "Player", 0.85 ) if ( column ) then for id, playeritem in ipairs(getElementsByType("player")) do local row = guiGridListAddRow ( playerList ) guiGridListSetItemText ( playerList, row, column, getPlayerName ( playeritem ), false, false ) end addEventHandler ( "onClientGUIClick", playerList, click ) end if ( source == bhsh ) then guiGridListClear ( playerList ); local sName = guiGetText ( source ); if ( sName ~= "" ) then for _, pPlayer in ipairs ( getElementsByType 'player' ) do if string.find ( getPlayerName ( pPlayer ):lower ( ), sName:lower ( ), 1, true ) then local row = guiGridListAddRow ( playerlist ); guiGridListSetItemText ( playerlist, row, column, getPlayerName ( pPlayer ), false, false ); end end end end end addEventHandler ( "onClientResourceStart", getRootElement(), onUpdateMoneyplayersList) addEventHandler("onClientPlayerJoin", getRootElement(), onUpdateMoneyplayersList) addEventHandler("onClientPlayerQuit", getRootElement(), onUpdateMoneyplayersList) addEventHandler("onClientPlayerChangeNick", getRootElement(), onUpdateMoneyplayersList) addEventHandler("onClientGUIChanged", getRootElement(), onUpdateMoneyplayersList) Link to comment
abu5lf Posted April 20, 2012 Author Share Posted April 20, 2012 What work did not work well Link to comment
Michael# Posted April 20, 2012 Share Posted April 20, 2012 pList = guiCreateGridList ( 17, 59, 166, 327, false, WinSend ) guiGridListSetSelectionMode ( pList, 2 ) onUpdateMoneyPlayerList = function ( ) local pName = getPlayerName ( localPlayer ) local column = guiGridListAddColumn ( pList, 'Player', 0.85 ) if ( column ) then for _, player in ipairs ( getElementsByType 'player' ) do local row = guiGridListAddRow ( pList ) guiGridListSetItemText ( pList, row, column, getPlayerName ( player ), false, false ) end addEventHandler ( 'onClientGUIClick', root, click ) -- where is click function? also, put in the start of function "if ( source == pList ) then" elseif ( source == bhsh ) then guiGridListClear ( pList ) local sName = guiGetText ( source ) if ( sName ~= '' ) then for _, player in ipairs ( getElementsByType 'player' ) do if ( string.find ( getPlayerName ( player ):lower ( ), sName:lower ( ), 1, true ) then local row = guiGridListAddRow ( pList ) guiGridListSetItemText ( pList, row, column, getPlayerName ( player ), false, false ) end end end end end addEventHandler ( 'onClientGUIClick', root, onUpdateMoneyPlayerList ) addEventHandler ( 'onClientPlayerChangeNick', root, onUpdateMoneyPlayerList ) addEventHandler ( 'onClientPlayerQuit', root, onUpdateMoneyPlayerList ) addEventHandler ( 'onClientPlayerJoin', root, onUpdateMoneyPlayerList ) addEventHandler ( 'onClientResourceStart', root, onUpdateMoneyPlayerList ) Just a edit. Also, what doesn't works? Player names don't appear? Link to comment
abu5lf Posted April 20, 2012 Author Share Posted April 20, 2012 onUpdateMoneyPlayerList = function ( ) local pName = getPlayerName ( localPlayer ) local column = guiGridListAddColumn ( pList, 'Player', 0.85 ) if ( column ) then for _, player in ipairs ( getElementsByType 'player' ) do local row = guiGridListAddRow ( pList ) guiGridListSetItemText ( pList, row, column, getPlayerName ( player ), false, false ) end addEventHandler ( 'onClientGUIClick', root, click ) -- where is click function? also, put in the start of function "if ( source == pList ) then" elseif ( source == bhsh ) then guiGridListClear ( pList ) local sName = guiGetText ( source ) if ( sName ~= '' ) then for _, player in ipairs ( getElementsByType 'player' ) do if string.find ( getPlayerName ( player ):lower ( ), sName:lower ( ), 1, true ) then local row = guiGridListAddRow ( pList ) guiGridListSetItemText ( pList, row, column, getPlayerName ( player ), false, false ) end end end end end addEventHandler ( 'onClientGUIClick', root, onUpdateMoneyPlayerList ) addEventHandler ( 'onClientPlayerChangeNick', root, onUpdateMoneyPlayerList ) addEventHandler ( 'onClientPlayerQuit', root, onUpdateMoneyPlayerList ) addEventHandler ( 'onClientPlayerJoin', root, onUpdateMoneyPlayerList ) addEventHandler ( 'onClientResourceStart', root, onUpdateMoneyPlayerList ) function click () local playerName = guiGridListGetItemText ( playerList, guiGridListGetSelectedItem ( playerList ), 1 ) guiSetText ( plnmedit, playerName ) end not work Edit: if ( string.find ( getPlayerName ( player ):lower ( ), sName:lower ( ), 1, true ) then ")" expected near "then" Link to comment
Michael# Posted April 20, 2012 Share Posted April 20, 2012 My bad... pList = guiCreateGridList ( 17, 59, 166, 327, false, WinSend ) guiGridListSetSelectionMode ( pList, 2 ) onUpdateMoneyPlayerList = function ( ) local column = guiGridListAddColumn ( pList, 'Player', 0.85 ) if ( column ) then for _, player in ipairs ( getElementsByType 'player' ) do local row = guiGridListAddRow ( pList ) guiGridListSetItemText ( pList, row, column, getPlayerName ( player ), false, false ) end addEventHandler ( 'onClientGUIClick', root, click ) elseif ( source == bhsh ) then guiGridListClear ( pList ) local sName = guiGetText ( source ) if ( sName ~= '' ) then for _, player in ipairs ( getElementsByType 'player' ) do if ( string.find ( getPlayerName ( player ):lower ( ), sName:lower ( ), 1, true ) ) then local row = guiGridListAddRow ( pList ) guiGridListSetItemText ( pList, row, column, getPlayerName ( player ), false, false ) end end end end end addEventHandler ( 'onClientGUIClick', root, onUpdateMoneyPlayerList ) addEventHandler ( 'onClientPlayerChangeNick', root, onUpdateMoneyPlayerList ) addEventHandler ( 'onClientPlayerQuit', root, onUpdateMoneyPlayerList ) addEventHandler ( 'onClientPlayerJoin', root, onUpdateMoneyPlayerList ) addEventHandler ( 'onClientResourceStart', root, onUpdateMoneyPlayerList ) function click ( ) if ( source == pList ) then local row, col = guiGridListGetSelectedItem ( source ) if ( row and col and row ~= -1 and col ~= -1 ) then local pName = guiGridListGetItemText ( source, row, col ) guiSetText ( plnmedit, tostring ( pName ) ) end end end Copy all my code, not just a part! Link to comment
Castillo Posted April 20, 2012 Share Posted April 20, 2012 pList = guiCreateGridList ( 17, 59, 166, 327, false, WinSend ) column = guiGridListAddColumn ( pList, 'Player', 0.85 ) onUpdateMoneyPlayerList = function ( ) if ( column ) then for _, player in ipairs ( getElementsByType 'player' ) do local row = guiGridListAddRow ( pList ) guiGridListSetItemText ( pList, row, column, getPlayerName ( player ), false, false ) end elseif ( source == bhsh ) then guiGridListClear ( pList ) local sName = guiGetText ( source ) if ( sName ~= '' ) then for _, player in ipairs ( getElementsByType 'player' ) do if string.find ( getPlayerName ( player ):lower ( ), sName:lower ( ), 1, true ) then local row = guiGridListAddRow ( pList ) guiGridListSetItemText ( pList, row, column, getPlayerName ( player ), false, false ) end end end end end addEventHandler ( 'onClientPlayerChangeNick', root, onUpdateMoneyPlayerList ) addEventHandler ( 'onClientPlayerQuit', root, onUpdateMoneyPlayerList ) addEventHandler ( 'onClientPlayerJoin', root, onUpdateMoneyPlayerList ) addEventHandler ( 'onClientResourceStart', resourceRoot, onUpdateMoneyPlayerList ) function click ( ) local row, col = guiGridListGetSelectedItem ( pList ) if ( row and col and row ~= -1 and col ~= -1 ) then local playerName = guiGridListGetItemText ( pList, row, col ) guiSetText ( plnmedit, playerName ) end end addEventHandler ( 'onClientGUIClick', pList, click ) Link to comment
abu5lf Posted April 20, 2012 Author Share Posted April 20, 2012 pList = guiCreateGridList ( 17, 59, 166, 327, false, WinSend ) column = guiGridListAddColumn ( pList, 'Player', 0.85 ) onUpdateMoneyPlayerList = function ( ) if ( column ) then for _, player in ipairs ( getElementsByType 'player' ) do local row = guiGridListAddRow ( pList ) guiGridListSetItemText ( pList, row, column, getPlayerName ( player ), false, false ) end elseif ( source == bhsh ) then guiGridListClear ( pList ) local sName = guiGetText ( source ) if ( sName ~= '' ) then for _, player in ipairs ( getElementsByType 'player' ) do if string.find ( getPlayerName ( player ):lower ( ), sName:lower ( ), 1, true ) then local row = guiGridListAddRow ( pList ) guiGridListSetItemText ( pList, row, column, getPlayerName ( player ), false, false ) end end end end end addEventHandler ( 'onClientPlayerChangeNick', root, onUpdateMoneyPlayerList ) addEventHandler ( 'onClientPlayerQuit', root, onUpdateMoneyPlayerList ) addEventHandler ( 'onClientPlayerJoin', root, onUpdateMoneyPlayerList ) addEventHandler ( 'onClientResourceStart', resourceRoot, onUpdateMoneyPlayerList ) function click ( ) local row, col = guiGridListGetSelectedItem ( pList ) if ( row and col and row ~= -1 and col ~= -1 ) then local playerName = guiGridListGetItemText ( pList, row, col ) guiSetText ( plnmedit, playerName ) end end addEventHandler ( 'onClientGUIClick', pList, click ) pList = guiCreateGridList ( 17, 59, 166, 327, false, WinSend ) column = guiGridListAddColumn ( pList, 'Player', 0.85 ) onUpdateMoneyPlayerList = function ( ) if ( column ) then for _, player in ipairs ( getElementsByType 'player' ) do local row = guiGridListAddRow ( pList ) guiGridListSetItemText ( pList, row, column, getPlayerName ( player ), false, false ) end elseif ( source == bahs ) then guiGridListClear ( pList ) local sName = guiGetText ( source ) if ( sName ~= '' ) then for _, player in ipairs ( getElementsByType 'player' ) do if string.find ( getPlayerName ( player ):lower ( ), sName:lower ( ), -1, true ) then local row = guiGridListAddRow ( pList ) guiGridListSetItemText ( pList, row, column, getPlayerName ( player ), false, false ) end end end end end addEventHandler ( 'onClientPlayerChangeNick', root, onUpdateMoneyPlayerList ) addEventHandler ( 'onClientPlayerQuit', root, onUpdateMoneyPlayerList ) addEventHandler ( 'onClientPlayerJoin', root, onUpdateMoneyPlayerList ) addEventHandler ( 'onClientResourceStart', resourceRoot, onUpdateMoneyPlayerList ) addEventHandler ( 'onClientGUIChanged', root, onUpdateMoneyPlayerList ) function click ( ) local row, col = guiGridListGetSelectedItem ( pList ) if ( row and col and row ~= -1 and col ~= -1 ) then local playerName = guiGridListGetItemText ( pList, row, col ) guiSetText ( plnmedit, playerName ) end end addEventHandler ( 'onClientGUIClick', pList, click ) Link to comment
Puma Posted April 21, 2012 Share Posted April 21, 2012 What's the problem? We can't read minds and this is not pictionary either.. Link to comment
abu5lf Posted April 21, 2012 Author Share Posted April 21, 2012 Problem and a clear image, repeat the name when you search for it Link to comment
Castillo Posted April 21, 2012 Share Posted April 21, 2012 You should use two functions, one to refresh the players and other to search for a player. Link to comment
abu5lf Posted April 22, 2012 Author Share Posted April 22, 2012 how remove hex code in grid list ? Link to comment
Kenix Posted April 22, 2012 Share Posted April 22, 2012 string.gsub( s, '#%x%x%x%x%x%x', '' ) Link to comment
abu5lf Posted April 22, 2012 Author Share Posted April 22, 2012 string.gsub( s, '#%x%x%x%x%x%x', '' ) onUpdateMoneyPlayerList = function ( ) if ( column ) then for _, player in ipairs ( getElementsByType 'player' ) do local row = guiGridListAddRow ( pList ) local name = getPlayerName ( player ) guiGridListSetItemText ( pList, row, column, name, "#%x%x%x%x%x%x", ( player ), false, false ) string.gsub( name, "#%x%x%x%x%x%x", "" ) end end end Link to comment
Kenix Posted April 22, 2012 Share Posted April 22, 2012 (edited) Learn lua! viewtopic.php?f=148&t=40809 It's example, not copypaste .. Edited April 22, 2012 by Guest Link to comment
Michael# Posted April 22, 2012 Share Posted April 22, 2012 onUpdateMoneyPlayerList = function ( ) if ( column ) then for _, player in ipairs ( getElementsByType 'player' ) do local row = guiGridListAddRow ( pList ) local name = getPlayerName ( player ) guiGridListSetItemText ( pList, row, column, string.gsub( name, "#%x%x%x%x%x%x", "" ), false, false ) end end end Is that hard? Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now