Jump to content

remove specific player?


Speak

Recommended Posts

Posted
    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

Posted

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.

Posted
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

?

  • Moderators
Posted

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)

Posted
  
    players = {} 
    for k,v in ipairs(getElementsByType("player")) do 
                    players[v] = v; 
     end 
   -- removing part: 
    players[getPlayerFromName("someNmae")] = nil 
  

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...