AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   HAM_USE for hostage (https://forums.alliedmods.net/showthread.php?t=209300)

avril-lavigne 02-24-2013 01:11

HAM_USE for hostage
 
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);


 ???


Emp` 02-24-2013 03:35

Re: HAM_USE for hostage
 
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 );
}


ConnorMcLeod 02-24-2013 05:48

Re: HAM_USE for hostage
 
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)
    }



avril-lavigne 02-24-2013 11:43

Re: HAM_USE for hostage
 
Interesting. Thanks for the code. I like to learn something new for me.

avril-lavigne 02-25-2013 01:24

Re: HAM_USE for hostage
 
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 



All times are GMT -4. The time now is 21:48.

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