Jump to content

Need a little help over here, thanks.


Panda

Recommended Posts

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...