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

Multilines kick reason


Post New Thread Reply   
 
Thread Tools Display Modes
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
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 11-12-2006 , 16:38   Re: Multilines kick reason
Reply With Quote #2

Sounds interesting. Can you show a screen shot of it in action?
__________________
Brad is offline
Teyut
Junior Member
Join Date: Nov 2006
Location: Somewhere between Mars a
Old 11-12-2006 , 16:50   Re: Multilines kick reason
Reply With Quote #3

Like I explained it above, I wasn't really ready to post my message when you saw it. The (almost) final version is now available, with a screenshot as you asked Its content is in french, but that shouldn't be a real problem

I'm sorry for the typo and english mistakes, but I'm unable to edit my message again without messing the Pwan code parts
Teyut is offline
k007
BANNED
Join Date: Mar 2006
Location: bacon?
Old 11-12-2006 , 16:56   Re: Multilines kick reason
Reply With Quote #4

sweet dude
k007 is offline
Send a message via MSN to k007
Old 11-12-2006, 19:22
Da_sk8rboy
This message has been deleted by Brad. Reason: off-topic
VEN
Veteran Member
Join Date: Jan 2005
Old 11-14-2006 , 10:56   Re: Multilines kick reason
Reply With Quote #5

Correction: it's SVC_DISCONNECT, not SVC_KICK.
VEN is offline
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 11-14-2006 , 13:03   Re: Multilines kick reason
Reply With Quote #6

Is it possible to use color in the message?
__________________
Brad is offline
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 12-08-2006 , 00:11   Re: Multilines kick reason
Reply With Quote #7

My testing indicates that you can not use color in the message.
__________________
Brad is offline
evilworm
Junior Member
Join Date: Apr 2008
Old 02-28-2009 , 19:06   Re: Multilines kick reason
Reply With Quote #8

Sorry for bringing up old topics, but I think this belongs here...

I'm using this kick method to kick players from the server after they have failed the admin-check in the client_authorized() function and there are no free slots, however it sometimes fails and crashes server with this message (totally random... sometimes crashes 3 times in 10 minutes, sometimes can go on for 3-4 mapchanges):

Quote:
L 03/01/2009 - 01:29:53: FATAL ERROR (shutting down): MSG_ONE or MSG_ONE_UNRELIABLE with no target entity

FATAL ERROR (shutting down): MSG_ONE or MSG_ONE_UNRELIABLE with no target entity

Add "-debug" to the ./hlds_run command line to generate a debug.log to help with solving this problem
Sun Mar 1 01:29:53 EET 2009: Server restart in 10 seconds
I'm using the loopback method by register_clcmd(g_cmdSignal, "ackSignal") and then issuign Kick_ML. The function is_user_connected() always returns false, but is_user_connecting() - true. So the question is - how can I know if I can send message to the player with message_begin() if the player shows up as not connected? I also tried to check player with (pev(id,pev_flags) & FL_CLIENT), but it returns false, so it's useless.

Help would be appreciated!
evilworm is offline
Teyut
Junior Member
Join Date: Nov 2006
Location: Somewhere between Mars a
Old 02-28-2009 , 23:40   Re: Multilines kick reason
Reply With Quote #9

Quote:
Originally Posted by evilworm View Post
Quote:
FATAL ERROR (shutting down): MSG_ONE or MSG_ONE_UNRELIABLE with no target entity
[...]
So the question is - how can I know if I can send message to the player with message_begin() if the player shows up as not connected?
From what I understand reading the AMXX/HLSDK source code, such crashes happen when the last parameter (player entity) of the MESSAGE_BEGIN macro is NULL. The AMXX core doesn't check for such a case before calling that macro (the result of INDEXENT should be checked before use in unicast messages)

I've fixed that bug in the kick_ML() method (see above) calling the is_valid_ent() method (engine module) before doing anything. If the kick can't work, the method will return 0. Note however that is_valid_ent() does almost the same things as is_user_connected(), so it may not really help you, but at least, it should fix that server crash (I haven't test the code actually).

If you really want to kick players that are connecting but are not yet connected, you'll need to find a way to retrieve the result of the HL engine method pfnPEntityOfEntIndex: if it's non-zero, then you may kick the player. But I haven't find an AMXX module which provides a direct access to that method.

Quote:
Originally Posted by VEN View Post
Correction: it's SVC_DISCONNECT, not SVC_KICK.
Fixed, thanks. I didn't know where to find the correct names.

Quote:
Originally Posted by Brad View Post
My testing indicates that you can not use color in the message.
Sorry about my lack of answer You were right: it's not possible (I guess it is with Source).

Last edited by Teyut; 03-01-2009 at 00:11.
Teyut is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-01-2009 , 03:14   Re: Multilines kick reason
Reply With Quote #10

Quote:
Originally Posted by Teyut View Post
Fixed, thanks. I didn't know where to find the correct names.
Quote:
Originally Posted by message_const.inc
/* Hardcoded message types for message_begin()
* Look in the actual HLSDK for details!
*/
#define SVC_NOP 1
#define SVC_DISCONNECT 2
#define SVC_EVENT 3
#define SVC_VERSION 4
#define SVC_SETVIEW 5
#define SVC_SOUND 6
#define SVC_TIME 7
#define SVC_PRINT 8
#define SVC_STUFFTEXT 9
#define SVC_SETANGLE 10
#define SVC_SERVERINFO 11
#define SVC_LIGHTSTYLE 12
#define SVC_UPDATEUSERINFO 13
#define SVC_DELTADESCRIPTION 14
#define SVC_CLIENTDATA 15
#define SVC_STOPSOUND 16
#define SVC_PINGS 17
#define SVC_PARTICLE 18
#define SVC_DAMAGE 19
#define SVC_SPAWNSTATIC 20
#define SVC_EVENT_RELIABLE 21
#define SVC_SPAWNBASELINE 22
#define SVC_TEMPENTITY 23
#define SVC_SETPAUSE 24
#define SVC_SIGNONNUM 25
#define SVC_CENTERPRINT 26
#define SVC_KILLEDMONSTER 27
#define SVC_FOUNDSECRET 28
#define SVC_SPAWNSTATICSOUND 29
#define SVC_INTERMISSION 30
#define SVC_FINALE 31
#define SVC_CDTRACK 32
#define SVC_RESTORE 33
#define SVC_CUTSCENE 34
#define SVC_WEAPONANIM 35
#define SVC_DECALNAME 36
#define SVC_ROOMTYPE 37
#define SVC_ADDANGLE 38
#define SVC_NEWUSERMSG 39
#define SVC_PACKETENTITIES 40
#define SVC_DELTAPACKETENTITIES 41
#define SVC_CHOKE 42
#define SVC_RESOURCELIST 43
#define SVC_NEWMOVEVARS 44
#define SVC_RESOURCEREQUEST 45
#define SVC_CUSTOMIZATION 46
#define SVC_CROSSHAIRANGLE 47
#define SVC_SOUNDFADE 48
#define SVC_FILETXFERFAILED 49
#define SVC_HLTV 50
#define SVC_DIRECTOR 51
#define SVC_VOICEINIT 52
#define SVC_VOICEDATA 53
#define SVC_SENDEXTRAINFO 54
#define SVC_TIMESCALE 55
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Reply


Thread Tools
Display Modes

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 11:18.


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