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

Questin for enrtty


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
PawNod
Member
Join Date: Jun 2019
Location: Turkey
Old 06-29-2019 , 09:09   Questin for enrtty
Reply With Quote #1

I did an entity. I want when ı near entity and touch E I destroy it. How ı do this?
PawNod is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 06-29-2019 , 09:51   Re: Questin for enrtty
Reply With Quote #2

You should ask in the "Scripting Help" section.

Hook "Ham_Use" if the entity can be interacted with and check if the entity is near you, then destroy it.
If not, use cmdstart or some other forward and check if the user pressed E, then do the rest.
__________________

Last edited by OciXCrom; 06-29-2019 at 09:51.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
SHIELD755
Veteran Member
Join Date: Feb 2018
Location: FROM MARVEL STUDIO
Old 06-29-2019 , 09:56   Re: Questin for enrtty
Reply With Quote #3

Yes , like this :-
PHP Code:
public fm_cmdstart(iduc_handleseed){
    if(!
is_user_alive(id)) return

    new 
buttons get_uc(uc_handle,UC_Buttons)
    if(
buttons IN_USE){

      
////YOUR CODE BLA BLA 
    
}

Show the code of your entity
__________________
SED LYF !!!
SHIELD755 is offline
PawNod
Member
Join Date: Jun 2019
Location: Turkey
Old 06-29-2019 , 09:58   Re: Questin for enrtty
Reply With Quote #4

How ı do this "check if the entity is near you, then destroy it."
PawNod is offline
SHIELD755
Veteran Member
Join Date: Feb 2018
Location: FROM MARVEL STUDIO
Old 06-29-2019 , 10:22   Re: Questin for enrtty
Reply With Quote #5

Quote:
Originally Posted by PawNod View Post
How ı do this "check if the entity is near you, then destroy it."
You can find entity by its class name , show the full code may it helps
__________________
SED LYF !!!
SHIELD755 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-29-2019 , 10:34   Re: Questin for enrtty
Reply With Quote #6

get_distance to check the distance between you and your entitty.
To detect when you press E you should use FM_EmitSound.
__________________
HamletEagle is offline
PawNod
Member
Join Date: Jun 2019
Location: Turkey
Old 06-29-2019 , 10:35   Re: Questin for enrtty
Reply With Quote #7

OK I will send you code in the evening
PawNod is offline
PawNod
Member
Join Date: Jun 2019
Location: Turkey
Old 06-29-2019 , 13:47   Re: Questin for enrtty
Reply With Quote #8

Code
PHP Code:
#include <amxmodx> 
#include <amxmisc> 
#include <fakemeta> 
#include <engine> 
#include <hamsandwich>
#include <xs>  

#define PLUGIN "NPC - Non Playar Character - Oyuncu Olmayan Karakter"
#define VERSION "1.0" 
#define AUTHOR "peNgueN" 

new boolg_NpcOldu512 ];  
new const 
NpcClass[] = "entity_npc"

new const 
g_NpcIdleAnimations[] = { 1345};
new const 
g_NpcDamageAnimations[] = { 57,5859 }; 
new const 
g_NpcDeathAnimations[] = { 545556495351 }; 
new const 
g_NpcTalkAnimations[] = { 5960616263 }; 

new 
npc_kan_sprnpc_kan_spr_sprey;

new const 
g_NpcModel[] = "models/hostageC.mdl";

new 
NpcSayisi

new 
yuruyor 1gerisibende

public plugin_init() 

    
register_pluginPLUGINVERSIONAUTHOR );
    
    
register_clcmd"say /npc""NpcMenu" );
    
register_clcmd"say_team /npc""NpcMenu" );
    
    
RegisterHamHam_TakeDamage"info_target""fw_NpcTakeDamage" ); 
    
RegisterHamHam_Killed"info_target""fw_NpcKilled" ); 
    
RegisterHamHam_Think"info_target""fw_NpcThink" ); 
    
RegisterHamHam_TraceAttack"info_target""fw_NpcTraceAttack" ); 
    
RegisterHamHam_Touch"info_target""fw_NpcTouch" ); 

public 
plugin_precache( ) 

    
npc_kan_spr precache_model"sprites/blood.spr" );
    
npc_kan_spr_sprey precache_model"sprites/bloodspray.spr" );
    
precache_modelg_NpcModel ); 
    
}  
public 
NpcMenuid 

    new 
iMenu64 ]; 
    
formatexiMenucharsmaxiMenu ), "NPC - Oyuncu Olmayan Karakter" );
    new 
menu menu_createiMenu"NpcMenu_go" );
    
    
formatexiMenucharsmaxiMenu ), "\wNPC Olustur \y( Aim ile yer belirleyin )" );
    
menu_additemmenuiMenu"1" );
    
formatexiMenucharsmaxiMenu ), "\wNPC Kaldir \y( Aim ile secin )" );
    
menu_additemmenuiMenu"2" );
    
formatexiMenucharsmaxiMenu ), "\wButun NPC'leri Kaldir^n \y  %d NPC Mevcut"NpcSayisi );
    
