#meS Posted September 9, 2015 Share Posted September 9, 2015 hello I want to remove row when player leave like i want to remove the player name who left the game from the grid list how to do that? Link to comment
KariiiM Posted September 9, 2015 Share Posted September 9, 2015 https://wiki.multitheftauto.com/wiki/Gu ... tRemoveRow guiGridListRemoveRow Link to comment
#meS Posted September 9, 2015 Author Share Posted September 9, 2015 Ok I know the function but .. Ah idk how to remove the left player this gonna work? function remove() guiGridListRemoveRow( gridplayers,getPlayerName(source)) end addEventHandler("onClientPlayerQuit",root,remove) Link to comment
JR10 Posted September 9, 2015 Share Posted September 9, 2015 guiGridListRemoveRow takes in the row id to remove. You need to loop through the rows and check which one has that player name and remove that row. for row = 0, guiGridListGetRowCount(gridplayers) - 1 do if (guiGridListGetItemText(gridplayers, row, 1) == getPlayerName(source)) then guiGridListRemoveRow(gridplayers, row) end end Link to comment
#meS Posted September 9, 2015 Author Share Posted September 9, 2015 Ok thank you but how to remove the rows near it? like i did near the player name ping row how to remove it when he leave? like this maybe? function remove() for row = 0, guiGridListGetRowCount(gridplayers) - 1 do if (guiGridListGetItemText(gridplayers, row, 1) == getPlayerName(source)) or (guiGridListGetItemText(gridplayers, row, 1) == getPlayerPing(getPlayerName(source) then guiGridListRemoveRow(gridplayers, row) end end addEventHandler("onClientPlayerQuit",root,remove) Link to comment
JR10 Posted September 9, 2015 Share Posted September 9, 2015 It's weird that you have 2 rows for the same player, why not add a column for the ping? You can use guiGridListSetItemData Link to comment
#meS Posted September 9, 2015 Author Share Posted September 9, 2015 thank you but why getting player team doesn't work? for id, playeritem in ipairs(getElementsByType("player")) do local row = guiGridListAddRow ( SRB.gridlist[1] ) guiGridListSetItemText ( SRB.gridlist[1], row, 1, getPlayerName ( playeritem ), false, false ) guiGridListSetItemText ( SRB.gridlist[1], row, 2, getTeamName (getPlayerTeam( playeritem )), false, false ) guiGridListSetItemText ( SRB.gridlist[1], row, 3, getElementData( playeritem ,"job"), false, false ) guiGridListSetItemText ( SRB.gridlist[1], row, 4, getPlayerPing( playeritem ), false, false ) guiGridListSetItemText ( SRB.gridlist[1], row, 5, getElementData( playeritem,"FPS"), false, false ) Link to comment
JR10 Posted September 9, 2015 Share Posted September 9, 2015 It seems fine. Are you sure the player is in a team? You should check if getPlayerTeam returns false or else getTeamName will spit a warning. 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