AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Edit plugin (https://forums.alliedmods.net/showthread.php?t=264356)

unscarred 06-14-2015 16:25

Edit plugin
 
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

versatile_bfg 06-15-2015 01:44

Re: Edit plugin
 
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);



blaacky 06-15-2015 02:59

Re: Edit plugin
 
Might have to check if attack client id isn't 0. Because the attacker can be the world which is entity #0

11530 06-15-2015 16:47

Re: Edit plugin
 
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);
  }



unscarred 06-15-2015 19:17

Re: Edit plugin
 
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

11530 06-15-2015 20:18

Re: Edit plugin
 
Quote:

Originally Posted by unscarred (Post 2308301)
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.

versatile_bfg 06-15-2015 21:10

Re: Edit plugin
 
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);
        }
    }



unscarred 06-16-2015 19:22

Re: Edit plugin
 
thank u guys !!


All times are GMT -4. The time now is 01:55.

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