Raised This Month: $ Target: $400
 0% 

HAM_USE for hostage


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
avril-lavigne
Banned
Join Date: Apr 2009
Old 02-24-2013 , 01:11   HAM_USE for hostage
Reply With Quote #1

Code:
public event_hostage_used(hostage, id) {
       if(get_pcvar_num(terrcanmove) == 1) {
        if((get_user_button(id) & IN_USE))
        cs_set_hostage_foll(id)
        client_print(0,print_chat,"!!! Terrorist is moving a hostage !!!")  
        }
        else
        client_print(0,print_chat,"!!! ONLY CT can Move hostages !!!")  
}

I want terr can move hostages, I found cs_set_hostage_foll(id) . I dont check teams because it should work for all




and how to set zone with

Code:
create_entity_by_classname("func_hostage_rescue")


 new Float:maxs[3] = {16.0,16.0,36.0}
 new Float:mins[3] = {-16.0,-16.0,-36.0}
    
    
 entity_set_size(myent, mins, maxs);


 ???
__________________
VDS in Europe 1 gb/s unmetered.Any configurations.
I accept Paypal, Moneybookers,etc

Last edited by avril-lavigne; 02-24-2013 at 01:33.
avril-lavigne is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 02-24-2013 , 03:35   Re: HAM_USE for hostage
Reply With Quote #2

Ham Use Function:
Code:
public HamUse(this, idcaller, idactivator, use_type, Float:value)
{
	if( is_user_alive(idcaller) )
	{
		if( value == 1.0 )
		{
			if( cs_get_hostage_foll(this) == idcaller )
			{
				cs_set_hostage_foll(this, 0);
			}
			else
			{
				new hostage_sound[64];
				formatex(hostage_sound, charsmax(hostage_sound), "hostage/hos%d.wav", random_num(1,5));
				emit_sound(this, CHAN_VOICE, hostage_sound, VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
				cs_set_hostage_foll(this, idcaller);
			}
			cs_set_hostage_nextuse(this, get_gametime()+1.0);
		}

		return HAM_SUPERCEDE;
	}
	return HAM_IGNORED;
}
Hostage rescue zone:
Code:
#define MIN_ADD -100.0
#define MAX_ADD 100.0

CreateHostageRescue( Float:origin[3] )
{
	new ent = fm_create_entity("func_hostage_rescue");

	fm_entity_set_origin( ent, origin );

	set_pev( ent, pev_solid, SOLID_TRIGGER );

	SetBrushSize(ent, origin);
}

SetBrushSize(ent, Float:origin[3])
{
	new i, Float:mins[3], Float:maxs[3];
	for( i=0; i<3; i++ )
	{
		mins[i] = origin[i] + MIN_ADD;
		maxs[i] = origin[i] + MAX_ADD;
	}
	set_pev( ent, pev_absmin, mins );
	set_pev( ent, pev_absmax, maxs );

	for( i=0; i<3; i++ )
	{
		mins[i] += 1.0;
		maxs[i] -= 1.0;
	}
	set_pev( ent, pev_mins, mins );
	set_pev( ent, pev_maxs, maxs );

	engfunc(EngFunc_SetSize, ent, mins, maxs);

	dllfunc(DLLFunc_Spawn, ent);

	for( i=0; i<3; i++ )
	{
		mins[i] = origin[i] + MIN_ADD;
		maxs[i] = origin[i] + MAX_ADD;
	}
	set_pev( ent, pev_absmin, mins );
	set_pev( ent, pev_absmax, maxs );

	for( i=0; i<3; i++ )
	{
		mins[i] += 1.0;
		maxs[i] -= 1.0;
	}
	set_pev( ent, pev_mins, mins );
	set_pev( ent, pev_maxs, maxs );
}
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 02-24-2013 , 05:48   Re: HAM_USE for hostage
Reply With Quote #3

Your way doesn't check if player is CT or T, so CT never receive bonus.
Also you forgot to check hostage nextuse.
You should at least check if user is T.

I have this :
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

const m_iTeam 114

const m_fHasGivenUseBonus 97
const m_flNextUse 100

new g_iMaxPlayers
#define IsPlayer(%0)    ( 1 <= (%0) <= g_iMaxPlayers )

new HamHook:g_iHhCHostageUsePost
new bool:g_bResetHasGivenUseBonus

public plugin_init()
{
    
g_iMaxPlayers get_maxplayers()

    new 
hostage_class[] = "hostage_entity"
    
RegisterHam(Ham_Usehostage_class"OnCHostage_Use"false)
    
DisableHamForwardg_iHhCHostageUsePost RegisterHam(Ham_Usehostage_class"OnCHostage_Use_Post"true) )
}

public 
OnCHostage_Use(iHostageidiCalleruseTypeFloat:value)
{
    if( 
IsPlayer(id) &&  get_pdata_int(idm_iTeam) == && get_pdata_float(iHostagem_flNextUse) < get_gametime() )
    {
        
EnableHamForwardg_iHhCHostageUsePost )
        
set_pdata_int(idm_iTeam2)
        if( !
get_pdata_int(iHostagem_fHasGivenUseBonus) )
        {
            
// prevent bonus from being given to terrorist
            
set_pdata_int(iHostagem_fHasGivenUseBonus1)
            
g_bResetHasGivenUseBonus true
        
}
        return 
HAM_HANDLED
    
}
    return 
HAM_IGNORED
}

public 
OnCHostage_Use_Post(iHostageid)
{
    
DisableHamForwardg_iHhCHostageUsePost )
    
set_pdata_int(idm_iTeam1)
    if( 
g_bResetHasGivenUseBonus )
    {
        
g_bResetHasGivenUseBonus false
        set_pdata_int
(iHostagem_fHasGivenUseBonus0)
    }

__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 02-24-2013 at 06:06.
ConnorMcLeod is offline
avril-lavigne
Banned
Join Date: Apr 2009
Old 02-24-2013 , 11:43   Re: HAM_USE for hostage
Reply With Quote #4

Interesting. Thanks for the code. I like to learn something new for me.
__________________
VDS in Europe 1 gb/s unmetered.Any configurations.
I accept Paypal, Moneybookers,etc
avril-lavigne is offline
avril-lavigne
Banned
Join Date: Apr 2009
Old 02-25-2013 , 01:24   Re: HAM_USE for hostage
Reply With Quote #5

and my last request save/load (without menu) for hostages

ven`s code

PHP Code:
public host_spawn(id) {
    new 
Float:origin[3]
    
entity_get_vector(idEV_VEC_originorigin)
    
origin[0] += 100

    
new host create_entity("hostage_entity")
    
entity_set_origin(hostorigin)
    
DispatchSpawn(host)
    
    return 
PLUGIN_HANDLED



PHP Code:
need load save functions of hostage origin  up to four hostages


public load()
{
    new 
config[50],map[30],Float:origin[3]
    
get_configsdir(config,29)
    
get_mapname(map,29)
    
formatex(config,49,"%s/hostage/%s.ini",config,map)
    if(!
file_exists(config))return
    
    new 
File fopen(config,"r")
    if(
File)
    {

need help 
__________________
VDS in Europe 1 gb/s unmetered.Any configurations.
I accept Paypal, Moneybookers,etc

Last edited by avril-lavigne; 02-25-2013 at 01:25.
avril-lavigne 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 21:48.


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