Klesh Posted June 23, 2011 Share Posted June 23, 2011 Hi community of MTA:SA, i make a script and this shows what players are in the server (starting GUI Scripting "Testing Scripts") and in the following code the players not showing in the list or gridlist: Client-Side: Player_Window = guiCreateWindow(22,226,189,359,"Players List by Sparrow",false) local Player_Grid = guiCreateGridList(16,57,156,288,false,Player_Window) guiGridListAddColumn(Player_Grid,"Player",0.2) guiGridListSetSelectionMode(Player_Grid,2) Hide_Button = guiCreateButton(38,23,116,26,"<Hide Window>",false,Player_Window) addCommandHandler("players", function () guiSetVisible(Player_Window, true) showCursor(true, false) end, false) addEventHandler("onClientGUIClick", Hide_Button, function (button) if (button == "left") then guiSetVisible(Player_Window, false) showCursor(false) end end, false) showCursor(true) function show() local column = guiGridListAddColumn(Player_Grid,"Player",0.2) if ( column ) then --If the column has been created, fill it with players for id, player in ipairs(getElementsByType("player")) do local row = guiGridListAddRow ( Player_Grid ) guiGridListSetItemText ( Player_Grid, row, column, getPlayerName ( player ), false, false ) end end end function Show() local player = guiGridListGetItemText (Player_Grid, guiGridListGetSelectedItem (Player_Grid), 1) end Link to comment
JR10 Posted June 23, 2011 Share Posted June 23, 2011 Try this: Player_Window = guiCreateWindow(22,226,189,359,"Players List by Sparrow",false) Player_Grid = guiCreateGridList(16,57,156,288,false,Player_Window) column = guiGridListAddColumn(Player_Grid,"Player",0.2) guiGridListSetSelectionMode(Player_Grid,2) Hide_Button = guiCreateButton(38,23,116,26,"",false,Player_Window) addCommandHandler("players", function () guiSetVisible(Player_Window, true) showCursor(true, false) end, false) addEventHandler("onClientGUIClick", Hide_Button, function (button) if (button == "left") then guiSetVisible(Player_Window, false) showCursor(false) end end, false) showCursor(true) function show() for id, player in ipairs(getElementsByType("player")) do local row = guiGridListAddRow ( Player_Grid ) guiGridListSetItemText ( Player_Grid, row, column, getPlayerName ( player ), false, false ) end end function Show() local player = guiGridListGetItemText (Player_Grid, guiGridListGetSelectedItem (Player_Grid), 1) end Link to comment
Klesh Posted June 23, 2011 Author Share Posted June 23, 2011 Not Works, is only showing the players Column but not the players are currently playing in the server. Uploaded with ImageShack.us Link to comment
JR10 Posted June 23, 2011 Share Posted June 23, 2011 Post any errors or warnings. function show() for id, player in ipairs(getElementsByType("player")) do local row = guiGridListAddRow ( Player_Grid ) guiGridListSetItemText ( Player_Grid, row, column, getPlayerName ( player ), false, false ) end end Where did you use this function i don't see it in your code. Try this: Player_Window = guiCreateWindow(22,226,189,359,"Players List by Sparrow",false) Player_Grid = guiCreateGridList(16,57,156,288,false,Player_Window) column = guiGridListAddColumn(Player_Grid,"Player",0.2) guiGridListSetSelectionMode(Player_Grid,2) Hide_Button = guiCreateButton(38,23,116,26,"",false,Player_Window) addCommandHandler("players", function () guiSetVisible(Player_Window, true) showCursor(true, false) show() end, false) addEventHandler("onClientGUIClick", Hide_Button, function (button) if (button == "left") then guiSetVisible(Player_Window, false) showCursor(false) end end, false) showCursor(true) function show() for id, player in ipairs(getElementsByType("player")) do local row = guiGridListAddRow ( Player_Grid ) guiGridListSetItemText ( Player_Grid, row, column, getPlayerName ( player ), false, false ) end end function Show() local player = guiGridListGetItemText (Player_Grid, guiGridListGetSelectedItem (Player_Grid), 1) end Link to comment
Klesh Posted June 23, 2011 Author Share Posted June 23, 2011 Being no showing the players online: No warnins or Errors found with debugscript 3. I try to follow the code of wiki.mta: function clientsideResourceStart () local playerList = guiCreateGridList ( 0.80, 0.10, 0.15, 0.60, true ) -- Create the grid list local column = guiGridListAddColumn( playerList, "Player", 0.85 ) -- Create a 'players' column in the list if ( column ) then -- If the column was successfully created for id, playeritem in ipairs(getElementsByType("player")) do --Loop through all the players, adding them to the table local row = guiGridListAddRow ( playerList ) guiGridListSetItemText ( playerList, row, column, getPlayerName ( playeritem ), false, false ) end end end addEventHandler ( "onClientResourceStart", getRootElement(), clientsideResourceStart )] I see this here Link to comment
JR10 Posted June 23, 2011 Share Posted June 23, 2011 WHAT??? What happened when you used the wiki's code it worked right? And did you use my last code it should work. Link to comment
Klesh Posted June 23, 2011 Author Share Posted June 23, 2011 Yes i used, but i can see the errors if it have, i test the debug and nothing and as you can see i put a picture before your post your code, with your code, maybe is my pc or the sscript is not build correctly, but thanks i need a little hhelp with this. Link to comment
UAEpro Posted June 23, 2011 Share Posted June 23, 2011 function clientsideResourceStart () local playerList = guiCreateGridList ( 0.80, 0.10, 0.15, 0.60, true ) -- Create the grid list local column = guiGridListAddColumn( playerList, "Player", 0.85 ) -- Create a 'players' column in the list if ( column ) then -- If the column was successfully created for id, playeritem in ipairs(getElementsByType("player")) do --Loop through all the players, adding them to the table local row = guiGridListAddRow ( playerList ) guiGridListSetItemText ( playerList, row, column, getPlayerName ( playeritem ), false, false ) end end end addEventHandler ( "onClientResourceStart", getRootElement(), clientsideResourceStart ) fixed 1 small thing ^.^ Link to comment
Klesh Posted June 23, 2011 Author Share Posted June 23, 2011 Thanks is fixed! But i need to know what error was have in the script! Link to comment
JR10 Posted June 23, 2011 Share Posted June 23, 2011 Your code addEventHandler ( "onClientResourceStart", getRootElement(), clientsideResourceStart )] You see that "]" at the end? that's the problem lol. his code addEventHandler ( "onClientResourceStart", getRootElement(), clientsideResourceStart ) He removed it. 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