AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   suppress the message "the game will restart in x second (https://forums.alliedmods.net/showthread.php?t=6781)

mercury 10-14-2004 08:02

suppress the message "the game will restart in x second
 
HOW? )

i do amx_csay LIVE! LIVE! LIVE!
then sv_restart 3

i see hud message "LIVE! LIVE! LIVE!" for a second (but i want more) and then standard message "the game will restart in 3 seconds."

but the only thing i want to see is hud, or just won't dissapearing when "the game will restart in x seconds." displays.

Da Bishop 10-14-2004 08:07

I believe that function "will restart in x Seconds" is found in one of the stats plugins.

mercury 10-14-2004 08:32

no, it's a server's message. you can turn off ALL ADDONS and enter in sever console: sv_restart 1

and you will see that message.

DS 10-14-2004 10:49

If you want to block that message, you will need to use the engine module.

Here's how I'd do it:
Code:
#include <amxmodx> #include <engine> public plugin_init() {     register_message(get_user_msgid("TextMsg"), "hook_TextMsg") // Hook TextMsg message to function } public hook_TextMsg(msgid, msgdest, msgargs) {     new message[32]     get_msg_arg_string(2, message, 31) // Get text message         // If text message = "Game will restart in X seconds" then block the message     if (equal(message, "#Game_will_restart_in")         return PLUGIN_HANDLED // Blocks message         return PLUGIN_CONTINUE // Lets other TextMsg messages go through }

register_message basically lets you hook a function to any game messages. In this case the "game will restart in" is done by the TextMsg message. And then you can block it by returning PLUGIN_HANDLED or let a message continue by returning PLUGIN_CONTINUE. In this case I only block the TextMsg when the message is about the game restarting, otherwise it will display all other text messages such as Counter-Terrorists Win.

mercury 10-14-2004 13:49

thank you very much)

i wrote my own plugin with hud instead of poor cs's standard messages)

mercury 10-14-2004 14:45

here it is.. but it crashes the server on map change.

Code:
#include <amxmodx> #include <amxmisc> #include <engine> public hook_TextMsg(msgid, msgdest, msgargs) {     new message[32]     get_msg_arg_string(2, message, 31) // Get text message           // If text message = "Game will restart in X seconds" then block the message     if (equal(message, "#Game_will_restart_in"))         return PLUGIN_HANDLED // Blocks message           return PLUGIN_CONTINUE // Lets other TextMsg messages go through } public drestart(param[])     set_cvar_string("sv_restart",param) public admin_rr(id, level, cid) {     if (!cmd_access(id, level, cid, 3))         return PLUGIN_HANDLED     new sdelay[4], stimes[4]     read_argv(1,stimes,3)     read_argv(2,sdelay,3)     new delay = str_to_num(sdelay)     new times = str_to_num(stimes)     for(new a = times;a > 0;--a)         set_task( float(delay * a) + 1.0 , "drestart", 0, sdelay, 4)     // console_print(id,"The Game will restart %d times with a %d sec. delay between restarts",times,delay)     set_hudmessage(245, 245,245, -1.0, 0.4, 0, 4.0, 20.0, 2.0, 2.0, 1)     show_hudmessage(0,"RESTART!")     set_hudmessage(245, 10,10, -1.0, 0.43, 0, 4.0, 20.0, 2.0, 2.0, 2)     show_hudmessage(0,"LIVE! LIVE! LIVE!")     set_hudmessage(245, 10,10, -1.0, 0.46, 0, 4.0, 20.0, 2.0, 2.0, 3)     show_hudmessage(0,"GOOD LUCK, HAVE FUN!")     return PLUGIN_HANDLED } public plugin_init() {     register_plugin("Admin RestartRound","1.0.0","mercury")     register_concmd("amx_restart","admin_rr",ADMIN_LEVEL_A,"<restart times> <delay>")     register_message(get_user_msgid("TextMsg"), "hook_TextMsg") // Hook TextMsg message to function     return PLUGIN_CONTINUE }

DS 10-14-2004 17:39

Quote:

Originally Posted by mercury
here it is.. but it crashes the server on map change.

Hmm, really? What version of AMXX are you using? I'm using the latest nightly build of 0.20 and it works fine on map changes.

BAILOPAN 10-14-2004 17:40

0.16 register_message will crash the server on mapchange. Sorry :)

DS 10-14-2004 18:01

Thanks for info, Bailo.

Ok, well if that's case you can either update to 0.20 if you wish or you can try this:

Change:
Code:
register_message(get_user_msgid("TextMsg"), "hook_TextMsg") // Hook TextMsg message to function

To:
Code:
register_event("TextMsg", "event_RestartRound", "a", "2=#Game_will_restart_in")

Remove the entire function called hook_TextMsg and replace it with this:
Code:
public event_RestartRound() {     set_msg_block(get_user_msgid("TextMsg"), BLOCK_ONCE)         return PLUGIN_CONTINUE }

set_msg_block is another way to block messages. I'm just so used to using register_message that I rarely use it. But this should work in 0.16 AFAIK.

BAILOPAN 10-14-2004 20:46

Will this work?

Events are captured in Post so they've already happened...


All times are GMT -4. The time now is 17:15.

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