Raised This Month: $94 Target: $400
 23% 

Nades Api


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   Counter-Strike        Category:   Technical/Development        Approver:   Arkshine (91)
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-26-2013 , 03:10   Nades Api
Reply With Quote #1

Nades Api



.: Description :.


Little Api that let's you know by forwards when a grenade is bouncing or is exploding, is smoking after the explosion, or is simply thinking because it's not time to to something else yet.
This plugin also exposes some natives to retrieve those functions indexes (internally it is pointers but we can use them as integers) that are used with pdata m_pThink and m_pUse.



.: How does the game works :.


When a grenade is shot, its m_pfnTouch function is set to BounceTouch, this function is called internally each time a nade is touching the world (sound is only played on 5 first times).

At grenade shot, m_pfnThink is set to TumbleThink for flash and hegrenade, and to SG_TumbleThink for smokegrenade, this is default think and ends when pev->dmgtime <= gpGlobals->time (and for smoke if nade is on the ground)
Then, m_pfnThink is change to Detonate, Detonate3 and SG_Detonate for respectlively flashbangs, hegrenades and smokegrenades, this is during those functions that specific grenade actions are done (flash, explosion and smoke).
After those actions it is not complitely finished, m_pfnThink is change to Smoke, Smoke3_C and SG_Smoke (same nades types order), this is function where you gonnna see little black smoke before a nade is about to die.



.: Forwards :.


Code:
// Flash forwards forward OnFlashNadenadeBounceTouch(ent, pOther); forward OnFlashNadeTumbleThink(ent); forward OnFlashNadeDetonate(ent); forward OnFlashNadeSmoke(ent); // HeGrenade forwards forward OnHeNadenadeBounceTouch(ent, pOther); forward OnHeNadeTumbleThink(ent); forward OnHeNadeDetonate(ent); forward OnHeNadeSmoke(ent); // SmokeGrenade forwards forward OnSmokeNadenadeBounceTouch(ent, pOther); forward OnSmokeNadeTumbleThink(ent); forward OnSmokeNadeDetonate(ent); forward OnSmokeNadeSmoke(ent);



.: Natives :.


Code:
// Returns TumbleThink index        // FLASH    // HE native Get_Nade_TumbleThink(); // Returns BounceTouch index        // FLASH    // HE   // SMOKE native Get_Nade_BounceTouch(); // Returns Detonate index         // FLASH native Get_Nade_Detonate(); // Returns Smoke index        // FLASH native Get_Nade_Smoke(); // Returns Detonate3 index      // HE native Get_Nade_Detonate3(); // Returns Smoke3_C index         // HE native Get_Nade_Smoke3_C(); // Returns SG_TumbleThink index  // SMOKE native Get_Nade_SG_TumbleThink(); // Returns SG_Detonate index        // SMOKE native Get_Nade_SG_Detonate(); // Returns SG_Smoke index         // SMOKE native Get_Nade_SG_Smoke();



.: Notes :.


You need those includes in order to compile plugin : https://forums.alliedmods.net/showth...01#post1712101
!! NEW !! Experimental version with C4 forwards and natives here : https://forums.alliedmods.net/showth...20#post1923720



Attached Files
File Type: sma Get Plugin or Get Source (nades_api.sma - 626 views - 10.1 KB)
File Type: inc nades_api.inc (1.3 KB, 545 views)
__________________
- tired and retired -

Last edited by ConnorMcLeod; 03-31-2013 at 19:25.
ConnorMcLeod is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-26-2013 , 03:11   Re: Nades Api
Reply With Quote #2

Example on how to make a flashbang grenade explode as a smokegrenade instead of blinding players :

