Speak Posted October 1, 2014 Share Posted October 1, 2014 players = {} for k,v in ipairs(getElementsByType("player")) do players[#players+1] = v; end how to remove a specific player? players[#players - 1] = v; ? using - does not work Link to comment
'LinKin Posted October 1, 2014 Share Posted October 1, 2014 What? If you want to remove an specific player IN THAT table, you have two ways: 1) table.remove(players, table_index) 2) players[table_index] = nil -- Where table_index is the position of the table that you want to remove. Link to comment
Speak Posted October 1, 2014 Author Share Posted October 1, 2014 What? If you want to remove an specific player IN THAT table, you have two ways:1) table.remove(players, table_index) 2) players[table_index] = nil -- Where table_index is the position of the table that you want to remove. I want to remove only one player v = ... ? players[v_index] = nil ? Link to comment
Moderators IIYAMA Posted October 1, 2014 Moderators Share Posted October 1, 2014 Insert the player as key: players[v]=true -- Insert players[v]=nil -- remove It it easier to manage. Require the pairs loop, to loop the list. (not the ipairs) Link to comment
Anubhav Posted October 1, 2014 Share Posted October 1, 2014 players = {} for k,v in ipairs(getElementsByType("player")) do players[v] = v; end -- removing part: players[getPlayerFromName("someNmae")] = nil 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