Raised This Month: $ Target: $400
 0% 

Smoke events?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CrazyChickenTest
Member
Join Date: Jul 2010
Location: World ;)
Old 07-20-2011 , 10:42   Smoke events?
Reply With Quote #1

How can I capture the coordination of exploded smoke grenade?
I try to do code which will be infect players who went into smoke.
Are there any events or something which could help me to do that?
__________________
Respect ;)
CrazyChickenTest is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 07-20-2011 , 11:13   Re: Smoke events?
Reply With Quote #2

You can try something like :

Code:
stock getSGExplosionOrigin( const grenade, Float:origin[3] ) {     const m_SGExplosionPos = 115;         for( new i = 0; i < sizeof origin; i++ )     {         origin[ i ] = get_pdata_float( grenade, m_SGExplosionPos + i );     } }

and in your code :

Code:
new Float:smokeOrigin[3]; getSGExplosionOrigin( grenade, smokeOrigin );

Just an example.

Note : grenade is the "grenade" entity index.
__________________

Last edited by Arkshine; 07-20-2011 at 11:48.
Arkshine is offline
abdul-rehman
Veteran Member
Join Date: Jan 2010
Location: Khi, Pakistan
Old 07-20-2011 , 11:48   Re: Smoke events?
Reply With Quote #3

Quote:
Originally Posted by Arkshine View Post
You can try something like :

Code:
stock getSGExplosionOrigin( const grenade, Float:origin[3] ) {     const m_SGExplosionPos = 115;         for( new i = 0; i < sizeof origin; i++ )     {         origin[ 0 ] = get_pdata_float( grenade, m_SGExplosionPos + i );     } }
I dont get it your only retrieving the x-axis value through the offset and not the y-axis or z-axis one?
__________________

My Plugins For ZP

Inactive due to College and Studies
abdul-rehman is offline
Send a message via Yahoo to abdul-rehman Send a message via Skype™ to abdul-rehman
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 07-20-2011 , 11:54   Re: Smoke events?
Reply With Quote #4

I've already fixed before you post ;) but yes, it was obviously a typo.
__________________
Arkshine is offline
CrazyChickenTest
Member
Join Date: Jul 2010
Location: World ;)
Old 07-20-2011 , 12:08   Re: Smoke events?
Reply With Quote #5

ok but when I must called this function. how can I capture message when somebody threw smoke grenade?
__________________
Respect ;)
CrazyChickenTest is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 07-20-2011 , 13:49   Re: Smoke events?
Reply With Quote #6

http://www.amxmodx.org/funcwiki.php?go=func&id=578
__________________
Selling tons of my own private works.
Accepting paid work for clans and communities.
Don't hesitate to contact me.
bibu is offline
CrazyChickenTest
Member
Join Date: Jul 2010
Location: World ;)
Old 07-20-2011 , 13:51   Re: Smoke events?
Reply With Quote #7

thank You very much
__________________
Respect ;)
CrazyChickenTest is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 07-20-2011 , 13:58   Re: Smoke events?
Reply With Quote #8

You can use grenade_throw forward to hook when a grenade is thrown.
This forward is based on SetModel forward, in others words grenade_throw is called right after a throw(ing?) when the grenade model is applied.

The problem is : the explosion comes after, so you may think that's not a good way.
Here, a preview of a basic flow (and only what we need) of a smoke grenade explosion :

Code:
 You throw a grenade
    ┌ A new grenade entity spawns
    └ The smoke grenade model is applied on the entity → grenade_throw called.
        ┌ After 1.5 seconds, the grenade detonates
        ├ createsmoke.sc event is called. (big smoke)
        └ m_SGExplosionPos offset is set by the current grenade position.
            └ 0.1 second later, the grenade explodes.
                ┌ 0.1 second later, the smoke appears
                └ A second createsmoke.sc event is fired. (20 times, small smoke)
                    └ Grenade removed.
So, a solution would be to hook the createsmoke.sc event (the first) in grenade_throw and since we hook this forward, we don't need the offset anymore.
But since the player's id is not passed for this event, we need some trick.

An example :

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <csx>

new HandleFwdPlaybackEvent;
new Array:
HandleGrenadePlayerIdQueue;

public 
plugin_init()
{
    
register_plugin"""""" );
}

public 
grenade_throwplayergrenadeweaponId )
{
    if( 
weaponId == CSW_SMOKEGRENADE )
    {
        if( 
HandleGrenadePlayerIdQueue == Invalid_Array )
        {
            
HandleGrenadePlayerIdQueue ArrayCreate();
        }
    
        
ArrayPushCellHandleGrenadePlayerIdQueueplayer );
    
        if( !
HandleFwdPlaybackEvent )
        {
            
HandleFwdPlaybackEvent register_forwardFM_PlaybackEvent"OnPlaybackEvent" );
        }
    }
}

public 
OnPlaybackEvent( const flags, const client, const eventIndex, const Float:delay, const Float:origin[3] )
{
    if( 
HandleFwdPlaybackEvent )
    {
        new 
player ArrayGetCellHandleGrenadePlayerIdQueue);
        
ArrayDeleteItemHandleGrenadePlayerIdQueue);
        
        if( !
ArraySizeHandleGrenadePlayerIdQueue ) )
        {
            
ArrayDestroyHandleGrenadePlayerIdQueue );
            
            
unregister_forwardFM_PlaybackEventHandleFwdPlaybackEvent );
            
HandleFwdPlaybackEvent 0;
        }

        
// Use origin variable to get the explosion origin.
        //server_print( "Player %d - Explosion origin = %f %f %f", player, origin[ 0 ], origin[ 1 ], origin[ 2 ] );
    
}



Note #1 : It's an example, so it may need more check for example if player is still connected, or if you throw a grenade, the game is reset or new round and the grenade is removed right away without exploding, the Array would need to be destroy. Such situation where you need to check.

Note #2 : A more direct way would be simply to hook directly CGrenade::SG_Detonate() as post, with orpheu and retrieving the m_SGExplosionPos offset. If you don't care using Orpheu module, tell me.
__________________

Last edited by Arkshine; 07-20-2011 at 14:12.
Arkshine is offline
CrazyChickenTest
Member
Join Date: Jul 2010
Location: World ;)
Old 07-21-2011 , 01:38   Re: Smoke events?
Reply With Quote #9

biig thanks again
__________________
Respect ;)
CrazyChickenTest 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 00:48.


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