Raised This Month: $ Target: $400
 0% 

Print multiline messages to clients console before kick


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
supergreg
Senior Member
Join Date: Jul 2007
Location: Oslo, Norway
Old 06-07-2009 , 19:11   Print multiline messages to clients console before kick
Reply With Quote #1

Hacking away at my first ever plugin. One of its functions will be to reserve slots for registered members.

So if a player connects and his steamid isn't in our database, he will be kicked with a standard message in the modal kick dialog. However, I'd like to provide users with additional explanation over several lines in their console (how to register, display their steamid and tell them to use that during registration etc), something like this:

PHP Code:
client_cmd(id"echo ^"KickedReason:^"");
client_cmd(id"echo ^"=======================================^"");
client_cmd(id"echo ^"Reason explanation of registration goes here^"");
client_cmd(id"echo ^"You will need your SteamID during registrationit is: %s^""authid);
client_cmd(id"echo ^"=======================================^"");
server_cmd("kick #%d ^"Reserved for membersCheck your console for more information^""get_user_userid(id)); 
I also tried
PHP Code:
client_print(idprint_console"Kicked! Reason:"); 
None of the above methods make messages show up in my client console, before I'm kicked, but the kick with message work fine. I am kicked as expected, but no sign of any message in my console. I suspect this might be due to the client not being fully connected yet? Currently I am running the steamid-check in client_putinserver. I have tried client_connect and client_authorized, but with the latter two I can't get any of my code to trigger at all.

I would be grateful if someone could prove a link to, or maybe write, an overview of the client join event chain. In what order are these client_* functions executed, and when do the different server+client commands and features become available+ready to be used in plugins?

Oh, and I tried searching for similar topics/issues but had little luck, so if there are other threads explaining what I'm missing here, please do post links. Thanks a bunch
supergreg is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-07-2009 , 20:00   Re: Print multiline messages to clients console before kick
Reply With Quote #2

Best way is to just test them all. Print something on every client_* and see which prints. You can do this for order by using server_print but there are at least two events that are not guarunteed to happen in any certain order as far as I understand.
__________________
fysiks is offline
supergreg
Senior Member
Join Date: Jul 2007
Location: Oslo, Norway
Old 06-07-2009 , 21:27   Re: Print multiline messages to clients console before kick
Reply With Quote #3

Thanks, here are the results of my testing, which leaves me just as clueless. Test-plugin attached. Am I doing something really wrong? I am a total newbie so I may very well be overlooking the obvious..

Server console:
Code:
_______________ server_print from plugin_init _________________
L 06/08/2009 - 03:18:26: "Player<1><STEAM_0:1:12468><>" connected, address "80.11.22.33:27005"
L 06/08/2009 - 03:18:27: "Player<1><STEAM_0:1:12468><>" STEAM USERID validated
_______________ server_print from client_putinserver _________________
_______________ server_print from client_infochanged _________________
_______________ server_print from client_infochanged _________________
L 06/08/2009 - 03:18:31: "Player<1><STEAM_0:1:12468><>" entered the game
L 06/08/2009 - 03:18:39: "Player<1><STEAM_0:1:12468><>" joined team "CT"
_______________ server_print from client_infochanged _________________
_______________ server_print from plugin_end _________________
Client console:
Code:
----------------- client_print from client_infochanged ------------
Player connected
----------------- client_print from client_infochanged ------------
********** client_cmd echo from client_infochanged *******
********** client_cmd echo from client_infochanged *******
Player is joining the Counter-Terrorist force
----------------- client_print from client_infochanged ------------
Scoring will not start until both teams have players
********** client_cmd echo from client_infochanged
So none of the tests work, I cannot find any method to print to client console. I never saw the _changeteam() nor _spawn() method triggered. I can use client_infochanged() but I'm afraid of doing unnecessary double/triple checks as my plugin will rename clients nicks quite often, and I really dont want to query the db each time the client chooses to change something.

I tried on different servers, out of about 40 attempts there was 1 single time where I saw the following in my client console. This was early on before I added the server_print()s, and haven't been able to replicate.
Code:
********** client_cmd echo from client_connect *******
********** client_cmd echo from client_authorized *******
Attached Files
File Type: sma Get Plugin or Get Source (event-test.sma - 860 views - 2.9 KB)
supergreg is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-07-2009 , 23:46   Re: Print multiline messages to clients console before kick
Reply With Quote #4

I would not check "is_user_connected(id)". I would server print and include the result of is_user_connected.

Also, client_changeteam and client_spawn are only for NS (Natural Selection).

About your last statement:
I think that if you are checking is_user_connected() it will return one result most of the time and the other rarely or something of that nature.

