Raised This Month: $12 Target: $400
 3% 

Showing Team Attacks in Chat


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
nerevye
Junior Member
Join Date: Mar 2011
Old 07-09-2011 , 03:55   Showing Team Attacks in Chat
Reply With Quote #1

Hey folks,

I am currently searching for an option showing ALL team attacks to all players on a server and not just to the own team. Did I just miss a normal cvar? Or is it possible to get this behaviour with SourceMod / an SM plugin?

Cheers,
nerevye
nerevye is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 07-09-2011 , 09:22   Re: Showing Team Attacks in Chat
Reply With Quote #2

http://www.sourcemod.net/compiler.php

PHP Code:
public Plugin:myinfo = {
    
name "Print to chat all team attacker",
    
author "Bacardi",
    
description "Show rest of all players team attacker in chat",
    
version "0.1",
    
url "https://forums.alliedmods.net/showthread.php?t=161597"
};

public 
OnPluginStart()
{
    
HookEvent("player_hurt"player_hurt);
}

public 
player_hurt(Handle:event, const String:name[], bool:dontBroadcast)
{
    
decl attackervictimteam;
    
attacker GetClientOfUserId(GetEventInt(event"attacker"));
    
victim GetClientOfUserId(GetEventInt(event"userid"));


    if(
attacker && attacker != victim && (team GetClientTeam(attacker)) == GetClientTeam(victim))
    {
        for(new 
1<= MaxClientsi++)
        {
            if(
IsClientInGame(i) && GetClientTeam(i) != team)
            {
                
PrintToChat(i"%N attacked a teammate"attacker);
            }
        }
    }

This print to rest of all players in chat team attacker.

*edit
filter suicide out

Last edited by Bacardi; 07-10-2011 at 09:29. Reason: PritnTOServer out...
Bacardi is offline
nerevye
Junior Member
Join Date: Mar 2011
Old 07-12-2011 , 14:28   Re: Showing Team Attacks in Chat
Reply With Quote #3

Hello Bacardi,

thank you very very much for your code! I'm going to test it this evening...

Cheers,
nerevye
nerevye is offline
nerevye
Junior Member
Join Date: Mar 2011
Old 07-12-2011 , 16:50   Re: Showing Team Attacks in Chat
Reply With Quote #4

It works great! Big THX
nerevye is offline
ASTFA
Member
Join Date: Jun 2011
Old 11-02-2011 , 07:19   Re: Showing Team Attacks in Chat
Reply With Quote #5

As always, thank you Bacardiii
__________________

ASTFA is offline
Brooke
New Member
Join Date: May 2011
Old 11-02-2011 , 10:15   Re: Showing Team Attacks in Chat
Reply With Quote #6

Thank you very much Bacardi you give a good answer to the question and i really like your answer.
__________________
Brooke is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 11-02-2011 , 16:36   Re: Showing Team Attacks in Chat
Reply With Quote #7

Maybe this is better version, not spam too much team attack message.
PHP Code:
public Plugin:myinfo = {
    
name "Print to chat all team attacker",
    
author "Bacardi",
    
description "Show all players team attacker in chat",
    
version "0.2",
    
url "https://forums.alliedmods.net/showthread.php?t=161597"
};

public 
OnPluginStart()
{
    
HookUserMessage(GetUserMessageId("TextMsg"), TextMsgtrue);
}

public 
Action:TextMsg(UserMsg:msg_idHandle:bf, const players[], playersNumbool:reliablebool:init)
{
    
decl String:buffer[MAX_NAME_LENGTH];
    
buffer[0] = '\0';
    
BfReadString(bfbuffersizeof(buffer), false); // Message

    
if(StrContains(buffer"Game_teammate_attack") != -1// Message match
    
{
        
BfReadString(bfbuffersizeof(buffer), false); // Get name

        
decl String:name[MAX_NAME_LENGTH];
        
GetClientName(players[0], namesizeof(name));

        if(
StrEqual(buffername)) // Team attacker name match player name who get this message.
        
{
            new 
Handle:pack;
            
CreateDataTimer(0.1msgpack); // Need print new message after this usermessage
            
WritePackCell(packplayers[0]);
        }
        return 
Plugin_Handled// Stop show message
    
}

    return 
Plugin_Continue;
}

public 
Action:msg(Handle:timerHandle:pack)
{
    
decl clientString:buffer[128];
    
ResetPack(pack);
    
client ReadPackCell(pack);

    
Format(buffersizeof(buffer), "\01[SM] \x03%N \x01attacked a teammate"client);

    new 
Handle:hBf;
    
hBf StartMessageAll("SayText2");
    if (
hBf != INVALID_HANDLE)
    {
        
BfWriteByte(hBfclient);
        
BfWriteByte(hBf0);
        
BfWriteString(hBfbuffer);
        
EndMessage();
    }

__________________
Do not Private Message @me
Bacardi is offline
ASTFA
Member
Join Date: Jun 2011
Old 11-04-2011 , 03:47   Re: Showing Team Attacks in Chat
Reply With Quote #8

Quote:
Originally Posted by Bacardi View Post
Maybe this is better version, not spam too much team attack message.
PHP Code:
public Plugin:myinfo = {
    
name "Print to chat all team attacker",
    
author "Bacardi",
    
description "Show all players team attacker in chat",
    
version "0.2",
    
url "https://forums.alliedmods.net/showthread.php?t=161597"
};

public 
OnPluginStart()
{
    
HookUserMessage(GetUserMessageId("TextMsg"), TextMsgtrue);
}

public 
Action:TextMsg(UserMsg:msg_idHandle:bf, const players[], playersNumbool:reliablebool:init)
{
    
decl String:buffer[MAX_NAME_LENGTH];
    
buffer[0] = '\0';
    
BfReadString(bfbuffersizeof(buffer), false); // Message

    
if(StrContains(buffer"Game_teammate_attack") != -1// Message match
    
{
        
BfReadString(bfbuffersizeof(buffer), false); // Get name

        
decl String:name[MAX_NAME_LENGTH];
        
GetClientName(players[0], namesizeof(name));

        if(
StrEqual(buffername)) // Team attacker name match player name who get this message.
        
{
            new 
Handle:pack;
            
CreateDataTimer(0.1msgpack); // Need print new message after this usermessage
            
WritePackCell(packplayers[0]);
        }
        return 
Plugin_Handled// Stop show message
    
}

    return 
Plugin_Continue;
}

public 
Action:msg(Handle:timerHandle:pack)
{
    
decl clientString:buffer[128];
    
ResetPack(pack);
    
client ReadPackCell(pack);

    
Format(buffersizeof(buffer), "\01[SM] \x03%N \x01attacked a teammate"client);

    new 
Handle:hBf;
    
hBf StartMessageAll("SayText2");
    if (
hBf != INVALID_HANDLE)
    {
        
BfWriteByte(hBfclient);
        
BfWriteByte(hBf0);
        
BfWriteString(hBfbuffer);
        
EndMessage();
    }

So if I were to make it show which team the team attack occurred on, how would you code it?

E.g.

if FF occurred on my team:

xxx attacked a teammate

( ^ which is default)

if FF occurred on the other team:

(CT) xxx attacked a teammate

or

(T) xxx attacked a teammate
__________________

ASTFA is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 11-04-2011 , 05:17   Re: Showing Team Attacks in Chat
Reply With Quote #9

Quote:
Originally Posted by ASTFA View Post
So if I were to make it show which team the team attack occurred on, how would you code it?

E.g.

if FF occurred on my team:

xxx attacked a teammate

( ^ which is default)

if FF occurred on the other team:

(CT) xxx attacked a teammate

or

(T) xxx attacked a teammate
I released plugin with translations. [Cs:s]Teammate attack show all
You get team color in chat announce (red, blue and maybe white if player join quicly in spec)

*ps
post #7 works same way, team colors
__________________
Do not Private Message @me

Last edited by Bacardi; 11-04-2011 at 05:19.
Bacardi is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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