AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [question] print_chat messages (https://forums.alliedmods.net/showthread.php?t=85294)

darkman488 02-08-2009 09:42

[question] print_chat messages
 
Hello! :wink: I've got one question, is there any way to recive/get messages printed by other plugin with print_chat? I didn't found any topic about this, so I write new one, but if it exist - sorry, I didn't know how to type great keyword for this. Waitin 4 respond :mrgreen: +karma for useful posts.

ConnorMcLeod 02-08-2009 09:55

Re: [question] print_chat messages
 
If you code yourself the plugin and use emessage, yes.

You can use this :
It supports default game message, for example :

ClientPrint(iKiller, print_center, "#Killed_Teammate") // print center : You have killed a teamate

or

ClientPrint(id, print_chat, "#Game_teammate_attack", szName)
// print in chat : "Name attacked a teamate"


Doesn't format strings as client_print does, for example you can do :

client_print(id, print_chat, "Your id is %d", id)
%d will be replaced with id value
You can't do it with ClientPrint
I could make another fonction for it, or change some code in the existing function, i just had this one ready, so i give it to you.

PHP Code:

ClientPrint(idprint_typeszText[], szSubMsg1[] = 0szSubMsg2[] = 0szSubMsg3[] = 0szSubMsg4[] = 0)
{
    new 
MSG_DEST = (id MSG_ONE MSG_ALL)
    
emessage_begin(MSG_DESTget_user_msgid("TextMsg"), _id)
    
ewrite_byte(print_type)
    
ewrite_string(szText)
    if( 
szSubMsg1[0] )
    {
        
ewrite_string(szSubMsg1)
        if( 
szSubMsg2[0] )
        {
            
ewrite_string(szSubMsg2)
            if( 
szSubMsg3[0] )
            {
                
ewrite_string(szSubMsg3)
                if( 
szSubMsg4[0] )
                {
                    
ewrite_string(szSubMsg4)
                }
            }
        }
    }
    
emessage_end()


(Replace get_user_msgid("TextMsg") with a globale var )


Then, to catch it in another plugin, just register the event TextMsg :

register_event("TextMsg", "Event_TextMsg", "b" /* or "a" */)


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

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