Mbtdaa Posted May 8, 2014 Share Posted May 8, 2014 Hi,, I have label for get total Hunters It's not working i am sure from the data Can anyone help me solve the problem addEventHandler( "onClientGUIClick", resourceRoot, function() if ( source == GridList ) then if ( guiGridListGetSelectedItem ( source ) ~= -1 ) then local data = getElementData(source,"Hunters") or 0 local hunt = getPlayerFromName(guiGridListGetItemData(source),guiGridListGetSelectedItem(source),1) guiSetText(hunter,"Total Hunters:",data,hunt) end end end ) debugscript say getPlayerFromName == nil getElementData== nil i am sure from the data Link to comment
xXMADEXx Posted May 8, 2014 Share Posted May 8, 2014 I think this is what you are trying to do: addEventHandler( "onClientGUIClick", resourceRoot, function() if ( source == GridList ) then if ( guiGridListGetSelectedItem ( source ) ~= -1 ) then local data = getElementData(source,"Hunters") or 0 local hunt = getPlayerFromName(guiGridListGetItemData(source),guiGridListGetSelectedItem(source),1) guiSetText(hunter,"Total Hunters:"..data..hunt) end end end ) Link to comment
Mbtdaa Posted May 8, 2014 Author Share Posted May 8, 2014 I think this is what you are trying to do: addEventHandler( "onClientGUIClick", resourceRoot, function() if ( source == GridList ) then if ( guiGridListGetSelectedItem ( source ) ~= -1 ) then local data = getElementData(source,"Hunters") or 0 local hunt = getPlayerFromName(guiGridListGetItemData(source),guiGridListGetSelectedItem(source),1) guiSetText(hunter,"Total Hunters:"..data..hunt) end end end ) Bad argument @ 'guiGridListGetitemData'[expected number at argument 2,got none Bad argument @ 'getPlayerFromName'[expected number at argument 1,got boolne this is my Code function Players() guiGridListClear(GridList) for i, player in ipairs (getElementsByType ("player")) do local row = guiGridListAddRow(GridList) local Player1 = getPlayerName(player) local Player2 = string.gsub(Player1,"#%x%x%x%x%x%x","") guiGridListSetItemText(GridList,row,1,Player2,false,false) end end addEventHandler("onClientResourceStart",resourceRoot,Players) addEventHandler( "onClientGUIClick", resourceRoot, function() if ( source == GridList ) then if ( guiGridListGetSelectedItem ( source ) ~= -1 ) then local data = getElementData(source,"Hunters") or 0 local hunt = getPlayerFromName(guiGridListGetItemData(source),guiGridListGetSelectedItem(source),1) guiSetText(hunter,"Total Hunters:"..data..hunt) end end end ) Link to comment
TAPL Posted May 9, 2014 Share Posted May 9, 2014 Did you realize that you have used 3 arguments for the function getPlayerFromName? local hunt = getPlayerFromName(guiGridListGetItemData(source),guiGridListGetSelectedItem(source),1) And there more errors. Try this: function Players() guiGridListClear(GridList) for i, player in ipairs (getElementsByType ("player")) do local row = guiGridListAddRow(GridList) local Player1 = getPlayerName(player) local Player2 = string.gsub(Player1, "#%x%x%x%x%x%x", "") guiGridListSetItemText(GridList, row, 1, Player2, false, false) guiGridListSetItemData(GridList, row, 1, Player1) end end addEventHandler("onClientResourceStart", resourceRoot, Players) addEventHandler("onClientGUIClick", resourceRoot, function() if (source == GridList) then local row, col = guiGridListGetSelectedItem(source) if (row ~= -1) then local player = getPlayerFromName(guiGridListGetItemData(source, row, 1)) if player then local data = getElementData(player, "Hunters") or 0 guiSetText(hunter, "Total Hunters: "..data) else guiSetText(hunter, "Total Hunters: N/A") end end end end) Link to comment
Mbtdaa Posted May 9, 2014 Author Share Posted May 9, 2014 Did you realize that you have used 3 arguments for the function getPlayerFromName? local hunt = getPlayerFromName(guiGridListGetItemData(source),guiGridListGetSelectedItem(source),1) And there more errors. Try this: function Players() guiGridListClear(GridList) for i, player in ipairs (getElementsByType ("player")) do local row = guiGridListAddRow(GridList) local Player1 = getPlayerName(player) local Player2 = string.gsub(Player1, "#%x%x%x%x%x%x", "") guiGridListSetItemText(GridList, row, 1, Player2, false, false) guiGridListSetItemData(GridList, row, 1, Player1) end end addEventHandler("onClientResourceStart", resourceRoot, Players) addEventHandler("onClientGUIClick", resourceRoot, function() if (source == GridList) then local row, col = guiGridListGetSelectedItem(source) if (row ~= -1) then local player = getPlayerFromName(guiGridListGetItemData(source, row, 1)) if player then local data = getElementData(player, "Hunters") or 0 guiSetText(hunter, "Total Hunters: "..data) else guiSetText(hunter, "Total Hunters: N/A") end end end end) Thank you TAPL , But He does not count.! and the (else) doesn't work good . Link to comment
TAPL Posted May 9, 2014 Share Posted May 9, 2014 Show me where you have set the element data. Link to comment
Mbtdaa Posted May 9, 2014 Author Share Posted May 9, 2014 Show me where you have set the element data. the data in gamemode race, Link to comment
TAPL Posted May 9, 2014 Share Posted May 9, 2014 If the data does not exists it will show 0, if the player not in the server anymore it will show N/A. Nothing else. Link to comment
Mbtdaa Posted May 9, 2014 Author Share Posted May 9, 2014 If the data does not exists it will show 0, if the player not in the server anymore it will show N/A. Nothing else. that's the problem the data exist ! Link to comment
TAPL Posted May 9, 2014 Share Posted May 9, 2014 Use this and let me know what you see in the chat. for i, player in ipairs(getElementsByType("player")) do outputChatBox(getElementData(player, "Hunters")) end Link to comment
Mbtdaa Posted May 9, 2014 Author Share Posted May 9, 2014 (edited) sorry it's my bad ! i changed the data and it's worked ! but ther are smoll pro when i choose player and i see the text then i click in the grid the text stel same i want to set ,Total Huneter function() if (source == GridList) then local row, col = guiGridListGetSelectedItem(source) if (row ~= -1) then local player = getPlayerFromName(guiGridListGetItemData(source,row, 1)) if player then local data = getElementData(player, "race rank") or 0 guiSetText(hunter, "Total Hunters: "..data) else guiSetText(hunter, "Total Hunters: ") end end end end) race rank,for ex just try it for cheking , Edited May 9, 2014 by Guest 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