Raised This Month: $51 Target: $400
 12% 

Multilines kick reason


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Teyut
Junior Member
Join Date: Nov 2006
Location: Somewhere between Mars a
Old 11-12-2006 , 16:23   Multilines kick reason
Reply With Quote #1

Hi !

When you use the kick command on a server con, you can give a reason for that kick using the following scheme:
Code:
kick (name | #userid) [reason]
The problem is that the reason message is a one line message. If you want it to be displayed on multiple lines, you can count how many characters can fit on each lines of the kick popup dialog, and then format your reason message accordingly. That's painfull since HL characters don't have the same width, thus that won't work with dynamic reason messages.

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:
#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 }

There's only 3 lines available in the popup dialog. These lines should not contain a lot of text of course ... Here's a sample dialog:

[IMG]http://img292.**************/img292/5623/kickmlxv5.th.jpg[/IMG]

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:
#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.  */

Sorry if such infos have already been posted before. I was just testing the layout of my post, and click on the "submit message" button instead of the "Preview Changes" one. I didn't want to post my message right now, but since you can't delete your own messages, I had no choice but to do it

Last edited by Teyut; 12-29-2009 at 18:55. Reason: Fix SVC names, and server crash.
Teyut is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:44.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode