Zalmon Posted July 2, 2011 Posted July 2, 2011 Would this work? If not, how do I fix it? local players = getElementsByType ( "player" ) for i, player in ipairs( getElementsByType ( players ) ) if (getPlayerTeam(players) == "Criminals") then outputChatBox ( "I wanna say something only to this team", 255, 0, 0,players) I'm trying to get all the players in the team "criminals" and only tell the message to them.
Castillo Posted July 2, 2011 Posted July 2, 2011 (edited) for i,v in pairs(getPlayersInTeam(getTeamFromName("Criminals"))) do outputChatBox("Hello pals",v,255,0,0) end Edited July 2, 2011 by Guest
Jockie Posted July 2, 2011 Posted July 2, 2011 You forgot an "end" and you use tables instead of player elements. local players = getElementsByType ( "player" ) for i, player in ipairs( getElementsByType ( players ) ) if (getPlayerTeam(player) == "Criminals") then outputChatBox ( "I wanna say something only to this team", 255, 0, 0,player) end end EDIT: pairs(getPlayersInTeam(getTeamFromName("Criminals")) works as well, like SolidSnake just posted before me. Grtz. Jockie
Zalmon Posted July 2, 2011 Author Posted July 2, 2011 for i,v in pairs(getPlayersInTeam(getTeamFromName("Criminals")) do outputChatBox("Hello pals",v,255,0,0) end Thanks bro
Zalmon Posted July 2, 2011 Author Posted July 2, 2011 got error while loading says ) expected near do
Zalmon Posted July 2, 2011 Author Posted July 2, 2011 nvm lol I feel dumb, thats the easiest error to fix ever.
Castillo Posted July 2, 2011 Posted July 2, 2011 Oh, my bad, I corrected my mistake, sorry for the inconvenience.
Zalmon Posted July 2, 2011 Author Posted July 2, 2011 It's okay, it was a very easy mistake to fix, I didn't realize the error until I posted it.
r57` Posted July 6, 2011 Posted July 6, 2011 for i,v in pairs(getPlayersInTeam(getTeamFromName("Criminals")) do outputChatBox("Hello pals",v,255,0,0) end Valid...
JR10 Posted July 6, 2011 Posted July 6, 2011 The problem is already solved, and that's the same code that castillo posted.
Castillo Posted July 6, 2011 Posted July 6, 2011 JR10, even wrong, because I had a missing ')' and I fixed it, but seems like he copied a old code.
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