Admin Reservations in amxmodx use client_authorized to kick clients.

Also, as an alternative to using console print you can use this but as I read from the thread it can't be too much text.
__________________

Last edited by fysiks; 06-08-2009 at 00:03.
fysiks is offline
supergreg
Senior Member
Join Date: Jul 2007
Location: Oslo, Norway
Old 06-08-2009 , 21:05   Re: Print multiline messages to clients console before kick
Reply With Quote #5

Thanks for helping.

Good points, I implemented those changes but am still at a loss. I found the thread you are referring to before I made this thread - the big difference (IMO) is providing the user with his Steamid in console from where he can copy it directly. It makes it all the more user friendly.

Are there any reasons I should avoid solving this by moving the entire block of client_cmd's + kick into a separate function and call it like ~10 seconds delayed using set_task?
supergreg is offline
stupok
Veteran Member
Join Date: Feb 2006
Old 06-08-2009 , 21:25   Re: Print multiline messages to clients console before kick
Reply With Quote #6

Client console:
Code:
BUILD 4554 SERVER (0 CRC)
Server # 4
stupok connected
* Privileges set 

BUILD 4554 SERVER (0 CRC)
Server # 5
* iCount: 84 forward_PreThink(1) Time: 8.437127
* iCount: 85 forward_PreThink(1) Time: 8.453126
* iCount: 86 forward_PreThink(1) Time: 8.464129
* iCount: 87 forward_PreThink(1) Time: 8.480129
* iCount: 88 forward_PreThink(1) Time: 8.496129
* iCount: 89 forward_PreThink(1) Time: 8.513206
* iCount: 90 forward_PreThink(1) Time: 8.529206
* iCount: 91 forward_PreThink(1) Time: 8.547128
* iCount: 92 forward_PreThink(1) Time: 8.563128
stupok is joining the Terrorist force
* iCount: 93 forward_PreThink(1) Time: 8.578135
* iCount: 94 forward_PreThink(1) Time: 8.595135
* iCount: 95 forward_PreThink(1) Time: 8.622122
* iCount: 96 forward_PreThink(1) Time: 8.637122
* iCount: 97 forward_PreThink(1) Time: 8.653122
* iCount: 98 forward_PreThink(1) Time: 8.664102
* iCount: 99 forward_PreThink(1) Time: 8.680102
* iCount: 100 forward_PreThink(1) Time: 8.696102
* iCount: 101 forward_PreThink(1) Time: 8.721202
* iCount: 102 forward_PreThink(1) Time: 8.737202
* iCount: 103 forward_PreThink(1) Time: 8.754202
* iCount: 104 forward_PreThink(1) Time: 8.764178
* iCount: 105 forward_PreThink(1) Time: 8.780178
* iCount: 106 forward_PreThink(1) Time: 8.796177
* iCount: 107 forward_PreThink(1) Time: 8.813157
* iCount: 108 forward_PreThink(1) Time: 8.829157
* iCount: 109 forward_PreThink(1) Time: 8.855161
* iCount: 110 forward_PreThink(1) Time: 8.870162
* iCount: 111 forward_PreThink(1) Time: 8.886161
* iCount: 112 forward_PreThink(1) Time: 8.897140
* iCount: 113 forward_PreThink(1) Time: 8.913141
* iCount: 114 forward_PreThink(1) Time: 8.929141
* iCount: 115 forward_PreThink(1) Time: 8.946115
* iCount: 116 forward_PreThink(1) Time: 8.962116
Scoring will not start until both teams have players
* iCount: 117 forward_PreThink(1) Time: 8.978266
* iCount: 118 forward_PreThink(1) Time: 8.995266
* iCount: 119 forward_PreThink(1) Time: 9.010989
* iCount: 120 forward_PreThink(1) Time: 9.025989
* iCount: 121 forward_PreThink(1) Time: 9.041989
* iCount: 122 forward_PreThink(1) Time: 9.063133
* iCount: 123 forward_PreThink(1) Time: 9.079133
* iCount: 124 forward_PreThink(1) Time: 9.095133
* iCount: 125 forward_PreThink(1) Time: 9.120123
* iCount: 126 forward_PreThink(1) Time: 9.136123
* iCount: 127 forward_PreThink(1) Time: 9.152123
* iCount: 128 forward_PreThink(1) Time: 9.171140
* iCount: 129 forward_PreThink(1) Time: 9.187140
* iCount: 130 forward_PreThink(1) Time: 9.197174
* iCount: 131 forward_PreThink(1) Time: 9.213173
* iCount: 132 forward_PreThink(1) Time: 9.229173
* iCount: 133 forward_PreThink(1) Time: 9.254130
* iCount: 134 forward_PreThink(1) Time: 9.270130
* iCount: 135 forward_PreThink(1) Time: 9.286129
* iCount: 136 forward_PreThink(1) Time: 9.303148
* iCount: 137 forward_PreThink(1) Time: 9.320148
* iCount: 138 forward_PreThink(1) Time: 9.330133
* iCount: 139 forward_PreThink(1) Time: 9.346134
* iCount: 140 forward_PreThink(1) Time: 9.362133
* iCount: 141 forward_PreThink(1) Time: 9.381134
* iCount: 142 forward_PreThink(1) Time: 9.397134
* iCount: 143 forward_PreThink(1) Time: 9.413134
* iCount: 144 forward_PreThink(1) Time: 9.430134
* iCount: 145 forward_PreThink(1) Time: 9.446134
* iCount: 146 forward_PreThink(1) Time: 9.470138
* iCount: 147 forward_PreThink(1) Time: 9.486138
* iCount: 148 forward_PreThink(1) Time: 9.502138
* iCount: 149 forward_PreThink(1) Time: 9.513188
* iCount: 150 forward_PreThink(1) Time: 9.529188
* iCount: 151 forward_PreThink(1) Time: 9.545188
* iCount: 152 forward_PreThink(1) Time: 9.5701
Server console:
Code:
* client_connect(1) Time: 2.146843
L 06/08/2009 - 20:23:00: [admin.amxx] Login: "stupok<3><STEAM_0:0:1528147><>" became an admin (account "STEAM_0:0:1528147") (access "bcdefghijklmnopqrstu") (address "24.13.204.207")
* client_authorized(1) Time: 2.146843
* client_putinserver(1) Time: 6.341520
Plugin:
PHP Code:
/* Script generated by Pawn Studio */

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>

