Raised This Month: $ Target: $400
 0% 

Spawn a HE grenade on player.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Voltron
Senior Member
Join Date: Jun 2007
Location: Above the battlefield.
Old 05-17-2011 , 02:50   Spawn a HE grenade on player.
Reply With Quote #1

Code:
new nade = engfunc(EngFunc_CreateNamedEntity, "armoury_entity");
set_pev(nade, pev_classname, "grenade"); 
entity_set_int(nade,EV_ENT_owner, owner); 
engfunc(EngFunc_SetOrigin, nade, playerOrigin); 
engfunc(EngFunc_SetModel, nade, "models/w_hegrenade.mdl");
set_pev(nade, pev_movetype, MOVETYPE_TOSS); 
set_pev(nade, pev_solid, SOLID_TRIGGER);
Doesn't spawn a nade.
What am I doing wrong?
__________________
Voltron is offline
Leon M.
Senior Member
Join Date: Apr 2009
Location: Germany
Old 05-17-2011 , 02:57   Re: Spawn a HE grenade on player.
Reply With Quote #2

What do you want exactly?

If a player should get a nade then use this:
PHP Code:
give_item(id"weapon_hegrenade"
Don't forget to include fun.inc (#include <fun>) at the beginning of your file.
__________________
  • ZapTic - Paintball (Version 7.1.3 b1303)
  • Your #1 CS Paintball Server since 2008
  • 85.131.163.101:27015
Leon M. is offline
Voltron
Senior Member
Join Date: Jun 2007
Location: Above the battlefield.
Old 05-17-2011 , 03:12   Re: Spawn a HE grenade on player.
Reply With Quote #3

Quote:
Originally Posted by Leon M. View Post
What do you want exactly?
I want to spawn a HE nade on or near a player and then detonate it.
__________________
Voltron is offline
Leon M.
Senior Member
Join Date: Apr 2009
Location: Germany
Old 05-17-2011 , 03:45   Re: Spawn a HE grenade on player.
Reply With Quote #4

I'm not sure if you can execute a detonation but you can create your own detonation.

PHP Code:
public plugin_init(){
        
//...
        
register_forward(FM_Think"fwd_think")
        
//...
}

// iVictim is your target ;)
public JohnDoe(iVictim){
                
//...

                // Create a fake hegrenade
                
new iEntity engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target"))

                
engfunc(EngFunc_SetModeliEntity"models/w_hegrenade.mdl")
                
set_pev(iEntitypev_classname"fake_hegrenade")
                
set_pev(iEntitypev_owneriVictim)
                
set_pev(iEntitypev_iuser10)
                
set_pev(iEntitypev_mins, { -2.5, -2.5, -2.5})
                
set_pev(iEntitypev_maxs, { 2.52.52.5})
                
set_pev(iEntitypev_solidSOLID_TRIGGER)
                
set_pev(iEntitypev_movetypeMOVETYPE_TOSS)

                
// That's your timer for the detonation
                
set_pev(iEntitypev_nextthinkget_gametime() + 10.0)

                new 
Float:f_vAngles[3] = { 0.00.00.0}
                
f_vAngles[1] = random_float(0.0180.0)
                
set_pev(iEntitypev_anglesf_vAngles)

                new 
Float:f_vOrigin[3]
                
pev(iVictimpev_originf_vOrigin)
                
f_vOrigin[0] += 10.0
                engfunc
(EngFunc_SetOriginiEntityf_vOrigin)

                
//...
}

public 
fwd_think(iEntity){
    if (!
pev_valid(iEntity)){
        return 
FMRES_IGNORED
    
}

    new 
szClass[20]
    
pev(iEntitypev_classnameszClass19)

    if (
equal(szClass"fake_hegrenade")){
        
func_nade_explode(iEntity)
    }
    return 
FMRES_IGNORED
}

public 
func_nade_explode(iEntity){

    
// ... Do anything

    // Remove the nade
    
engfunc(EngFunc_RemoveEntityiEntity)

__________________
  • ZapTic - Paintball (Version 7.1.3 b1303)
  • Your #1 CS Paintball Server since 2008
  • 85.131.163.101:27015
Leon M. 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 04:28.


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