Cronoss Posted February 21, 2022 Share Posted February 21, 2022 Hello again, I'm having a problem to understand how the tables work... I want to get ALL players inside a vehicle and get their health but I don't know how to make the table select every player and get their different healths This is function vhDam(loss) local playersLossHP = getVehicleOccupants(source) local setLossToPlayers = getElementHealth(#playersLossHP) --------- how could I get every player's health? ---------------blablabla end addEventHandler("onVehicleDamage", root, vhDam) Link to comment
βurak Posted February 21, 2022 Share Posted February 21, 2022 (edited) try using it like this function vhDam(loss) local playersLossHP = getVehicleOccupants(source) -- getVehicleOccupants returns a table for seat, player in pairs(playersLossHP) do --put this table in for loop local playerHealth = getElementHealth(player) --get the hp of the player inside the vehicle outputDebugString("Seat ID: "..seat.." Player Health: "..playerHealth) --print seat id and player's health end end addEventHandler("onVehicleDamage", root, vhDam) Edited February 21, 2022 by Burak5312 1 Link to comment
Cronoss Posted February 21, 2022 Author Share Posted February 21, 2022 Thanks, it worked 1 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