Jump to content

How to get a player using getAlivePlayers()


Recommended Posts

Hello everybody ,

i'm trying to make a script where the last player in combat gets a reward.

I'm using onVehicleExplode() to check on the number of alive players since it is a Shooter mode.

How can i get the last player alive and set a variable to him so i may be able to give him money , exp ,etc.?

Link to comment

Inside the event, you can check the table size to see how many players are remaining. If it's only one, you can access it with variable[1].


local players = getAlivePlayers ( ); -- Get players 
if ( #players == 1 ) then  
    -- only one player is remaining 
    local player = players [ 1 ]; 
    -- 'player' variable is the winning player 

Link to comment

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...