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

[ HELP ] Work with grenades?


Post New Thread Reply   
 
Thread Tools Display Modes
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 02-22-2017 , 20:42   Re: [ HELP ] Work with grenades?
Reply With Quote #11

Hey Depresie , The code that you gave me is to check which grenade was thrown?
__________________








CrazY. is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 02-23-2017 , 11:26   Re: [ HELP ] Work with grenades?
Reply With Quote #12

Use grenade_throw from csx.
__________________
HamletEagle is online now
Depresie
Veteran Member
Join Date: Nov 2013
Old 02-23-2017 , 16:07   Re: [ HELP ] Work with grenades?
Reply With Quote #13

Yes, that is called when the grenade is thrown..
__________________
Depresie is offline
JusTGo
Veteran Member
Join Date: Mar 2013
Old 02-23-2017 , 16:17   Re: [ HELP ] Work with grenades?
Reply With Quote #14

some how FM_SetModel s called twice so i don't advice using it in this case.
__________________
JusTGo is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 02-23-2017 , 16:36   Re: [ HELP ] Work with grenades?
Reply With Quote #15

It is called twice, first to set the grenade p_model then the w_model...
The script i posted is safe to be used, it is called only when the grenade is thrown, not when deployed or dropped
__________________
Depresie is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 02-24-2017 , 07:28   Re: [ HELP ] Work with grenades?
Reply With Quote #16

Quote:
Originally Posted by Depresie View Post
You could also detect grenade launching using FM_SetModel, check there for w_grenade model then check the classname of the entity not to be a weaponbox

PHP Code:
register_forward(FM_SetModel"fw_SetModel")

public 
fw_SetModel(iEntity, const szModel[])
{
    if(!
pev_valid(iEntity))
        return 
FMRES_IGNORED

    
if(strlen(szModel) < 8)
        return 
FMRES_IGNORED

    
if(szModel[7] != 'w' || szModel[8] != '_')
        return 
FMRES_IGNORED

    
if(equal(szModel"models/w_weaponbox.mdl"))
        return 
FMRES_IGNORED

    
static szClass[32]

    
entity_get_string(iEntityEV_SZ_classnameszClasscharsmax(szClass))

    if(!
equal(szClass"weaponbox"))
        return 
FMRES_IGNORED
        
        
// Grenade launched ( you can check for model to get what type of grenade it is, ex w_flashbang, w_smokegrenade, w_hegrenade 
Poor way. Using grenade_throw from csx as Hamlet stated is fine.

PHP Code:
public grenade_throwindex,greindex,wId ) {

    if(
wId != CSW_HEGRENADE
    return 
PLUGIN_CONTINUE;
    
    
// code //

__________________

Last edited by edon1337; 02-24-2017 at 07:40.
edon1337 is offline
JusTGo
Veteran Member
Join Date: Mar 2013
Old 02-24-2017 , 10:47   Re: [ HELP ] Work with grenades?
Reply With Quote #17

Quote:
Originally Posted by Depresie View Post
It is called twice, first to set the grenade p_model then the w_model...
The script i posted is safe to be used, it is called only when the grenade is thrown, not when deployed or dropped
afaik FM_SetModel isn't called when p model is set also from my testes its callled twice even if i m checking for w_ models.
__________________
JusTGo is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 02-24-2017 , 13:48   Re: [ HELP ] Work with grenades?
Reply With Quote #18

Quote:
Originally Posted by JusTGo View Post
afaik FM_SetModel isn't called when p model is set also from my testes its callled twice even if i m checking for w_ models.
It's called twice because it firstly sets weaponbox.mdl then it sets the model corresponding to the weapon packed into the box. You did something wrong if it's still called twice.
__________________
HamletEagle is online now
JusTGo
Veteran Member
Join Date: Mar 2013
Old 02-24-2017 , 14:57   Re: [ HELP ] Work with grenades?
Reply With Quote #19

Quote:
Originally Posted by HamletEagle View Post
It's called twice because it firstly sets weaponbox.mdl then it sets the model corresponding to the weapon packed into the box. You did something wrong if it's still called twice.
damn i registred the forward twice... amxmodx compiler should give a warning or somthing for such things xD.
__________________
JusTGo is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 02-24-2017 , 15:44   Re: [ HELP ] Work with grenades?
Reply With Quote #20

Quote:
Originally Posted by JusTGo View Post
amxmodx compiler should give a warning or somthing for such things xD.
Not going to happen.
__________________

Last edited by klippy; 02-24-2017 at 15:45.
klippy 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 05:13.


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