#define PLUGIN    "print test"
#define AUTHOR    "Unknown"
#define VERSION    "1.0"

new g_iPreThink

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
g_iPreThink register_forward(FM_PlayerPreThink"forward_PreThink"1)
}

public 
client_connect(id)
{
    
console_print(id"* client_connect(%i) Time: %f"idget_gametime())
    
server_print("* client_connect(%i) Time: %f"idget_gametime())
}

public 
client_authorized(id)
{
    
console_print(id"* client_authorized(%i) Time: %f"idget_gametime())
    
server_print("* client_authorized(%i) Time: %f"idget_gametime())
}

public 
client_putinserver(id)
{
    
console_print(id"* client_putinserver(%i) Time: %f"idget_gametime())
    
server_print("* client_putinserver(%i) Time: %f"idget_gametime())
}

public 
forward_PreThink(id)
{
    static 
iCount
    
if(iCount++ > 150)
        
unregister_forward(FM_PlayerPreThinkg_iPreThink1)
    
    
console_print(id"* iCount: %i forward_PreThink(%i) Time: %f"iCountidget_gametime())

__________________
stupok is offline
supergreg
Senior Member
Join Date: Jul 2007
Location: Oslo, Norway
Old 06-11-2009 , 18:40   Re: Print multiline messages to clients console before kick
Reply With Quote #7

Thank you for your response. It is a bit too complicated for me. I understand approximately what happens there, but not how I can take advantage of it.

Is a forward almost like "extending a class" in other languages? I had some questions in general about such custom "functions", made a thread for it.

From what I gather, PreThink gets called every frame? So where do I put my kick message? Or was this merely a display of the event chain?

So far I think I'll try to put the console print and kick in a separate function which is called from putinserver with 5-6 seconds delay (only way I can think of). Does that sound OK? Of course I can just test, but I'd like to get it confirmed from someone who knows what they're doing
supergreg is offline
stupok
Veteran Member
Join Date: Feb 2006
Old 06-12-2009 , 02:02   Re: Print multiline messages to clients console before kick
Reply With Quote #8

I'm just showing you a chain of events and the actual times for each event. If you delay 5-6 seconds after client_putinserver(), that should be fine. According to my test, the client begins to receive messages at ~8.4 seconds, and he is "put in server" at ~6.3 seconds.
__________________
stupok is offline
supergreg
Senior Member
Join Date: Jul 2007
Location: Oslo, Norway
Old 06-13-2009 , 20:17   Re: Print multiline messages to clients console before kick
Reply With Quote #9

Seems to be working fine, thanks a lot for helping out. I currently have a 2.5 sec delay from putinserver, it has worked every time for me and my testers so far.
supergreg is offline
Reply



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 13:47.


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