AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Block Radio Command [SOLVED] | Create entity in front of Player [SOLVED] (https://forums.alliedmods.net/showthread.php?t=74484)

Grinf4ce 07-19-2008 16:29

Block Radio Command [SOLVED] | Create entity in front of Player [SOLVED]
 
Hello everyone,
How i can create an entity in front of the player?

(EXAMPLE) Like TeamFortress Classic:
If someone press drop a backpack, it will throw in front of the player.
How i can realize that?

- Grinf4ce

Drak 07-19-2008 20:55

Re: Create entity in front of Player
 
Actually, I'm in need of this two.

hzqst 07-19-2008 22:10

from bazooka(rpg) plugin
 
Quote:

new NUKERPG = create_entity("info_target")
new Float:Origin[3], Float:Angle[3]
get_user_origin(id,origin) entity_set_string(NUKERPG, EV_SZ_classname, "hahahanuke")
entity_set_model(NUKERPG, "models/rpgrocket.mdl")
entity_set_origin(NUKERPG, origin)
entity_get_vector(id, EV_VEC_v_angle, Angle)// ←return the angle(player)
entity_set_vector(NUKERPG, EV_VEC_angles, Angle)//set the angle of this entity

new Float:MinBox[3] = {-1.0, -1.0, -1.0}
new Float:MaxBox[3] = {1.0, 1.0, 1.0}
entity_set_vector(NUKERPG, EV_VEC_mins, MinBox)
entity_set_vector(NUKERPG, EV_VEC_maxs, MaxBox)
entity_set_int(NUKERPG, EV_INT_solid, 1)
entity_set_int(NUKERPG, EV_INT_movetype, 6)
new vec[3]
new Float:force = Float(999)
VelocityByAim(id, force, Vec) // important
entity_set_vector(NUKERPG, EV_VEC_velocity, Vec) // throw

danielkza 07-20-2008 01:51

Re: Create entity in front of Player
 
Code:

    new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString,"info_target"))
    if(!ent)
        return
   
    set_pev(ent,pev_classname, "env_whatever")
   
    new Float:vOrigin[3],Float:vAngles[3],Float:vAngleVector[3]
    pev(id,pev_origin,vOrigin)
    pev(id,pev_v_angle,vAngles)
    angle_vector(vAngles,1,vAngleVector)
   
    for(new i=0;i < 3;i++)
        // This will put the entity 50 units in front of the player's view angle
        fOrigin[i] += (vAngleVector[i] * 50)
       
    dllfunc(DLLFunc_Spawn,ent)


Grinf4ce 07-20-2008 01:53

Re: Create entity in front of Player
 
Oh new code..
i will try it :) @ danielkza

EDIT::
Hmm.. Doesnt work, because the back flow in the sky or very far of me away.. to the next wall.. :-(
It should drop in front of my feets :-/

Please help

Alka 07-20-2008 03:41

Re: Create entity in front of Player
 
Take a look in this plugin http://forums.alliedmods.net/showthread.php?p=19610

Grinf4ce 07-20-2008 04:57

Re: Create entity in front of Player
 
Hello Alka,
i taked a look in the plugin and created the function which drop a entity in front of me.

PHP Code:

new g_Classname[] = "func_backpack"
new g_Model[] = "models/tfm/backpack.mdl"

public drop_backpack(id) {
    new 
FloatOrigin[3], FloatVelocity[3]
    
entity_get_vector(idEV_VEC_originOrigin)

    new 
backpackdrop create_entity("info_target")
    if(!
backpackdrop) return

    
entity_set_string(backpackdropEV_SZ_classnameg_Classname)
    
entity_set_model(backpackdropg_Model)

    new 
Float:MinBox[3] = {-1.0, -1.0, -1.0}
    new 
Float:MaxBox[3] = {1.01.01.0}
    
entity_set_vector(backpackdropEV_VEC_minsMinBox)
    
entity_set_vector(backpackdropEV_VEC_maxsMaxBox)

    
entity_set_origin(backpackdropOrigin)

    
entity_set_int(backpackdropEV_INT_effects32)
    
entity_set_int(backpackdropEV_INT_solid1)
    
entity_set_int(backpackdropEV_INT_movetype6)
    
entity_set_edict(backpackdropEV_ENT_ownerid)

    
VelocityByAim(id400 Velocity)
    
entity_set_vector(backpackdropEV_VEC_velocity ,Velocity)


I tryed to "touch" the entity, but nothing happens..:
PHP Code:

public plugin_init() {
    
register_touch("player","*","hook_touch");
}

public 
hook_touch(pToucherpTouched) {
    if ( !
is_valid_ent(pToucher) ) return

    new 
Classname[32]
    
entity_get_string(pToucherEV_SZ_classnameClassname31)
    new 
Float:kOrigin[3]
    
entity_get_vector(pToucherEV_VEC_originkOrigin)

    if(
equal(Classname,g_Classname)) 
    {
        if ( !
is_valid_ent(pTouched) ) return
        
        
// Aufgehoben
        
client_print(pTouched,print_chat,"[TEST] You touched the entity dude..")
        
remove_entity(pToucher)
    }


Whats wrong? :-S
Please help me :-/

- Grinf4ce

danielkza 07-20-2008 05:08

Re: Create entity in front of Player
 
Quote:

Originally Posted by Grinf4ce (Post 655392)
Oh new code..
i will try it :) @ danielkza

EDIT::
Hmm.. Doesnt work, because the back flow in the sky or very far of me away.. to the next wall.. :-(
It should drop in front of my feets :-/

Please help

Try changing the 50 in the code to a small number,like 1 or 2.

Grinf4ce 07-20-2008 17:32

Re: Block Radio Commands [OPEN] | Create entity in front of Player [SOLVED]
 
Thank you :) I created a script to drop a entity infront of me and pick it up :)

But i have a new question:
How i can block radio command "Fire in the hole" when i throw a grenade? I would block the sound and the message, but how? :S

Can someone help me please?

- Grinf4ce

XxAvalanchexX 07-20-2008 18:46

Re: Block Radio Command [OPEN] | Create entity in front of Player [SOLVED]
 
http://forums.alliedmods.net/showthread.php?t=29293


All times are GMT -4. The time now is 05:29.

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