Raised This Month: $51 Target: $400
 12% 

Entity touch problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
peNgueN
Junior Member
Join Date: Nov 2011
Old 08-05-2015 , 13:26   Entity touch problem
Reply With Quote #1

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <hamsandwich>
#include <xs>
#include <engine>

#define PLUGIN "BoxBox"
#define VERSION "1.0"
#define AUTHOR "penguen"

#define MAX_BOX       1024
#define BOX_COUNT     5
#define NEXT_JUMP     2.0

new g_BoxCount;

new 
boolNextJump[MAX_BOX];

new const 
BoxEntity[] = "entity_jumpbox";
new const 
BoxModel[] = "models/jumpbox.mdl";
new const 
BoxSound[] = "debris/pushbox1.wav";

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd"say /jumpbox""cmdboxMenu" );
    
    
register_touchBoxEntity"player""fwd_box_touch" );
    
RegisterHamHam_Think"info_target""fwd_box_think" );
}

public 
plugin_precache() 
{
    
precache_modelBoxModel );
    
precache_soundBoxSound );
}

public 
cmdboxMenuid 
{
    new 
menu menu_create"\wJump Box""cmdboxMenu_Handler" );    
    
    
menu_additemmenu"\wCreate Jump Box""1" );
    
menu_additemmenu"\wRemove Jump Box""2" );
    
menu_additemmenu"\wRemove All Boxs""1" );
    
menu_displayidmenu );
}

public 
cmdboxMenu_Handleridmenuitem )
{
    if( 
item == MENU_EXIT )
        return 
PLUGIN_HANDLED;
    
    switch( 
item ) {
        
        case 
0: {
            if( 
g_BoxCount BOX_COUNT ) {
                
CreateBoxid );
                
client_printidprint_chat"A Box Created" );
            }
        }
        case 
1: {
            if( !
is_user_aliveid ) ) return PLUGIN_HANDLED;
            
            new 
entBody, Class[32];
            
get_user_aimingidentBody );
            
            if ( 
is_valid_entent ) ) {
                
entity_get_stringentEV_SZ_classname, Class, charsmax( Class ) );
                
                if ( 
equalBoxEntity, Class ) ) {
                    
remove_entityent );
                    
g_BoxCount -= -1;
                    
client_printidprint_chat"A Box Removed" );
                }
                
            }
        }
        case 
2: {
            
remove_entity_nameBoxEntity );
            
g_BoxCount 0;
            
client_printidprint_chat"Removed All Boxs" );
        }
    }
    
menu_destroymenu );
    return 
PLUGIN_HANDLED;
}

public 
fwd_box_touchentid )
{
    if( !
is_user_aliveid ) ) return;
    
    if( 
NextJump[ent] ) {
        new 
FloatpVelocity[3];
        
entity_get_vectoridEV_VEC_velocitypVelocity );
        
pVelocity] += 400.0;
        
entity_set_vectoridEV_VEC_velocitypVelocity );
        
        
NextJump[ent] = false;
        
        
emit_soundentCHAN_VOICEBoxSound,  VOL_NORMATTN_NORM0PITCH_NORM );
        
entity_set_floatentEV_FL_nextthinkget_gametime() + NEXT_JUMP );
    }
}

public 
fwd_box_thinkent )
{
    if( !
is_valid_entent ) )
        return;
    
    new Class[
32];
    
entity_get_stringentEV_SZ_classname, Class, charsmax( Class ) );
    
    if( 
equalBoxEntity, Class ) ) {
        
        if( !
NextJump[ent] ) {
            
NextJump[ent] = true;    
            
entity_set_floatentEV_FL_nextthinkget_gametime() + NEXT_JUMP );
            return;
        }
        
entity_set_floatentEV_FL_nextthinkget_gametime() + NEXT_JUMP );
    }
}

public 
CreateBoxid )
{
    if( !
is_user_aliveid ) ) return PLUGIN_HANDLED;
    
    new 
FloatOrigin] = { 0.00.00.0 };
    new 
FloatAngle] = { 0.00.00.0 };
    
    new 
ent create_entity"info_target" );
    
entity_set_stringentEV_SZ_classnameBoxEntity );
    
    
get_user_hitpointidOrigin );
    
Origin] += 70.0
    
entity_set_originentOrigin );
    
    
entity_get_vectoridEV_VEC_anglesAngle );
    
Angle[0] = 0.0;
    
    
entity_set_vectorentEV_VEC_anglesAngle );
    
    
entity_set_modelentBoxModel );
    
entity_set_intentEV_INT_movetypeMOVETYPE_TOSS );
    
entity_set_intentEV_INT_solidSOLID_BBOX );
    
    new 
Floatmins[3] = {-10.0, -15.0, -10.0 }
    new 
Floatmaxs[3] = { 10.015.010.0 }
    
    
entity_set_sizeentminsmaxs );
    
entity_set_floatentEV_FL_nextthinkget_gametime() + 0.1 );    
    
    
drop_to_floorent );
    return 
PLUGIN_CONTINUE;
}

stock get_user_hitpoint(idFloat:hOrigin[3]) {
    if ( ! 
is_user_aliveid ))
        return 
0;
    
    new 
Float:fOrigin[3], Float:fvAngle[3], Float:fvOffset[3], Float:fvOrigin[3], Float:feOrigin[3];
    new 
Float:fTemp[3];
    
    
pev(idpev_originfOrigin);
    
pev(idpev_v_anglefvAngle);
    
pev(idpev_view_ofsfvOffset);
    
    
xs_vec_add(fOriginfvOffsetfvOrigin);
    
    
engfunc(EngFunc_AngleVectorsfvAnglefeOriginfTempfTemp);
    
    
xs_vec_mul_scalar(feOrigin9999.9feOrigin);
    
xs_vec_add(fvOriginfeOriginfeOrigin);
    
    
engfunc(EngFunc_TraceLinefvOriginfeOrigin0id);
    
global_get(glb_trace_endposhOrigin);
    return 
1;

When i touched box nothing happened. I don't know where is the problem. i tried change origin,

PHP Code:
new FloatpOrigin[3];
entity_get_vectoridEV_VEC_velocitypOrigin );
pVelocity] += 70.0;
entity_set_vectoridEV_VEC_velocitypOrigin ); 
it worked but,

PHP Code:
new FloatpVelocity[3];
entity_get_vectoridEV_VEC_velocitypVelocity );
pVelocity] += 400.0;
entity_set_vectoridEV_VEC_velocitypVelocity ); 
this is not working.
__________________
i seems happy :')
peNgueN is offline
Reply



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 00:39.


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