AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to check if player killed a hostage? (https://forums.alliedmods.net/showthread.php?t=168886)

Evaldas.Grigas 10-05-2011 13:58

How to check if player killed a hostage?
 
How to check if player killed a hostage?

Xellath 10-05-2011 14:12

Re: How to check if player killed a hostage?
 
Hook Ham_Killed with "hostage_entity" as entity classname or register TextMsg with "2&#Killed_Hostage" as a condition.

Evaldas.Grigas 10-05-2011 14:19

Re: How to check if player killed a hostage?
 
Mhm something like this should work?
PHP Code:

public hostage_killed(id)
{
    
client_print(idprint_chat"You've killed a hostage")



Stereo 10-05-2011 14:40

Re: How to check if player killed a hostage?
 
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")



Evaldas.Grigas 10-05-2011 15:02

Re: How to check if player killed a hostage?
 
Thank you!

Hunter-Digital 10-06-2011 05:10

Re: How to check if player killed a hostage?
 
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.

Napoleon_be 10-06-2011 06:46

Re: How to check if player killed a hostage?
 
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.

Arkshine 10-06-2011 07:23

Re: How to check if player killed a hostage?
 
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)

Stereo 10-06-2011 09:25

Re: How to check if player killed a hostage?
 
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"


?

Arkshine 10-06-2011 09:56

Re: How to check if player killed a hostage?
 
is_user_connected is pointless and get_maxplayers() should be cached.


All times are GMT -4. The time now is 19:41.

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