Meshare Posted June 13, 2013 Share Posted June 13, 2013 hi guys ' g_Players = getElementsByType("player") -- get a list of all players in the server for i,aPlayer in ipairs(g_Players) do -- find out what index the local player has in the list if aPlayer == getLocalPlayer() then g_CurrentSpectated = i break end end function spectatePrevious() -- decrement the spectate index and spectate the corresponding player if g_CurrentSpectated == 1 then g_CurrentSpectated = #g_Players else g_CurrentSpectated = g_CurrentSpectated - 1 end setCameraTarget(g_Players[g_CurrentSpectated]) end function spectateNext() -- increment the spectate index and spectate the corresponding player if g_CurrentSpectated == #g_Players then g_CurrentSpectated = 1 else g_CurrentSpectated = g_CurrentSpectated + 1 end setCameraTarget(g_Players[g_CurrentSpectated]) end -- Bind above functions to arrow keys bindKey("arrow_l", "down", spectatePrevious) bindKey("arrow_r", "down", spectateNext) it is this in my code setCameraTarget for all players ' i want for all players in my team not all players in server ' thanks ' Link to comment
Moderators IIYAMA Posted June 13, 2013 Moderators Share Posted June 13, 2013 local team = getPlayerTeam (localPlayer) if team then g_Players = getPlayersInTeam (team ) end Link to comment
Meshare Posted June 13, 2013 Author Share Posted June 13, 2013 local team = getPlayerTeam (localPlayer) if team then g_Players = getPlayersInTeam (team ) end thanks , but i can see dead players , i want see only alive players Link to comment
Moderators IIYAMA Posted June 13, 2013 Moderators Share Posted June 13, 2013 if getElementHealth( target/player/etc. ) > 0 then Link to comment
Meshare Posted June 13, 2013 Author Share Posted June 13, 2013 thanks again , i want if click button do Target random player alive in my team Link to comment
Moderators IIYAMA Posted June 13, 2013 Moderators Share Posted June 13, 2013 randomPlayer = g_Players[math.random (1,#g_Players)] you should first filter the playertable. (alive/dead) 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