View Single Post
honorcode23
BANNED
Join Date: Mar 2010
Location: Chile
Old 02-10-2011 , 09:57   Re: [L4d2] Request: Remove kill messages
Reply With Quote #16

Compile this:

PHP Code:
#include <sourcemod>

public OnPluginStart()
{
    new 
UserMsg:MsgMessage GetUserMessageId("PZDmgMsg");
    
HookUserMessage(MsgMessageOnPZDmgMsgtrue);
}

//Fires anytime a kill, protect, heal, damage x5 message is called (i Guess)
public Action:OnPZDmgMsg(UserMsg:msg_idHandle:bf, const players[], playersNumbool:reliablebool:init)
{
    
//Read Message
    
new iMsgType BfReadByte(bf); //This is the message type id: 12 = Pounce Damage 9 = <player> hit <player> x2 message
    
new iAttackerUserId BfReadShort(bf); //Userid of the attacker or the healer, etc.
    
new iVictimUserId BfReadShort(bf); //Userid of the victim / target
    
BfReadShort(bf); //Unknown
    
new iDamage BfReadShort(bf); //Damage done.
    
    //Print the info to server, uncomment to check
    
PrintToServer("PZDmg Sent: T:%i | A:%i | V:%i | D:%i"iMsgTypeiAttackerUserIdiVictimUserIdiDamage);

    return 
Plugin_Continue;

Ok now, every time that kind of messages of friendly-fire, damage x4, <player> killed <player> the message PZDmg is sent. The message can be blocked using return Plugin_Handled. However, if you block this message directly, absolutelly nothing will be sent to players and all messages (linked to this) will be blocked. You only need to block 3 type of messages, so, go to your empty server, check the server console and start doing friendly fire, or kill someone.

The server will print, for example, something like this:

Code:
PZDemg Sent: T:12 | A:1 | V:3 | D:0
"T" would be the message id, this is what you want to block the specific message. When you obtain this value, add the following code you the previous one, remove the "PrintToServer" line and everyone is happy. Suppose the id is 8:

Code:
if(iMsgType == 8)
{
         return Plugin_Handled;
}
Thats all. If you dont understand i cant really help you anymore, i dont have the time to get all the message ids.
honorcode23 is offline