Sending a message to another player

Discussion in 'CommandHelper' started by Tikkle, Jul 12, 2017.

  1. Tikkle

    Tikkle New Member

    SO I am completely new to CommandHelper and I am trying to figure out how to make this command send the msg's to the $player:

    [commandhelper]#
    # STAFF ASKER
    # Use this command when someone asks for staff
    #

    modtool:/staff $player = >>>
    msg('')
    msg('\u00A7bHey there\u00A7e'$player'\u00A7b!\u00A7c'player()'\u00A7bnoticed you were asking about staff!')
    msg('\u00A7bYou can register to our website and apply for a staff postion at')
    msg('\u00A7ahttps://oldkingdomsmc.enjin.com/recruitment')
    msg('')
    msg('\u00A7dGood Luck ;P')
    msg('')
    <<<
    [/commandhelper]
  2. PseudoKnight

    PseudoKnight Well-Known Member

    You should look at concat(). This function even has a shorthand using dots. (periods) This is called dot-concatentation. So we can glue strings and variables together using this.
    PHP:
    msg('\u00A7bHey there\u00A7e'.$player.'\u00A7b!\u00A7c'.player().'\u00A7bnoticed you were asking about staff!')
    Then there's color(), which is an easier and more obvious way of inserting colors and can be used with dot-concatenation.
    PHP:
    msg(color('b').'Hey there '.color('e').$player.color('b').'!'.color('c').player().color('b').'noticed you were asking about staff!')
    Or we can even use colorize() which allows us to use ampersand color codes directly in the string.
    PHP:
    msg(colorize('&bHey there &e'.$player.'&b!&c'.player().'&bnoticed you were asking about staff!'))
    I usually use color() for when I only want the whole line to be a single color, and I use colorize() when I'm changing colors a lot in a single line.

    Now, back to your question. The function you're looking for is tmsg(). This allows you to send a message to a specific player, not just the player who ran a command.
    PHP:
    tmsg($player, colorize('&bHey there &e'.$player.'&b!&c'.player().'&bnoticed you were asking about staff!'))