menu_additemmenuiMenu"3" );
    
    
menu_setpropmenuMPROP_EXITMEXIT_ALL);
    
menu_setpropmenuMPROP_EXITNAME"\rCIKIS" );
    
    
menu_display(idmenu); 
    return 
PLUGIN_HANDLED


public 
NpcMenu_goidmenuitem )

    
    if( 
item == MENU_EXIT 
    { 
        
menu_destroymenu ); 
        return 
PLUGIN_HANDLED
    } 
    
    new 
info], szName64 ]; 
    new 
accesscallback
    
    
menu_item_getinfomenuitemaccessinfocharsmaxinfo ), szNamecharsmaxszName ), callback );
    
    new 
key str_to_numinfo ); 
    
    switch( 
key 
    { 
        case 
1
        { 
            if( !
is_user_aliveid ) ) return PLUGIN_HANDLED;
            
            
NpcOlusturid ); 
        } 
        case 
2
        { 
            if( !
is_user_aliveid ) ) return PLUGIN_HANDLED;
            
            new 
iEntVucutNPC64 ];
            
get_user_aimingidiEntVucut );
            
            if ( 
is_valid_entiEnt ) ) 
            { 
                
entity_get_stringiEntEV_SZ_classnameNPCcharsmaxNPC ) );
                
                if ( 
equalNPCNpcClass ) ) 
                { 
                    
remove_entityiEnt );
                    
NpcSayisi--; 
                    
client_printidprint_chat"[NPC] Bir NPC Kaldirildi." ); 
                } 
                
            } 
        } 
        case 
3
        { 
            
remove_entity_nameNpcClass );
            
NpcSayisi 0
            
client_printidprint_chat"[NPC] Butun NPC'ler Kaldirildi." );
        } 
    } 
    
    
    
menu_destroy(menu); 
    return 
PLUGIN_HANDLED
}
public 
fw_NpcTouchiEntid )  

    if( !
is_user_aliveid ) ) 
        return 
HAM_SUPERCEDE
    
    static 
FloatgametimeFloatCooldown32 ]; 
    
gametime get_gametime(); 
    
    if(
gametime 1.0 Cooldownid ]) { 
        new 
NPC64 ]; 
        
entity_get_stringiEntEV_SZ_classnameNPCcharsmaxNPC ) );
        
        if( 
equaliNPCNpcClass ) ) { 
            
Util_PlayAnimationiEntg_NpcTalkAnimationsrandomsizeof g_NpcTalkAnimations ) ] );
        } 
        
        
Cooldownid ] = gametime
    } 
    return 
HAM_IGNORED

public 
fw_NpcTakeDamageiEntinflictorattackerFloat:damagebits ) { 
    new 
NPC64 ]; 
    
entity_get_stringiEntEV_SZ_classnameNPCcharsmaxNPC ) );
    
    if( 
equaliNPCNpcClass ) )  { 
        
Util_PlayAnimationiEntg_NpcDamageAnimationsrandomsizeof g_NpcDamageAnimations ) ], 1.25 );
    } 

public 
fw_NpcKillediEntKiller ){ 
    new 
NPC64 ]; 
    
entity_get_stringiEntEV_SZ_classnameNPCcharsmaxNPC ) );
    
    if( 
equaliNPCNpcClass ) )  { 
        
g_NpcOlduiEnt ] = true
        
Util_PlayAnimation(iEntg_NpcDeathAnimationsrandomsizeof g_NpcDeathAnimations ) ] );
        
entity_set_intiEntEV_INT_solidSOLID_NOT );
        
entity_set_intiEntEV_INT_deadflagDEAD_DEAD );
        
entity_set_float(iEntEV_FL_takedamage0.0 ); 
        
        
client_printKillerprint_chat"[NPC] NPC'yi oldurdunuz." ); 
        
        
set_task5.0"NpcOluyuKaldir"iEnt );
    } 
    return 
HAM_SUPERCEDE


public 
NpcOluyuKaldirNpc )  { 
    
remove_entityNpc ); 

public 
fw_NpcThinkiEnt ) { 
    if( !
is_valid_entiEnt ) ) 
        return 
HAM_SUPERCEDE
    
    new 
NPC64 ]; 
    
entity_get_stringiEntEV_SZ_classnameNPCcharsmaxNPC ) );
    
    
    if( !
equaliNPCNpcClass ) ) 
        return 
HAM_SUPERCEDE
    
    if( 
g_NpcOlduiEnt ] ) 
        return 
HAM_SUPERCEDE
    if(
yuruyor == 0) {
        
Util_PlayAnimation(iEntg_NpcIdleAnimationsrandomsizeof g_NpcIdleAnimations ) ] );
    }
    if(
yuruyor == 1) {
        
UselessFunction(iEnt)
        if(
gerisibende == 0) {
            
Util_PlayAnimation(iEnt,13)
            
set_task(0.7,"dbnde",iEnt)
        }
    }
    if(
yuruyor == 0) {
        
entity_set_floatiEntEV_FL_nextthinkget_gametime() + 5.0 );
    }
    if(
yuruyor == 1) {
        
entity_set_floatiEntEV_FL_nextthinkget_gametime() + 0.7 );
    }
    return 
