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

Edit plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
unscarred
Member
Join Date: Dec 2009
Location: cs 1.6
Old 06-14-2015 , 16:25   Edit plugin
Reply With Quote #1

Hi all, someone can change notice PrintToChatAll("Player \"%s\" has been killed.", to player "name" killed player "name"

PHP Code:
#include <sourcemod>

public Plugin:myinfo =
{
    
name "Death Announce",
    
author "Arcaster",
    
description "Announces the death of players.",
    
version "1.0",
    
url ""
    
};
    
forward OnPluginStart();

public 
OnPluginStart()
{
    
PrintToServer("Death Announce by Arcaster has been loaded.");
    
HookEvent("player_death"Event_PlayerDeath);
}

public 
Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    
decl String:name[64]
    new 
victim_id GetEventInt(event"userid")
    new 
victim GetClientOfUserId(victim_id)
    
GetClientName(victimnamesizeof(name))
    
    
PrintToChatAll("Player \"%s\" has been killed.",
    
name);

thanks

Last edited by unscarred; 06-14-2015 at 16:57.
unscarred is offline
versatile_bfg
Veteran Member
Join Date: Feb 2012
Old 06-15-2015 , 01:44   Re: Edit plugin
Reply With Quote #2

PHP Code:
public Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    
decl String:nameV[64];
    
decl String:nameA[64];
    new 
victim_id GetEventInt(event"userid");
    new 
victim GetClientOfUserId(victim_id);
    
GetClientName(victimnameVsizeof(nameV));
    new 
attacker_id GetEventInt(event"attacker");
    new 
attacker GetClientOfUserId(attacker_id);
    
GetClientName(attackernameAsizeof(nameA));
    
    
PrintToChatAll("Player \"%s\" killed by Player \"%s\"."nameVnameA);

__________________

Last edited by versatile_bfg; 06-15-2015 at 01:44.
versatile_bfg is offline
blaacky
Senior Member
Join Date: Oct 2012
Old 06-15-2015 , 02:59   Re: Edit plugin
Reply With Quote #3

Might have to check if attack client id isn't 0. Because the attacker can be the world which is entity #0
blaacky is offline
11530
Veteran Member
Join Date: Sep 2011
Location: Underworld
Old 06-15-2015 , 16:47   Re: Edit plugin
Reply With Quote #4

Don't forget to use %N instead of GetClientName and %s.

PHP Code:
public Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
  new 
victim GetClientOfUserId(GetEventInt(event"userid"));
  new 
attacker GetClientOfUserId(GetEventInt(event"attacker"));
  
  if (
victim <= MaxClients && attacker <= MaxClients)
  {
    
PrintToChatAll("\"%N\" was killed by \"%N\"."victimattacker);
  }

__________________
11530 is offline
unscarred
Member
Join Date: Dec 2009
Location: cs 1.6
Old 06-15-2015 , 19:17   Re: Edit plugin
Reply With Quote #5

cant compile

/groups/sourcemod/compiler-1.7/include/sourcemod.inc(101) : error 025: function heading differs from prototype
/home/groups/sourcemod/upload_tmp/phpt6ARtA.sp(12) : error 025: function heading differs from prototype
unscarred is offline
11530
Veteran Member
Join Date: Sep 2011
Location: Underworld
Old 06-15-2015 , 20:18   Re: Edit plugin
Reply With Quote #6

Quote:
Originally Posted by unscarred View Post
cant compile

/groups/sourcemod/compiler-1.7/include/sourcemod.inc(101) : error 025: function heading differs from prototype
/home/groups/sourcemod/upload_tmp/phpt6ARtA.sp(12) : error 025: function heading differs from prototype
Remove forward OnPluginStart(); in your first post.
__________________

Last edited by 11530; 06-15-2015 at 20:20.
11530 is offline
versatile_bfg
Veteran Member
Join Date: Feb 2012
Old 06-15-2015 , 21:10   Re: Edit plugin
Reply With Quote #7

Ah forgot about world Only quickly put it together.

Would also need to check that the attacker isn't the victim as then it would print Bob was killed by Bob. Which is acceptable but wouldn't it be better to have Bob killed himself or Bob suicided.

PHP Code:
public Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
victim GetClientOfUserId(GetEventInt(event"userid"));
    new 
attacker GetClientOfUserId(GetEventInt(event"attacker"));
    
    if (
victim <= MaxClients && attacker <= MaxClients)
    {
        if (
victim == attacker)
        {
            
PrintToChatAll("\"%N\" suicided."victim);
        }
        else
        {
            
PrintToChatAll("\"%N\" was killed by \"%N\"."victimattacker);
        }
    }

__________________

Last edited by versatile_bfg; 06-15-2015 at 21:12.
versatile_bfg is offline
unscarred
Member
Join Date: Dec 2009
Location: cs 1.6
Old 06-16-2015 , 19:22   Re: Edit plugin
Reply With Quote #8

thank u guys !!
unscarred is offline
Reply


Thread Tools
Display Modes

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 07:57.


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