colored_print.inc
Original include source with line numbers.
| 1 | #if defined _colored_print_included |
| 2 | #endinput |
| 3 | #endif |
| 4 | #define _colored_print_included |
| 5 | |
| 6 | colored_print(target, const message[], any:...) |
| 7 | { |
| 8 | static buffer[512], i, argscount |
| 9 | argscount = numargs() |
| 10 | |
| 11 | if (!target) |
| 12 | { |
| 13 | static player |
| 14 | for (player = 1; player <= get_maxplayers(); player++) |
| 15 | { |
| 16 | if (!is_user_connected(player)) |
| 17 | continue; |
| 18 | |
| 19 | static changed[5], changedcount // [5] = max LANG_PLAYER occurencies |
| 20 | changedcount = 0 |
| 21 | |
| 22 | for (i = 2; i < argscount; i++) |
| 23 | { |
| 24 | if (getarg(i) == LANG_PLAYER) |
| 25 | { |
| 26 | setarg(i, 0, player) |
| 27 | changed[changedcount] = i |
| 28 | changedcount++ |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | vformat(buffer, charsmax(buffer), message, 3) |
| 33 | |
| 34 | message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, player) |
| 35 | write_byte(player) |
| 36 | write_string(buffer) |
| 37 | message_end() |
| 38 | |
| 39 | for (i = 0; i < changedcount; i++) |
| 40 | setarg(changed[i], 0, LANG_PLAYER) |
| 41 | } |
| 42 | } |
| 43 | else |
| 44 | { |
| 45 | vformat(buffer, charsmax(buffer), message, 3) |
| 46 | |
| 47 | message_begin(MSG_ONE, get_user_msgid("SayText"), _, target) |
| 48 | write_byte(target) |
| 49 | write_string(buffer) |
| 50 | message_end() |
| 51 | } |
| 52 | } |