AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   hook TextMsg, SayText (https://forums.alliedmods.net/showthread.php?t=187733)

hyphen 06-17-2012 06:26

hook TextMsg, SayText
 
Below is a code snippet to block "Fire in the hole" message display from all players. Can you guys clear me out the followings:

MsgTextMsg(msgid, dest, id) - params are not being used in the function, so its not required, not sure
get_msg_args() != 5 - why checking 5 arguments to be returned
get_msg_arg_string(5, arg, sizeof arg - 1) - why getting the 5th argument
new caller = str_to_num(arg) - why message argument is converted to number and used as id.

PHP Code:

public plugin_init()
{
        
register_message(get_user_msgid("TextMsg"), "MsgTextMsg")
}

public 
MsgTextMsg(msgiddestid)
{
    if (
get_msg_args() != || get_msg_argtype(5) != ARG_STRING)
        return 
PLUGIN_CONTINUE
    
    
static arg[32]
    
get_msg_arg_string(5argsizeof arg 1)

    if (!
equal(arg"#Fire_in_the_hole"))
        return 
PLUGIN_CONTINUE
    
    get_msg_arg_string
(5argsizeof arg 1//if argument no is 2 is it possible to read the caller ?
    
new caller str_to_num(arg)
    if (!
is_user_alive(caller))
        return 
PLUGIN_CONTINUE
    
    
return PLUGIN_HANDLED



hleV 06-17-2012 06:34

Re: hook TextMsg, SayText
 
  1. Yes, it's not required to define those parameters if you aren't using them.
  2. It's possible for TextMsg to not have 5 arguments. In this certain case we need there to be 5.
  3. In this case the 5th argument has the string which we need to check. If it's "#Fire_in_the_hole" or not.
  4. It's some sort of a mistake.

hyphen 06-17-2012 07:29

Re: hook TextMsg, SayText
 
Okay.

may I know what is the difference between SayText & TextMsg. What I found: to block #Fire_in_the_hole I need to hook TextMsg and for blocking #Cstrike_Name_Change use SayText. How to understand which message comes under what category.

hyphen 06-17-2012 08:16

Re: hook TextMsg, SayText
 
Tested the above code with some non-steam cs ver (not supporting non-steam, just tested) where "Fire in the hole" prints like:
Player @ CTSpawn (RADIO): Fire in the hole and didn't work. but with normal steam cs its working correctly because there it is only (RADIO): Fire in the hole. Is thise because of argument number matching ?

<VeCo> 06-17-2012 08:22

Re: hook TextMsg, SayText
 
Quote:

Originally Posted by hyphen (Post 1730412)
Tested the above code with some non-steam cs ver (not supporting non-steam, just tested) where "Fire in the hole" prints like:
Player @ CTSpawn (RADIO): Fire in the hole and didn't work. but with normal steam cs its working correctly because there it is only (RADIO): Fire in the hole. Is thise because of argument number matching ?

Non-Steam is shit. Who cares about it?

hyphen 06-17-2012 08:24

Re: hook TextMsg, SayText
 
Just want to know the concept how it works.

n0br41ner 06-17-2012 10:22

Re: hook TextMsg, SayText
 
Player @ CTSpawn (RADIO): Fire in the hole
This message is because the non steam version your using has some sort of bots addon (probably zbot) that's why the location is shown.

Also if you see this message:
(RADIO): Fire in the hole.
It has five arguments
1: (RADIO):
2: Fire
3: in
4: the
5: hole.

But this message:
Player @ CTSpawn (RADIO): Fire in the hole
has 7 or 8 parameters

I am not sure about this, but it could be :D

ConnorMcLeod 06-17-2012 10:38

Re: hook TextMsg, SayText
 
Quote:

Originally Posted by n0br41ner (Post 1730466)
Player @ CTSpawn (RADIO): Fire in the hole
This message is because the non steam version your using has some sort of bots addon (probably zbot) that's why the location is shown.

Also if you see this message:
(RADIO): Fire in the hole.
It has five arguments
1: (RADIO):
2: Fire
3: in
4: the
5: hole.

But this message:
Player @ CTSpawn (RADIO): Fire in the hole
has 7 or 8 parameters

I am not sure about this, but it could be :D

BULLSHIT

n0br41ner 06-17-2012 10:43

Re: hook TextMsg, SayText
 
Quote:

Originally Posted by n0br41ner
I am not sure about this, but it could be

:O im hurt :(
haha

bibu 06-17-2012 11:04

Re: hook TextMsg, SayText
 
He is right. AFAIK some non-steam version of 1.6 have also locations in the nav file.


All times are GMT -4. The time now is 06:07.

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