Raised This Month: $208 Target: $400
 52% 

Detect c4 carrier


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Sanjay Singh
Veteran Member
Join Date: Sep 2016
Old 12-05-2019 , 11:51   Detect c4 carrier
Reply With Quote #1

how can I detect if I killed a c4 carrier enemy or not?

I want to print chat message if I killed a c4 carrier

PHP Code:
client_print(id0"You just killed a c4 carrier guy (%s)"carrier name
__________________
Sanjay Singh is offline
Send a message via AIM to Sanjay Singh
redivcram
Veteran Member
Join Date: Jul 2014
Location: Serbia
Old 12-05-2019 , 12:27   Re: Detect c4 carrier
Reply With Quote #2

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

#define PLUGIN "Notify about C4 victim"
#define VERSION "1.0"
#define AUTHOR "redivcram"

public plugin_init() {
    
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
RegisterHam(Ham_Killed"player""HamPlayerKilled"1);
}

public 
HamPlayerKilled(iVictimiAttacker)
{
    if((
iVictim != iAttacker) && user_has_weapon(iVictimCSW_C4)) {
        
        new 
szCarrierName[32];
        
get_user_name(iVictimszCarrierNamecharsmax(szCarrierName));
        
        
client_print(iAttacker0"You just killed a c4 carrier guy (%s)"szCarrierName);
    }

__________________
Discord: wEight#6773

Hobbies:
- Map Designing (Any Half-Life 1 Engine Game)
- Pawn (Intermediate / Counter-Strike 1.6 only)
- C#/VB for .Net (Intermediate / Winforms)
- Java (Mostly Android Application Development)

Last edited by redivcram; 12-05-2019 at 13:22.
redivcram is offline
Sanjay Singh
Veteran Member
Join Date: Sep 2016
Old 12-05-2019 , 12:32   Re: Detect c4 carrier
Reply With Quote #3

But will it work? becuz it will be called only after player killed?
Quote:
Originally Posted by redivcram View Post
PHP Code:
#include <amxmodx>
#include <hamsandwich>

#define PLUGIN "Notify about C4 victim"
#define VERSION "1.0"
#define AUTHOR "redivcram"

public plugin_init() {
    
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
RegisterHam(Ham_Killed"player""HamPlayerKilled"1);
}

public 
HamPlayerKilled(iVictimiAttacker)
{
    if(
user_has_weapon(iVictimCSW_C4)) {
        
        new 
szCarrierName[32];
        
get_user_name(iVictimszCarrierNamecharsmax(szCarrierName));
        
        
client_print(iAttacker0"You just killed a c4 carrier guy (%s)"szCarrierName);
    }

__________________
Sanjay Singh is offline
Send a message via AIM to Sanjay Singh
redivcram
Veteran Member
Join Date: Jul 2014
Location: Serbia
Old 12-05-2019 , 12:39   Re: Detect c4 carrier
Reply With Quote #4

Quote:
Originally Posted by Sanjay Singh View Post
But will it work? becuz it will be called only after player killed?
Maybe test it out?
__________________
Discord: wEight#6773

Hobbies:
- Map Designing (Any Half-Life 1 Engine Game)
- Pawn (Intermediate / Counter-Strike 1.6 only)
- C#/VB for .Net (Intermediate / Winforms)
- Java (Mostly Android Application Development)
redivcram is offline
instinctpt1
Senior Member
Join Date: Dec 2016
Location: Rajasthan, India
Old 12-05-2019 , 13:02   Re: Detect c4 carrier
Reply With Quote #5

@redivcram Maybe with iVictim != iAttacker check too ?
__________________
CSIndia The only Indian Scripters Community
instinctpt1 is offline
redivcram
Veteran Member
Join Date: Jul 2014
Location: Serbia
Old 12-05-2019 , 13:22   Re: Detect c4 carrier
Reply With Quote #6

Quote:
Originally Posted by instinctpt1 View Post
@redivcram Maybe with iVictim != iAttacker check too ?
You are right! I totally forgot about that, thanks!
Updated my code above.
__________________
Discord: wEight#6773

Hobbies:
- Map Designing (Any Half-Life 1 Engine Game)
- Pawn (Intermediate / Counter-Strike 1.6 only)
- C#/VB for .Net (Intermediate / Winforms)
- Java (Mostly Android Application Development)
redivcram is offline
thEsp
Veteran Member
Join Date: Aug 2017
Old 12-05-2019 , 15:23   Re: Detect c4 carrier
Reply With Quote #7

(just a side note)
You may use "%n" formatting rule in order to get some player's name directly.
https://github.com/alliedmodders/amxmodx/pull/93
thEsp is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-05-2019 , 19:59   Re: Detect c4 carrier
Reply With Quote #8

Not thoroughly tested
PHP Code:

#include <amxmodx>
#include <hamsandwich>

new g_iPlayerHasC4;

public 
plugin_init() 
{
    
RegisterHamHam_Killed "player" "HamPlayerKilled" );
    
    
register_logevent"LostBomb" "2=Dropped_The_Bomb" );
    
register_logevent"GotBomb" "2=Got_The_Bomb" );
    
register_event"WeapPickup" "GotBomb2" "be" "1=6" );
}

