thasajti Posted November 16, 2015 Share Posted November 16, 2015 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
Addlibs Posted November 16, 2015 Share Posted November 16, 2015 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
thasajti Posted November 16, 2015 Author Share Posted November 16, 2015 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
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