Code:
#include <amxmodx> #include <nades_api> #tryinclude <cstrike_pdatas> #if !defined _cbaseentity_included         #assert Cstrike Pdatas and Offsets library required! Read the below instructions:   \                 1. Download it at forums.alliedmods.net/showpost.php?p=1712101#post1712101   \                 2. Put it into amxmodx/scripting/include/ folder   \                 3. Compile this plugin locally, details: wiki.amxmodx.org/index.php/Compiling_Plugins_%28AMX_Mod_X%29   \                 4. Install compiled plugin, details: wiki.amxmodx.org/index.php/Configuring_AMX_Mod_X#Installing #endif #define PLUGIN "" #define VERSION "0.0.1" #define SetThink(%0,%1) set_pdata_int(%0, m_pfnThink, %1, 0) new SG_Detonate new g_iEvent_CreateSmoke public plugin_init() {     register_plugin( PLUGIN, VERSION, "ConnorMcLeod" )     g_iEvent_CreateSmoke = engfunc(EngFunc_PrecacheEvent, 1, "events/createsmoke.sc")     set_task(2.0, "Retrieve_Functions") } public Retrieve_Functions() {     SG_Detonate = Get_Nade_SG_Detonate() } public OnFlashNadeDetonate( ent ) {     if( pev(ent, pev_flags) & FL_ONGROUND )     {         SetThink(ent, SG_Detonate)         set_pdata_short(ent, m_usEvent_Grenade, g_iEvent_CreateSmoke)     }     set_pev(ent, pev_nextthink, get_gametime() + 0.1)     return PLUGIN_HANDLED }
__________________
- tired and retired -

Last edited by ConnorMcLeod; 03-26-2013 at 03:15.
ConnorMcLeod is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Location: Portugal
Old 03-26-2013 , 18:33   Re: Nades Api
Reply With Quote #3

Man that is amazing
__________________
Jhob94 is offline
quilhos
Veteran Member
Join Date: Jun 2010
Old 03-26-2013 , 21:53   Re: Nades Api
Reply With Quote #4

Nice one, just one thing, this shouldn't be on section: "Code Snippets/Tutorial" ?
__________________
ELO RATING SYSTEM - SQL [COMPLETE]
Quote:
Originally Posted by Liverwiz View Post
DDDRRRRAAAAMMMMAAAAA!!!???

Put this shit on pause while i go get some popcorn!!
quilhos is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-27-2013 , 02:35   Re: Nades Api
Reply With Quote #5

Quote:
Originally Posted by quilhos View Post
Nice one, just one thing, this shouldn't be on section: "Code Snippets/Tutorial" ?
It is not a snippet or a tutorial, it is an api.
__________________
- tired and retired -
ConnorMcLeod is offline
quilhos
Veteran Member
Join Date: Jun 2010
Old 03-27-2013 , 07:42   Re: Nades Api
Reply With Quote #6

Then isnt exacly one plugin
__________________
ELO RATING SYSTEM - SQL [COMPLETE]
Quote:
Originally Posted by Liverwiz View Post
DDDRRRRAAAAMMMMAAAAA!!!???

Put this shit on pause while i go get some popcorn!!
quilhos is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-27-2013 , 13:13   Re: Nades Api
Reply With Quote #7

sma to amxx : plugin
__________________
- tired and retired -
ConnorMcLeod is offline
Kia
AlliedModders Donor
Join Date: Apr 2010
Location: In a world of madness
Old 03-27-2013 , 14:56   Re: Nades Api
Reply With Quote #8

Great Work Connor, it's very useful and saves me a lot of time.
__________________
Kia is offline
Sn!ff3r
Veteran Member
Join Date: Aug 2007
Location: Poland
Old 03-27-2013 , 18:49   Re: Nades Api
Reply With Quote #9

Really nice.
__________________
Join US - custom Zombie Server - Custom Addons:



Sn!ff3r is offline
Send a message via Skype™ to Sn!ff3r
quilhos
Veteran Member
Join Date: Jun 2010
Old 03-28-2013 , 09:15   Re: Nades Api
Reply With Quote #10

Quote:
Originally Posted by ConnorMcLeod View Post
sma to amxx : plugin
It depends the point of view xb
But great work by the way
__________________
ELO RATING SYSTEM - SQL [COMPLETE]
Quote:
Originally Posted by Liverwiz View Post
DDDRRRRAAAAMMMMAAAAA!!!???

Put this shit on pause while i go get some popcorn!!
quilhos 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 05:35.


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