When you use the kick command on a server con, you can give a reason for that kick using the following scheme:
Code: Select all
kick (name | #userid) [reason]A better solution could be to forge a kick packet which contains a multilines reason message. This can be done using the following kick_ML method: way:
Code: Select all
#define SVC_DISCONNECT 2
/* SVC_DISCONNECT: ask the client to disconnect and show the given string in a popup dialog.
* -> (string) kick_reason: reason of the kick. It is shown to the client via
* a popup dialog. Its content can't be large.
*
* Note: such messages are sent when using the <kick> command, or when the client
* disconnect himself. In the latter, no popup dialog is shown.
*/
/* Kick with a multilines reason. Return 0 if an error has occured. */
kick_ML(id, line1[] = "", line2[] = "", line3[] = "") {
if(!is_valid_ent(id)) return 0
new msg_content[1024], pl_name[32], pl_userid, pl_authid[35]
/* grab logging infos */
pl_userid = get_user_userid(id)
get_user_name(id, pl_name, 31)
get_user_authid(id, pl_authid, 34)
/* do kick the player */
format(msg_content, 1023, "%s^n%s^n%s", line1, line2, line3)
message_begin(MSG_ONE, SVC_DISCONNECT, {0,0,0}, id)
write_string(msg_content)
message_end()
/* log the kick as <kick> command do */
log_message("Kick_ML: ^"%s<%d><%s><>^" was kicked by ^"Console^" (message ^"%s^" ^"%s^" ^"%s^")",
pl_name, pl_userid, pl_authid, line1, line2, line3)
return 1
}I needed to do that for a plugin, so I though someone could need it too. The main interesting thing here is not that the ^n escape character create a new line, but that the SVC_KICK message do kick the player and show the reason message (without checking if it's a multines one or not).
I didn't find informations about HL specific message types anywhere, so I though it could be usefull. Here are some others message types I found:
Code: Select all
#define SVC_PRINT 8
/* SVC_PRINT: show the given string in the client console.
* -> (string) message: message to display in the client console.
*/
#define SVC_STUFFTEXT 9
/* SVC_STUFFTEXT: send command for the client to execute.
* -> (string) command_line: command to execute remotely.
*
* Note: commands correspond to the classic HL console commands.
*/