abu5lf Posted April 18, 2012 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
Alpha Posted April 19, 2012 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)
Michael# Posted April 20, 2012 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?
abu5lf Posted April 20, 2012 Author 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"
Michael# Posted April 20, 2012 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!
Castillo Posted April 20, 2012 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 )
abu5lf Posted April 20, 2012 Author 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 )
Puma Posted April 21, 2012 Posted April 21, 2012 What's the problem? We can't read minds and this is not pictionary either..
abu5lf Posted April 21, 2012 Author Posted April 21, 2012 Problem and a clear image, repeat the name when you search for it
Castillo Posted April 21, 2012 Posted April 21, 2012 You should use two functions, one to refresh the players and other to search for a player.
abu5lf Posted April 22, 2012 Author 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
Kenix Posted April 22, 2012 Posted April 22, 2012 (edited) Learn lua! viewtopic.php?f=148&t=40809 It's example, not copypaste .. Edited April 22, 2012 by Guest
Michael# Posted April 22, 2012 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?
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