AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Blocking messages (https://forums.alliedmods.net/showthread.php?t=24349)

v3x 02-19-2006 19:36

Blocking messages
 
I'm trying to block a message but it doesn't seem to be working:
Code:
register_message(get_user_msgid("TextMsg") , "block_message");
Code:
public block_message(msg_id , msg_dest , msg_ent) {     new const count = get_msg_args();     for(new i = 0; i < count; i++) {         if(get_msg_argtype(i) == ARG_STRING) {             new value[64];             get_msg_arg_string(i , value , 63);             if(equal(value , "#Cannot_Carry_Anymore")) {                 return PLUGIN_HANDLED;             }         }     }     return PLUGIN_CONTINUE; }
A solution would be appreciated. Thanks

Petey B 02-19-2006 19:56

this is just a guess but cant u have only one center_print message at once. so when u give a client a grenade just do a center_print message with " ". that should replace the one in the centre of the screen so it appears blank

v3x 02-19-2006 20:26

Yeah, that's what I had planned originally. I just want to know why that code doesn't work ( for future reference ).

GHW_Chronic 02-19-2006 20:44

Quote:

Originally Posted by v3x
( for future reference ).

for future reference use print_center

lol jk

BAILOPAN 02-19-2006 21:33

are you sure that the PLUGIN_HANDLED is being hit?

v3x 02-19-2006 21:55

Code:
public block_message(msg_id , msg_dest , msg_ent) {     new const count = get_msg_args();     for(new i = 0; i < count; i++) {         if(get_msg_argtype(i) == ARG_STRING) {             new value[64];             get_msg_arg_string(i , value , 63);             if(equal(value , "#Cannot_Carry_Anymore")) {                 log_amx("Nade message reached and blocked");                 return PLUGIN_HANDLED;             }         }     }     return PLUGIN_CONTINUE; }
Nothing in the logs so I guess not. Anyone know what's wrong?

Brad 02-19-2006 21:58

Yikes! Take your variable declaration out of the loop.

GHW_Chronic 02-19-2006 21:59

Code:
public block_message(msg_id , msg_dest , msg_ent) {     new const count = get_msg_args();     for(new i = 0; i < count; i++) {         if(get_msg_argtype(i) == ARG_STRING) {             new value[64];             get_msg_arg_string(i , value , 63);             client_print(0,print_chat,"%s",value)             if(equal(value , "#Cannot_Carry_Anymore")) {                 return PLUGIN_HANDLED;             }         }     }     return PLUGIN_CONTINUE; }

See if the value matches #Cannot_Carry_Anymore.

Brad 02-19-2006 22:00

Along the same train of thought, print out the arg count and arg type values so that you know you're receiving what you're expecting.

v3x 02-19-2006 22:16

Hmm, I can't seem to reproduce this message... :?

Edit: Started logging of TextMsg with DS's plugin and got this:
Quote:

L 02/19/2006 - 22:20:28: [msglogging.amxx] MessageBegin TextMsg(77) Arguments=2 Destination=One(1) Origin={0.000000 0.000000 0.000000} Entity=1 Classname=player Netname=ghw L 3 n N ! N G z ^ ^
L 02/19/2006 - 22:20:28: [msglogging.amxx] Arg 1 (Byte): 4
L 02/19/2006 - 22:20:28: [msglogging.amxx] Arg 2 (String): #Cannot_Carry_Anymore
L 02/19/2006 - 22:20:28: [msglogging.amxx] MessageEnd TextMsg(77)
But it only does it for him (he's the only admin on if that matters). I think that may be a bug within DS's plugin.

Quote:

Originally Posted by On round start a few times
amx_exec @ALL hegren

Current code:
Code:
public block_message(msg_id , msg_dest , msg_ent) {     new const count = get_msg_args();     for(new i = 0; i < count; i++) {         if(get_msg_argtype(i) == ARG_STRING) {             new value[64];             get_msg_arg_string(i , value , 63);             log_amx("[%i] Message string: %s | Arg count: %i" , i , value , count);             if(equal(value , "#Cannot_Carry_Anymore")) {                 log_amx("Nade message reached and blocked");                 return PLUGIN_HANDLED;             }         }     }     return PLUGIN_CONTINUE; }
:|


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

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