Jump to content

getRootElement except one player?


thasajti

Recommended Posts

Hello guys !

I have a question for you.

I want to make an outputChatBox which say "xy killed xy", but I dnot want the killer and the victim to see that message, because they get their own message.

outputChatBox("xy killed you",victim) 
outputChatBox("xy killed xy",getRootElement(victim,killer))--something like this to make an exception? 
  

If theres no solution to that, how can i achieve the same effects?

Link to comment
local x = getPlayerName(killer) -- since this is the same for everyone, there's no point of defining it multiple times in the loop 
for plr in ipairs(getElementsByType("player")) do 
  local y = ( victim == plr and "you" or getPlayerName(victim) ) -- if victim == the player its outputting message to, display "you", otherwise the victim's name (conditional operator, inline-IF-statement, or however you want to call this) 
  ouputChatBox(x .. " killed " .. y, plr) 
end 

Link to comment
local x = getPlayerName(killer) -- since this is the same for everyone, there's no point of defining it multiple times in the loop 
for plr in ipairs(getElementsByType("player")) do 
  local y = ( victim == plr and "you" or getPlayerName(victim) ) -- if victim == the player its outputting message to, display "you", otherwise the victim's name (conditional operator, inline-IF-statement, or however you want to call this) 
  ouputChatBox(x .. " killed " .. y, plr) 
end 

Thanks a lot, I'm starting to understand the ipairs stuff, and you really helped me in that! :):)

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...