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

Remove HE grenade when it touches the ground


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
wicho
Veteran Member
Join Date: Feb 2012
Location: GuateAmala
Old 10-12-2019 , 01:42   Remove HE grenade when it touches the ground
Reply With Quote #1

Hi everybody, well I want to create a mini game that consists of the players only having the HE grenade and the objective is to throw them at the players, if the grenade touches the player he dies instantly, if the player throws the grenade and fails I want the moment he touches the ground disappears, I don't want it to explode just that it disappears and gives the player another grenade, my questions are first how can I make when the player receives the blow of the grenade dies instantly, second how can I make when the grenade touches the ground or anything other than the player removes the grenade and gives the player a new one, could you please give me an example? ... Thanks in advance
wicho is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-12-2019 , 10:39   Re: Remove HE grenade when it touches the ground
Reply With Quote #2

Try this
PHP Code:

#include <amxmodx>
#include <hamsandwich>
#include <engine>
#include <fakemeta>
#include <fun>

new const Version[] = "0.1";

#define MAX_PLAYERS 32

#define IsPlayer(%1)    (1<=%1<=MAX_PLAYERS)

public plugin_init() 
{
    
register_plugin"Grenades" Version "bugsy" );
    
    
RegisterHamHam_Touch "grenade" "Grenade_Touch" );
    
register_forwardFM_SetModel "SetModel" );
}

public 
Grenade_TouchiToucher iTouched )
{
    if ( 
cs_get_grenade_typeiToucher ) == CSW_HEGRENADE )
    {
        new 
iGrenadeThrower peviToucher pev_owner );
        
        if ( 
IsPlayeriTouched ) )
        {
            
set_peviToucher pev_dmgtime 0.0 );
            
ExecuteHamHam_TakeDamage iTouched iToucher iGrenadeThrower 999.9 DMG_GRENADE );
        }
        else
        {
            
set_peviToucher pev_flags peviToucher pev_flags ) | FL_KILLME );
            
call_thinkiToucher );
        }
        
        if ( 
is_user_aliveiGrenadeThrower ) )
            
give_itemiGrenadeThrower "weapon_hegrenade" );

        return 
HAM_HANDLED;
    }
    
    return 
HAM_IGNORED;



public 
SetModeliEntity , const szModel[] )
{
    if ( 
cs_get_grenade_typeiEntity ) == CSW_HEGRENADE )
    {
        
set_peviEntity pev_dmgtime 99999.0 );
    }
}
    
cs_get_grenade_typeindex 
{
    if (!
pev_valid(index))
        return 
0
    
    
new classname[9]
    
pev(indexpev_classnameclassname8)
    
    if (!
equal(classname"grenade"))
        return 
0
    
    
if (get_pdata_int(index96) & (1<<8))
        return 
CSW_C4
    
    
new bits get_pdata_int(index114)
    
    if (
bits & (1<<0))
        return 
CSW_HEGRENADE
    
else if (bits & (1<<1))
        return 
CSW_SMOKEGRENADE
    
else if (!bits)
        return 
CSW_FLASHBANG
    
    
return 0

__________________

Last edited by Bugsy; 10-13-2019 at 22:22.
Bugsy is offline
wicho
Veteran Member
Join Date: Feb 2012
Location: GuateAmala
Old 10-12-2019 , 11:49   Re: Remove HE grenade when it touches the ground
Reply With Quote #3

ok thanks i will try it when i get to my house, i just forgot to ask something else, how can i do so that the grenade doesn't explode in the air? I mean, when you throw the grenade in the air, it is only removed when it touches the ground or when it hits the player. Another thing if the player hits the player also gives him a grenade. thx for your help
wicho is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-12-2019 , 15:08   Re: Remove HE grenade when it touches the ground
Reply With Quote #4

Above code is updated based on your comments.
__________________
Bugsy is offline
JocAnis
Veteran Member
Join Date: Jun 2010
Old 10-12-2019 , 16:20   Re: Remove HE grenade when it touches the ground
Reply With Quote #5

Good job Bugsy, one question, what is exactly 'call_think' doing? I hope it can be used for smth else beside hegrenade
__________________
KZ Public Autocup - PrimeKZ

My blog: http://primekz.xyz (in progress...) - not active (dec 2022)
JocAnis is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 10-12-2019 , 17:00   Re: Remove HE grenade when it touches the ground
Reply With Quote #6

He used it to safely remove the entity after giving the entity the Flag FL_KILLME
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 10-12-2019 at 17:01.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-12-2019 , 17:01   Re: Remove HE grenade when it touches the ground
Reply With Quote #7

That is how I am killing the grenade entity, after setting the FL_KILLME flag.
__________________
Bugsy is offline
JocAnis
Veteran Member
Join Date: Jun 2010
Old 10-12-2019 , 18:54   Re: Remove HE grenade when it touches the ground
Reply With Quote #8

Hm okay, interesting

Ps nice timing hah
__________________
KZ Public Autocup - PrimeKZ

My blog: http://primekz.xyz (in progress...) - not active (dec 2022)
JocAnis is offline
wicho
Veteran Member
Join Date: Feb 2012
Location: GuateAmala
Old 10-13-2019 , 11:32   Re: Remove HE grenade when it touches the ground
Reply With Quote #9

bugsy I tested your code and it works fine but sometimes when I throw the grenade it doesn't give me a new grenade, I think that happens when I throw it to a map entity (func_wall, etc)
wicho is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-13-2019 , 11:34   Re: Remove HE grenade when it touches the ground
Reply With Quote #10

Quote:
Originally Posted by wicho View Post
bugsy I tested your code and it works fine but sometimes when I throw the grenade it doesn't give me a new grenade, I think that happens when I throw it to a map entity (func_wall, etc)
Ok, try the above updated code.
__________________
Bugsy 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 02:28.


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