Raised This Month: $ Target: $400
 0% 

message appears when the player is killed


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
alfredo
Junior Member
Join Date: Feb 2014
Location: indonesia
Old 04-12-2014 , 22:55   message appears when the player is killed
Reply With Quote #1

everything is there who can help me. if a player is killed will display a message !!
alfredo is offline
Old 04-13-2014, 00:02
NikKOo31
This message has been deleted by hornet. Reason: This is the requests section. Please do not post half plugins.
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 04-13-2014 , 15:26   Re: message appears when the player is killed
Reply With Quote #2

What kind of message do you want? Chat message, or HUD? And, what to be the text of the message, maybe some colors?
Flick3rR is offline
Send a message via Skype™ to Flick3rR
Buckshot
Senior Member
Join Date: Mar 2014
Location: Sweden
Old 04-13-2014 , 17:42   Re: message appears when the player is killed
Reply With Quote #3

PHP Code:
#include < amxmodx > 
#include < hamsandwich >

public plugin_init( ) {
    
register_plugin"Death Message""1.0""BuckShot" )
    
RegisterHamHam_Killed"player""Fwd_Ham_Killed_Post")
}

public 
Fwd_Ham_Killed_PostiVictimiAttacker ) {
    new 
szAttackername32 ]
    new 
szVictimname32 ]
    
get_user_nameiAttackerszAttackernamecharsmaxszAttackername ) )
    
get_user_nameiVictimszVictimnamecharsmaxszVictimname ) )
    
client_print0print_chat"%s was killed by %s"szVictimnameszAttackername )

Example. Will display a message saying "Player was killed by player" when a player dies.
__________________
PM me for private work.



Last edited by Buckshot; 04-13-2014 at 17:44.
Buckshot is offline
Send a message via Skype™ to Buckshot
swapped
BANNED
Join Date: Mar 2014
Location: OrpheuRegisterHook
Old 04-14-2014 , 04:42   Re: message appears when the player is killed
Reply With Quote #4

Quote:
Originally Posted by Buckshot View Post
PHP Code:
#include < amxmodx > 
#include < hamsandwich >

public plugin_init( ) {
    
register_plugin"Death Message""1.0""BuckShot" )
    
RegisterHamHam_Killed"player""Fwd_Ham_Killed_Post")
}

public 
Fwd_Ham_Killed_PostiVictimiAttacker ) {
    new 
szAttackername32 ]
    new 
szVictimname32 ]
    
get_user_nameiAttackerszAttackernamecharsmaxszAttackername ) )
    
get_user_nameiVictimszVictimnamecharsmaxszVictimname ) )
    
client_print0print_chat"%s was killed by %s"szVictimnameszAttackername )

Example. Will display a message saying "Player was killed by player" when a player dies.
why use hamsandwich when you can use DeatMsg directly ?

This code will show an meesage to a victim and one msg to the victim

if headshot the message of the victim will be :

Code:
You have been headshoted !
if is not headshot the meesage of the victim will be :

Code:
You have been normal killed (without headshot)
if is headshot the message of the attacker will be :

Code:
You give headshot to other player
if is not headshot the meesage of the attacker will be :

Code:
You normal kill the player (without headshot)
The source code :

PHP Code:
#include <amxmodx>

public plugin_init()
{
    
register_event("DeathMsg""death_msg_function""a");
}

public 
death_msg_function()
{
    new 
victim read_data);
    new 
attacker read_data);
    new 
hs read_data);

    if(
hs)
    {
        
client_print(victim print_chat"You have been headshoted !")

        
client_print(attacker print_chat"You give headshot to other player");
    }

    else
    {
        
client_print(victim print_chat"You have been normal killed (without headshot) ");

        
client_print(attacker print_chat"You normal kill the player (without headshot) ");    
    }

swapped is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 04-14-2014 , 15:42   Re: message appears when the player is killed
Reply With Quote #5

And here I've added some more abbilities in your messages, swapped! I've got the victim and attacke names, also added some colors to the chat messages! Here you go:
PHP Code:
#include <amxmodx> 

public plugin_init() 

    
register_event("DeathMsg""death_msg_function""a"); 


public 
death_msg_function() 

    new 
victim read_data); 
    new 
attacker read_data); 
    new 
hs read_data); 
    new 
NameVictim[32]
    
get_user_name(victimNameVictim31)
    new 
NameAttacker[32]
    