HAM_IGNORED

public 
dbnde(iEnt) {
    
gerisibende 1
    Util_PlayAnimation
(iEnt,13)
    
set_task(0.7,"dbnde",iEnt)
}
public 
fw_NpcTraceAttack(iEntattackerFloatdamageFloatdirection[3], tracedamageBits) { 
    if( !
is_valid_entiEnt ) ) 
        return 
HAM_SUPERCEDE
    
    new 
NPC64 ]; 
    
entity_get_stringiEntEV_SZ_classnameNPCcharsmaxNPC ) );
    
    if( 
equaliNPCNpcClass ) )  { 
        if( 
entity_get_floatiEntEV_FL_takedamage ) == 0.0 )
            return 
HAM_SUPERCEDE
        
        new 
Floatend]; 
        
get_tr2traceTR_vecEndPosend );
        
        
message_beginMSG_BROADCAST,SVC_TEMPENTITY );
        
write_byteTE_BLOODSPRITE );
        
engfuncEngFunc_WriteCoordend] );
        
engfuncEngFunc_WriteCoordend] );
        
engfuncEngFunc_WriteCoordend] );
        
write_shortnpc_kan_spr_sprey );
        
write_shortnpc_kan_spr );
        
write_byte247 ); 
        
write_byterandom_num515 ) ); 
        
message_end(); 
    } 
    return 
HAM_IGNORED
}
stock Util_PlayAnimation(indexsequenceFloatframerate 1.0) { 
    
entity_set_float(indexEV_FL_animtimeget_gametime());
    
entity_set_float(indexEV_FL_framerate,  framerate);
    
entity_set_float(indexEV_FL_frame0.0);
    
entity_set_int(indexEV_INT_sequencesequence);
}   

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
}  
public 
NpcOlusturid )  { 
    new 
FloatOrigin], FloatAngle];
    
    new 
iEnt create_entity"info_target" );
    
    
entity_set_stringiEntEV_SZ_classnameNpcClass );
    
    
get_user_hitpointidOrigin );
    
Origin] += 70.0
    
entity_set_originiEntOrigin );
    
    
entity_get_vector(idEV_VEC_anglesAngle );
    
Angle] = 0.0
    
    
entity_set_vectoriEntEV_VEC_anglesAngle );
    
    
entity_set_modeliEntg_NpcModel );
    
entity_set_int(iEntEV_INT_movetypeMOVETYPE_PUSHSTEP );
    
    
entity_set_int(iEntEV_INT_solidSOLID_BBOX );
    
    
entity_set_floatiEntEV_FL_takedamage1.0 );
    
entity_set_floatiEntEV_FL_health500.0 );
    
    new 
Floatmins[3] = {-12.0, -12.00.0 };
    new 
Floatmaxs[3] = { 12.012.075.0 };
    
    
entity_set_size(iEntminsmaxs);
    
    
entity_set_byteiEntEV_BYTE_controller1125 );
    
    
    
drop_to_flooriEnt ); 
    
    
g_NpcOlduiEnt ] = false
    
NpcSayisi++; 
    
    
entity_set_floatiEntEV_FL_nextthinkget_gametime() + 1.0 );    
}
public 
UselessFunctioniEnt) {
    
Util_PlayAnimation(iEnt,13)
    new 
Float:fOrigin[3]
    new 
Float:fVelocity[3]
    
//new Float:fAngels[3]
    
    
peviEntpev_originfOrigin )
    
    
fVelocity[0] = -80.0 
    yuruyor 
1
    
//fAngels[0] = -80.0
    
    //set_pev(iEnt,pev_angles,fAngels) 
    
set_peviEntpev_velocityfVelocity )
    
    
set_task10.0"PutMeBackPLZ"iEnt )
    
}
public 
PutMeBackPLZ(iEnt) {
    new 
Float:fVelocity[3]
    
fVelocity[0] = 0.0
    set_pev
iEntpev_velocityfVelocity )
    
yuruyor 0
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1055\\ f0\\ fs16 \n\\ par }
*/ 
PawNod is offline
PawNod
Member
Join Date: Jun 2019
Location: Turkey
Old 06-29-2019 , 14:00   Re: Questin for enrtty
Reply With Quote #9

@HamletEagle when ı use FM_EmitSound if ı change weapon it is using
PawNod is offline
thEsp
BANNED
Join Date: Aug 2017
Old 06-29-2019 , 14:36   Re: Questin for enrtty
Reply With Quote #10

Quote:
Originally Posted by SHIELD755 View Post
Yes , like this :-
PHP Code:
public fm_cmdstart(iduc_handleseed){
    if(!
is_user_alive(id)) return

    new 
buttons get_uc(uc_handle,UC_Buttons)
    if(
buttons IN_USE){

      
////YOUR CODE BLA BLA 
    
}

Show the code of your entity
Okay... does this even work? No, you haven't tried yet as it is copy & paste from somewhere else for sure. How are you going to find if player is using the entity, if you can find the entity?
thEsp 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 03:08.


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