Panda Posted July 15, 2015 Share Posted July 15, 2015 Hello Everyone, I just want a little help over here, it's nothing for some players, but it really pissed me off for real.. local allowedTeams = {["Delta Team"] = true} function Hola() if allowedTeams[getTeamName(getPlayerTeam(source))] then exports.Servercommands:dropMessage("*Never Mind this...",9,93,19) end end addEvent("lol",true) addEventHandler('lol', getRootElement(), Hola) I can't even lock it to that Team, Maybe beacause it's a new event? It pissed me off.. How can i lock it? Thanks. PS: when i put it like that, the msg will be sent to everyone, I mean every player in the server not only The Delta Team, thanks again. Link to comment
Price. Posted July 15, 2015 Share Posted July 15, 2015 because the output you just written, you did not specify to whom this message should be delivered function Hola() for _, p in ipairs ( getElementsByType ( "player" ) ) do if getPlayerTeam(p) == getTeamFromName("Delta Team") then exports.Servercommands:dropMessage("*Never Mind this...", p, 9,93,19) end end end addEvent("lol",true) addEventHandler('lol', getRootElement(), Hola) try this, better organised Link to comment
GTX Posted July 15, 2015 Share Posted July 15, 2015 It's not better organised, because if you would like to add more teams, his code would be better. You would just need to add a team name into table. PS: when i put it like that, the msg will be sent to everyone, I mean every player in the server not only The Delta Team, thanks again. Is this solved? To send a message to team only, iterate through players in the server and then do an if check to check whether player is on team or not. After that, you'll need to pass a player argument to dropMessage function. If you'd show that function, I could solve the problem for you. Link to comment
Price. Posted July 15, 2015 Share Posted July 15, 2015 @GTX, he can... [lua] theTeam = getPlayerTeam ( p) if getTeamName( theTeam ) == "Team1" or getTeamName( theTeam ) == "Team2" or getTeamName( theTeam ) == "Team3" then [lua] Link to comment
GTX Posted July 15, 2015 Share Posted July 15, 2015 He can but it's not good. If you need to add 100 teams, what would you do then? 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