Raised This Month: $ Target: $400
 0% 

How to check if player killed a hostage?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Evaldas.Grigas
Senior Member
Join Date: Sep 2011
Location: Lithuania
Old 10-05-2011 , 13:58   How to check if player killed a hostage?
Reply With Quote #1

How to check if player killed a hostage?
Evaldas.Grigas is offline
Send a message via Skype™ to Evaldas.Grigas
Xellath
Veteran Member
Join Date: Dec 2007
Location: Sweden
Old 10-05-2011 , 14:12   Re: How to check if player killed a hostage?
Reply With Quote #2

Hook Ham_Killed with "hostage_entity" as entity classname or register TextMsg with "2&#Killed_Hostage" as a condition.
__________________
Achievements API - a simple way for you to create your OWN custom achievements!

Last edited by Xellath; 10-05-2011 at 14:15. Reason: typo
Xellath is offline
Evaldas.Grigas
Senior Member
Join Date: Sep 2011
Location: Lithuania
Old 10-05-2011 , 14:19   Re: How to check if player killed a hostage?
Reply With Quote #3

Mhm something like this should work?
PHP Code:
public hostage_killed(id)
{
    
client_print(idprint_chat"You've killed a hostage")

Evaldas.Grigas is offline
Send a message via Skype™ to Evaldas.Grigas
Stereo
Veteran Member
Join Date: Dec 2010
Old 10-05-2011 , 14:40   Re: How to check if player killed a hostage?
Reply With Quote #4

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

public plugin_init()
{
    
RegisterHam(Ham_Killed"hostage_entity""fw_Hostage_Die")
}

public 
fw_Hostage_Die(victimattackershouldgib)
{
    
client_print(attackerprint_chat"You've killed a hostage")

Stereo is offline
Evaldas.Grigas
Senior Member
Join Date: Sep 2011
Location: Lithuania
Old 10-05-2011 , 15:02   Re: How to check if player killed a hostage?
Reply With Quote #5

Thank you!
Evaldas.Grigas is offline
Send a message via Skype™ to Evaldas.Grigas
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 10-06-2011 , 05:10   Re: How to check if player killed a hostage?
Reply With Quote #6

You should check if attacker is a player too, because hostages can be killed by other means aswell and when that does you'll wonder wtf is printing errors.
__________________
Hunter-Digital is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 10-06-2011 , 06:46   Re: How to check if player killed a hostage?
Reply With Quote #7

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

public plugin_init() 

     
RegisterHam(Ham_Killed"hostage_entity""fw_Hostage_Die"


public 
fw_Hostage_Die(victimattackershouldgib

     if(!
is_user_bot(attacker))
     {
        
client_print(attackerprint_chat"You've killed a hostage"
     }

This should work i think.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-06-2011 , 07:23   Re: How to check if player killed a hostage?
Reply With Quote #8

A bot is a player for your information. All you need is to check if attacker's index is between 1 and max server slots. (get_maxplayers)
__________________
Arkshine is offline
Stereo
Veteran Member
Join Date: Dec 2010
Old 10-06-2011 , 09:25   Re: How to check if player killed a hostage?
Reply With Quote #9

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

new g_maxpl
#define IsPlayer(%1) ( 1 <= %1 <= g_maxpl )

public plugin_init() 
{
    
RegisterHam(Ham_Killed"hostage_entity""fw_Hostage_Die")

    
g_maxpl get_maxplayers()
}

public 
fw_Hostage_Die(victimattackershouldgib
{
    if(
IsPlayer(attacker) )
        
client_print(attackerprint_chat"You've killed a hostage"

?

Last edited by Stereo; 10-06-2011 at 12:25.
Stereo is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-06-2011 , 09:56   Re: How to check if player killed a hostage?
Reply With Quote #10

is_user_connected is pointless and get_maxplayers() should be cached.
__________________
Arkshine 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 19:41.


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