Meshare Posted June 13, 2013 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 '
Moderators IIYAMA Posted June 13, 2013 Moderators Posted June 13, 2013 local team = getPlayerTeam (localPlayer) if team then g_Players = getPlayersInTeam (team ) end Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Meshare Posted June 13, 2013 Author 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
Moderators IIYAMA Posted June 13, 2013 Moderators Posted June 13, 2013 if getElementHealth( target/player/etc. ) > 0 then Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Meshare Posted June 13, 2013 Author Posted June 13, 2013 thanks again , i want if click button do Target random player alive in my team
Moderators IIYAMA Posted June 13, 2013 Moderators Posted June 13, 2013 randomPlayer = g_Players[math.random (1,#g_Players)] you should first filter the playertable. (alive/dead) Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
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