get_user_name(attackerNameAttacker31)

    if(
hs
    { 
        
ColorMessage(victim"You have been headshoted by %s!"NameAttacker

        
ColorMessage(attacker"You have headshoted %s!"NameVictim); 
    } 

    else 
    { 
        
ColorMessage(victim,  "You have been normal killed by %s"NameAttacker); 

        
ColorMessage(attacker"You have normal killed %s"NameVictim);     
    } 
}  

/*You can add some colors to the chat messages
^4 - green color
^3 - team color
^1 - normal chat color
Example: ^3You have been ^4headshoted ^3by ^4%s!*/

stock ColorMessage(const id, const input[], any:...){
            new 
count 1players[32];
            static 
msg191 ];
            
vformat(msg190input3);
            if (
idplayers[0] = id; else get_players(players count "ch"); {
                for (new 
0counti++){
                    if (
is_user_connected(players[i])){
                        
message_begin(MSG_ONE_UNRELIABLE get_user_msgid("SayText"), _players[i]);
                        
write_byte(players[i]);
                        
write_string(msg);
                        
message_end();}}}
        } 
Flick3rR is offline
Send a message via Skype™ to Flick3rR
Buckshot
Senior Member
Join Date: Mar 2014
Location: Sweden
Old 04-16-2014 , 21:51   Re: message appears when the player is killed
Reply With Quote #6

Quote:
Originally Posted by swapped View Post
why use hamsandwich when you can use DeatMsg directly ?
Because deathmsg doesn't hook all ways of dying. It hooks when you get shot, but not when the bomb explodes for example.. Ham_Killed does. Even if it would i would still use ham_killed, since i don't gotta create 2 new separate variables for the victim & attacker indexes, i could just get them straight when declaring the function..
__________________
PM me for private work.



Last edited by Buckshot; 04-16-2014 at 22:15.
Buckshot is offline
Send a message via Skype™ to Buckshot
swapped
BANNED
Join Date: Mar 2014
Location: OrpheuRegisterHook
Old 04-17-2014 , 01:12   Re: message appears when the player is killed
Reply With Quote #7

Quote:
Originally Posted by Buckshot View Post
Because deathmsg doesn't hook all ways of dying. It hooks when you get shot, but not when the bomb explodes for example.. Ham_Killed does. Even if it would i would still use ham_killed, since i don't gotta create 2 new separate variables for the victim & attacker indexes, i could just get them straight when declaring the function..
Since now exist some cases when you are forced to use deathmsg and some cases when you Need to use ham_killed, my opinion is to use deathmsg insteand of including a new module, now all is about what you wanna do.


But i need you to ask "why?" to include a new module just for print a message in chat ? when we can use deathmsg.

Last edited by swapped; 04-17-2014 at 01:15.
swapped is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 04-17-2014 , 06:57   Re: message appears when the player is killed
Reply With Quote #8

Ok,let's test:

DeathMsg:
Code:
date: Thu Apr 17 03:51:47 2014 map: fy_snow
type |                             name |      calls | time / min / max
-------------------------------------------------------------------
   n |                   register_event |          1 | 0.000003 / 0.000003 / 0.000003
   n |                        read_data |          3 | 0.000005 / 0.000002 / 0.000002
   n |                     client_print |          2 | 0.000006 / 0.000002 / 0.000004
   p |               death_msg_function |          1 | 0.000011 / 0.000011 / 0.000011
   p |                      plugin_init |          1 | 0.000003 / 0.000003 / 0.000003
0 natives, 0 public callbacks, 2 function calls were not executed.
Ham:

Code:
date: Thu Apr 17 03:53:58 2014 map: fy_snow
type |                             name |      calls | time / min / max
-------------------------------------------------------------------
   n |                  register_plugin |          1 | 0.000002 / 0.000002 / 0.000002
   n |                      RegisterHam |          1 | 0.000041 / 0.000041 / 0.000041
   n |                    get_user_name |          2 | 0.000004 / 0.000002 / 0.000002
   n |                     client_print |          1 | 0.000004 / 0.000004 / 0.000004
   p |              Fwd_Ham_Killed_Post |          1 | 0.000008 / 0.000008 / 0.000008
   p |                      plugin_init |          1 | 0.000005 / 0.000005 / 0.000005
6 natives, 1 public callbacks, 3 function calls were not executed.
So:

register_event | 1 | 0.000003 / 0.000003 / 0.000003
death_msg_function | 1 | 0.000011 / 0.000011 / 0.000011

RegisterHam | 1 | 0.000041 / 0.000041 / 0.000041
Fwd_Ham_Killed_Post | 1 | 0.000008 / 0.000008 / 0.000008

Both are called just 1 time. Ham Killed is faster( 0.000008 )..

So, Ham Killed is better than DeathMsg( in terms of duration of execution ).
HamletEagle is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 04-17-2014 , 07:10   Re: message appears when the player is killed
Reply With Quote #9

Quote:
Originally Posted by HamletEagle View Post
Both are called just 1 time. Ham Killed is faster( 0.000008 )..

So, Ham Killed is better than DeathMsg( in terms of duration of execution ).
You forgot the amount of time it took to register the Ham. DeathMsg is 0.000014 and HamKilled is 0.000049, DeathMsg is the clear winner. But, it all comes down to what you are trying to do
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).

Last edited by YamiKaitou; 04-17-2014 at 07:11.
YamiKaitou is offline
Buckshot
Senior Member
Join Date: Mar 2014
Location: Sweden
Old 04-17-2014 , 13:12   Re: message appears when the player is killed
Reply With Quote #10

Quote:
Originally Posted by swapped View Post
Since now exist some cases when you are forced to use deathmsg and some cases when you Need to use ham_killed, my opinion is to use deathmsg insteand of including a new module, now all is about what you wanna do.


But i need you to ask "why?" to include a new module just for print a message in chat ? when we can use deathmsg.
I just told you.............

This guy wants to learn how to display a message when a player is killed, he doesn't tell us WHEN he wants to detect when a player is killed, if he jumps from a cliff, gets shot or dies by the bombs explosion. Ham_Killed will detect all types of deaths. Deathmsg will not display when a player is killed by bomb explosion for example, and i think there are a few other types of deaths too that deathmsg can't find... Then why teach him deathmsg if he wants to check when a player is killed by a bomb explosion.. we don't know if he wants that or not? He did not specify a reason to when he wants to check a player death, and in what way... So i just learned him ham_killed. Your method will not work if that's what he wants. What is the point of even arguing? :S
__________________
PM me for private work.



Last edited by Buckshot; 04-17-2014 at 13:14.
Buckshot is offline
Send a message via Skype™ to Buckshot
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 17:53.


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