Raised This Month: $32 Target: $400
 8% 

Solved [HELP] How to Count Hostages


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hellmonja
Senior Member
Join Date: Oct 2015
Old 04-11-2021 , 14:28   [HELP] How to Count Hostages
Reply With Quote #1

I have this:
PHP Code:
new i_hostage_nument = -1;

    while((
ent find_ent_by_class(ent"hostage_entity")))
        if(
pev_valid(ent))
            
i_hostage_num++;

    switch(
i_hostage_num)
    {
        case 
client_print(userprint_chat"No hostages left");
        case 
client_print(userprint_chat"1 hostage left");
        default : 
client_print(userprint_chat"%d hostages left"i_hostage_num);
    } 
It counts the hostages in a map and works. But when I kill or rescue some of them the number doesn't change. How can this be done?...
__________________

Last edited by hellmonja; 04-11-2021 at 16:23. Reason: Solved...
hellmonja is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 04-11-2021 , 14:44   Re: [HELP] How to Count Hostages
Reply With Quote #2

Code:
					"m_hostageEscortCount"  // byte
					{
						"type"      "character"
						"unsigned"  "1"

						"windows"   "9648"
						"linux"     "9668"
						"mac"       "9668"
					}
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 04-11-2021 at 14:44.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
hellmonja
Senior Member
Join Date: Oct 2015
Old 04-11-2021 , 14:47   Re: [HELP] How to Count Hostages
Reply With Quote #3

Quote:
Originally Posted by Natsheh View Post
Code:
					"m_hostageEscortCount"  // byte
					{
						"type"      "character"
						"unsigned"  "1"

						"windows"   "9648"
						"linux"     "9668"
						"mac"       "9668"
					}
Pardon? Is that an offset?...

EDIT: Sorry but how do I use this? I can't find any examples. And when I try to use it with get_pdata_cbase the game hangs...
__________________

Last edited by hellmonja; 04-11-2021 at 15:26.
hellmonja is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 04-11-2021 , 16:09   Re: [HELP] How to Count Hostages
Reply With Quote #4

m_hostageEscortCount has nothing to do with what you want, it seems to only be used for bots.
You can try to adjust your code and only count hostages with pev_solid != SOLID_NOT. See if this works.
__________________
HamletEagle is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 04-11-2021 , 16:15   Re: [HELP] How to Count Hostages
Reply With Quote #5

oh hamlet is correct, but here's the correct one.

Code:
					"m_iHostagesRescued"  // int
					{
						"type"      "integer"

						"windows"   "108"
						"linux"     "100"
						"mac"       "100"
					}
I've remembered there's an offset for hostage rescuing just forgot where its originally located.


This is how to retrieve it.

PHP Code:
new iHostagesRescued get_gamerules_int("CHalfLifeMultiplay""m_iHostagesRescued"); 

this offset will just retrieve the count of rescued hostages if you also want to add the count of dead hostages you need to hook their kill event and add a hostage death counter.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 04-11-2021 at 16:25.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
hellmonja
Senior Member
Join Date: Oct 2015
Old 04-11-2021 , 16:22   Re: [HELP] How to Count Hostages
Reply With Quote #6

Quote:
Originally Posted by HamletEagle View Post
m_hostageEscortCount has nothing to do with what you want, it seems to only be used for bots.
You can try to adjust your code and only count hostages with pev_solid != SOLID_NOT. See if this works.
PHP Code:
#include <amxmodx>
#include <engine>
#include <fakemeta>

public plugin_init() {
    
register_plugin("Hostage Counter""v0.1a""hellmonja");
    
    
register_concmd("debug""Debug");
}

public 
Debug(user

    new 
i_hostage_nument = -1;

    while((
ent find_ent_by_class(ent"hostage_entity")))
    {
//        if(entity_get_float(ent, EV_FL_health) > 0.0)
        
if(pev(entpev_solid) != SOLID_NOT)
            
i_hostage_num++;
    }

    switch(
i_hostage_num)
    {
        case 
client_print(userprint_chat"No hostages left");
        case 
client_print(userprint_chat"1 hostage left");
        default : 
client_print(userprint_chat"%d hostages left"i_hostage_num);
    }

Works like a charm, thanks! At first I tried checking their health points. But that only works when a hostage is killed. Checking for solidity works for both killing and rescuing the hostage. Thanks man!...
__________________
hellmonja 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 09:56.


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