public 
GotBomb()
{
    
g_iPlayerHasC4 get_loguser_index();
}

public 
GotBomb2id )
{
    
g_iPlayerHasC4 id;
}

public 
LostBomb()
{
    if ( 
is_user_aliveget_loguser_index() ) )
    {
        
g_iPlayerHasC4 0;
    }
}

public 
HamPlayerKillediVictim iAttacker )
{
    if ( 
g_iPlayerHasC4 && ( iVictim == g_iPlayerHasC4 ) )
    {
        new 
szCarrierName[32];
        
get_user_nameiVictim szCarrierName charsmaxszCarrierName ) );
    
        
client_printiAttacker print_chat"You just killed a c4 carrier guy (%s)" szCarrierName );
    }
}

get_loguser_index() 
{
    new 
loguser[80], name[32]
    
read_logargv(0loguser79)
    
parse_loguser(logusername31)
    
    return 
get_user_index(name)

__________________

Last edited by Bugsy; 12-05-2019 at 20:01.
Bugsy is offline
Sanjay Singh
Veteran Member
Join Date: Sep 2016
Old 12-06-2019 , 03:53   Re: Detect c4 carrier
Reply With Quote #9

This code working fine but you also need to add code for spawn c4 func and get his id. else its fine.
Thanks @bugsy

Quote:
Originally Posted by Bugsy View Post
Not thoroughly tested
PHP Code:

#include <amxmodx>
#include <hamsandwich>

new g_iPlayerHasC4;

public 
plugin_init() 
{
    
RegisterHamHam_Killed "player" "HamPlayerKilled" );
    
    
register_logevent"LostBomb" "2=Dropped_The_Bomb" );
    
register_logevent"GotBomb" "2=Got_The_Bomb" );
    
register_event"WeapPickup" "GotBomb2" "be" "1=6" );
}

public 
GotBomb()
{
    
g_iPlayerHasC4 get_loguser_index();
}

public 
GotBomb2id )
{
    
g_iPlayerHasC4 id;
}

public 
LostBomb()
{
    if ( 
is_user_aliveget_loguser_index() ) )
    {
        
g_iPlayerHasC4 0;
    }
}

public 
HamPlayerKillediVictim iAttacker )
{
    if ( 
g_iPlayerHasC4 && ( iVictim == g_iPlayerHasC4 ) )
    {
        new 
szCarrierName[32];
        
get_user_nameiVictim szCarrierName charsmaxszCarrierName ) );
    
        
client_printiAttacker print_chat"You just killed a c4 carrier guy (%s)" szCarrierName );
    }
}

get_loguser_index() 
{
    new 
loguser[80], name[32]
    
read_logargv(0loguser79)
    
parse_loguser(logusername31)
    
    return 
get_user_index(name)

__________________
Sanjay Singh is offline
Send a message via AIM to Sanjay Singh
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-06-2019 , 07:21   Re: Detect c4 carrier
Reply With Quote #10

This should hook when a player is spawned with c4.
__________________
Bugsy 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 23:24.


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