View Single Post
Plugin Info:     Modification:          Category:          Approver:   Arkshine (91)
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 08-07-2010 , 18:37   NadeType Ammo API v1.2
Reply With Quote #1

Description:
This mod offers the CS game a new dimension when we talk about nade ammo types. With it you can have all the grenade types you want.
Plugin features a maximum of 10 ammo types per nade. Meaning that you can add up to 9 new nade ammo types per nade. That means total of 30 different nades!

Some of them already included with the plugin are:
  • Frostnades (Thanks XxAvalanchexX)
  • Napalm Nades (Thanks MercyLeZZ)
  • Teleport Grenade (Translocator) (Thanks VEN)
  • Flare (Thanks Minimidget)
  • Concussion Grenade (Thanks VEN)
  • Negative Flash Grenades (Thanks KoST)
  • Gas Nades (Thanks Connor & xPaw)
  • He Grenade (Thanks Valve)
  • Flashbang (Thanks Valve)
  • Smoke grenade (Thanks Valve)
  • Tesla nade

Features:
- Nademodes compatible
- You can drop the nades (Thanks VEN)
- The limit of the ammo is set through cvars (Thanks v3x)
- You can add new nades (expendable ammo types)
- Everything is customizable

Installation:
Extract the archive in the cstrike folder

Ammo Types:
Block Nade

Extensions:
Descriptive Fire In The Hole

Commands:

This command makes the user change the ammo.
nda_change
say /nchange
say_team /nchange


This command makes the user drop the nade. (Only if enabled!)
drop

This command opens a menu that enables you to buy nade ammo types.
nda_menu
say /nadeammo
say_team /nadeammo


Cvars:
If you reconfigure the cvars a restart is required!
Main plugin
Code:
mp_obeybuyzone 1 // 1 - You need to be in buyzone to buy the nades, 0 - Does not matter where you buy them
mp_soundemittype 3 // 0 - no sounds, 1 - emit_sound (players arround you will hear), 2 - just the receiver hears, 3 - with emitambientsound (for blocking wallhackers)
mp_dropkill 1 // 0 - do not drop, 1 - drop all types of ammo, 2 - just one randomly
mp_dropalive 1  // 0 - no drop, 1 - can drop anytime, 2 - can't drop in freezetime, 3 - can't drop in buytime 
mp_ignorebuytime 1 // Ignores buytime when we buy nades (0 means that it does matter)


// Default Nades
mp_max_he 1 // Maximum he grenades that a user can buy
mp_max_fb 2 // Maximum flash bangs that a user can buy
mp_max_sg 1 // Maximum smoke grenades that a user can buy


mp_price_he 300 // Price of he grenades
mp_price_fb 200 // Price of flash bangs
mp_price_sg 300 // Price of smoke grenades


// Team cvars these can have the following values:
// -2 means special players, but the nade can be picked up by other players
// -1 means special players, so basically it is team independent, and because of the teams it cannot be picked up
//  0 all players can buy it and can pick it up
//  1 only terorists can buy pickup the nades
//  2 only CTs can buy pickup the nades
//  3 and 4 behave like 1 and 2 but the difference is that all the players can pickup the nades!!!

mp_team_he 0 
mp_team_fb 0 
mp_team_sg 0
Gas Nades
Description: These nades create a green smoke, that if the user breathes he will choke.
Code:
// Gas Nades

amx_gasnades 1 // 1 - enable the nades, 0 disable them
amx_gasdmg 5 // the damage the gas does when a user breathes it
amx_gasradius 175 // The radius of the damage
amx_gascheck 0.7 // Delay between the damage done to player. Ex: User takes damage, after 0.7 seconds he will take damage again
amx_gasobeyFF 0 // Friendly Fire
amx_gaslife 25 // How much seconds does the gas last
amx_smokegasp 1 // The *cough* sounds of the players when they brethe the gas
amx_gas_restore 0 // If the life of the player is restored after exiting the gas
amx_gas_nosmoke 0 // If the gasnades shouldn't create the green smoke


amx_gas_sel_nade 2 // The selected nade types: 2 means smokegrenade, 1 means flashbang, 0 means He grenade, other values are not accepted

amx_gas_price 450 // The price of the gas grenade
amx_gas_limit 1 // How many grenades a user can buy/pickup


// Team cvars these can have the following values:
// -2 means special players, but the nade can be picked up by other players
// -1 means special players, so basically it is team independent, and because of the teams it cannot be picked up
//  0 all players can buy it and can pick it up
//  1 only terorists can buy pickup the nades
//  2 only CTs can buy pickup the nades
//  3 and 4 behave like 1 and 2 but the difference is that all the players can pickup the nades!!!
amx_gas_team 0
Flares
Description: These nades are good for dark maps, useful for lighting up the halls
Code:
// Flares

flr_enable 1 // 1 - enable the nades, 0 - disable them
flr_duration 200.0 // Time in seconds after the flare will disappear
flr_price 50 // Flare price
flr_limit 6 // Flare limit for pickup and buy
flr_nadetype 2 // The selected nade types: 2 means smokegrenade, 1 means flashbang, 0 means He grenade, other values are not accepted

// Team cvars these can have the following values:
// -2 means special players, but the nade can be picked up by other players
// -1 means special players, so basically it is team independent, and because of the teams it cannot be picked up
//  0 all players can buy it and can pick it up
//  1 only terorists can buy pickup the nades
//  2 only CTs can buy pickup the nades
//  3 and 4 behave like 1 and 2 but the difference is that all the players can pickup the nades!!!
flr_teams 0
Frostnades
Description: These nades freezes opponents
Code:
// Frostnades

fn_enabled 1 // 1 - enable the nades, 0 - disable them
fn_nadetype 1 // The selected nade types: 2 means smokegrenade, 1 means flashbang, 0 means He grenade, other values are not accepted

fn_color "0 206 209" // The color of the effects

fn_by_radius 0.0  // If set above 0.0 it will make the frostnade freeze the players within a percentage of the radius (ex radius 100, fn_by_radius 60.0, if the user is closer than 60.0 the he will be frozen)
fn_hitself 1 // If owner is affected by the nade
fn_los 1 // Line of sight, if the nade sees the player he will be frozen
fn_maxdamage 20.0 // Max damage dealt to player
fn_mindamage 1.0 // Min damage dealt to player
fn_chill_maxchance 100.0 // Max Chill chance (slowdown)
fn_chill_minchance 100.0 // Min Chill chance (slowdown)
fn_chill_duration 7.0 // Chill duration (seconds)
fn_chill_variance 1.0 // If the chill with vary by +_1.0
fn_chill_speed 60.0 // The speed when chilled (60.0 means 60%)

fn_freeze_maxchance 110.0 // Max freeze chance
fn_freeze_minchance 40.0 // Min freeze chance (40 = 40%)
fn_freeze_duration 4.0 // Duration of freeze (seconds)
fn_freeze_variance 0.5 // Variance of the freeze

fn_price 300 // Price of the frosnade
fn_limit 1 // The limit of the frostnades

// Team cvars these can have the following values:
// -2 means special players, but the nade can be picked up by other players
// -1 means special players, so basically it is team independent, and because of the teams it cannot be picked up
//  0 all players can buy it and can pick it up
//  1 only terorists can buy pickup the nades
//  2 only CTs can buy pickup the nades
//  3 and 4 behave like 1 and 2 but the difference is that all the players can pickup the nades!!!

fn_teams 0
Concussion grenade
Description: These nades throw players in the air, good for climbing in high places
Code:
// Concussion Grenades

con_cost 400 // Price of the grenade
con_nadetype 0 // The selected nade types: 2 means smokegrenade, 1 means flashbang, 0 means He grenade, other values are not accepted
con_limit 2 // Number of nades that
 
// Team cvars these can have the following values:
// -2 means special players, but the nade can be picked up by other players
// -1 means special players, so basically it is team independent, and because of the teams it cannot be picked up
//  0 all players can buy it and can pick it up
//  1 only terorists can buy pickup the nades
//  2 only CTs can buy pickup the nades
//  3 and 4 behave like 1 and 2 but the difference is that all the players can pickup the nades!!!

con_team 0 

con_velocity 500.0 // Velocity of the thrown player
con_nofalldmg 1 // 0 - owner can throw himself but will have falldmg, 1 - owner can throw himself but does not have falldmg, 2 - owner can't throw himself
con_damage 20 // The damage of the nade
con_radius 300.0 // Radius of the nade
con_los 1 // Line of sight (if the grenade goes through walls 1 means that it does not go through walls!)
con_throwteammates 1 // If the nade throws even teammates (the damage of the fall is based on mp_firendlyfire cvar
Napalm Nades
Description: Nades used to fire up players, the fire can be extinguished if the player goes underwater
Code:
// Napalm grenades

napalm_on 1 // 1 - on, 0 - off
napalm_affect 0 // The selected nade types: 2 means smokegrenade, 1 means flashbang, 0 means He grenade, other values are not accepted


// Team cvars these can have the following values:
// -2 means special players, but the nade can be picked up by other players
// -1 means special players, so basically it is team independent, and because of the teams it cannot be picked up
//  0 all players can buy it and can pick it up
//  1 only terorists can buy pickup the nades
//  2 only CTs can buy pickup the nades
//  3 and 4 behave like 1 and 2 but the difference is that all the players can pickup the nades!!!

napalm_team  0

napalm_price 600 // Price of the nade
napalm_carrylimit 1 // Maximum of nades the player can carry
napalm_hitself 1 // If owner can put himself on flames
napalm_radius 240 // Radius
napalm_ff 0 // Friendly fire
napalm_spread 1 // If the fire spreads from player to others when touching
napalm_duration 5 // Duration of the flames 
napalm_damage 4 // Damage that the player receives every flame
napalm_cankill 1 // If the nade can kill 
napalm_slowdown 0.5 // The slowdown the player experiences when the flame burns
napalm_screamrate 20 // 20% chance that the player will scream when burning
napalm_los 1 // If the nade will affect players if a wall is between them (1 means that it will not harm players that the nade cannot see)
Negative grenades
Description: These grenades make the users invisible if they find themselves in the blast radius.
Code:
// Negative grenades

neg_on 1 // 1 - enable, 0 - disable
neg_affect 1 // The selected nade types: 2 means smokegrenade, 1 means flashbang, 0 means He grenade, other values are not accepted


// Team cvars these can have the following values:
// -2 means special players, but the nade can be picked up by other players
// -1 means special players, so basically it is team independent, and because of the teams it cannot be picked up
//  0 all players can buy it and can pick it up
//  1 only terorists can buy pickup the nades
//  2 only CTs can buy pickup the nades
//  3 and 4 behave like 1 and 2 but the difference is that all the players can pickup the nades!!!

neg_team 0

neg_price 1000 // Price
neg_carrylimit 1 // How many nades the user can carry 
neg_radius 240 // Radius of the nade
neg_hitself 1 // If the user can make himself invisible with the nade 
neg_lineofsight 1 // If nade makes invisible only the players that can see
neg_duration 10 // Seconds in which the user is invisible
neg_fadetime 5 // Seconds of fade time from the invisibility to totally visible
neg_slowdown 0.9 // The slowdown of the invisible player (0.9 means that he is slower when he is invisible) (1.1 faster)
Teleport nade (Translocator)
Description: This nade makes the user teleport to the location where the grenade explodes.
Code:
// Teleport nade (Translocator)

tsl_cost 500 // Price
tsl_limit 5 // Maximum grenades a user can buy/pickup
tsl_nadetype 2 // The selected nade types: 2 means smokegrenade, 1 means flashbang, 0 means He grenade, other values are not accepted


// Team cvars these can have the following values:
// -2 means special players, but the nade can be picked up by other players
// -1 means special players, so basically it is team independent, and because of the teams it cannot be picked up
//  0 all players can buy it and can pick it up
//  1 only terorists can buy pickup the nades
//  2 only CTs can buy pickup the nades
//  3 and 4 behave like 1 and 2 but the difference is that all the players can pickup the nades!!!

tsl_team 0
Tesla nades
Description: These nades electrocute the players around it even before it blows

Code:
// Tesla nades

tesla_on 1 // 1 - on, 0 - off
tesla_affect 0  // The selected nade types: 2 means smokegrenade, 1 means flashbang, 0 means He grenade, other values are not accepted


// Team cvars these can have the following values:
// -2 means special players, but the nade can be picked up by other players
// -1 means special players, so basically it is team independent, and because of the teams it cannot be picked up
//  0 all players can buy it and can pick it up
//  1 only terorists can buy pickup the nades
//  2 only CTs can buy pickup the nades
//  3 and 4 behave like 1 and 2 but the difference is that all the players can pickup the nades!!!

tesla_team 0

tesla_price 600 // Price
tesla_carrylimit 1 // The limit of the nades a player can carry/pickup
tesla_radius 600 // Radius of the nades
tesla_hitself 1 // If the nades affect the owner
tesla_ff 0 // Friendly fire
tesla_damage 20 // Damage of the nade on the sorrounding area before exploding
tesla_blowdmg 70 // Damage of the nade when it explodes
tesla_los 1 // Line of sight (if set to 1 the nade does not affect users through wall)
Extension coding:
General example:
PHP Code:

// We include all that we need
#include <amxmodx>
#include <engine>
#include <fakemeta>
#include <nadeammoapi>
#include <hamsandwich>

#define PLUGIN_NAME         "NDA Unkown Grenade"
#define PLUGIN_VERSION         "0.1"
#define PLUGIN_AUTHOR         "Me"

// Color of the nade defines
#define UGREN_R    255
#define UGREN_B    255
#define UGREN_G    255

// Global variables 
new pcv_costpcv_limitpcv_teampcv_select

new gID_NadeAmmoID

public plugin_init() 
{
    
// Register the plugin
    
register_plugin(PLUGIN_NAMEPLUGIN_VERSIONPLUGIN_AUTHOR)
    
    
pcv_cost register_cvar("gren_cost""400")
    
pcv_limit register_cvar("gren_limit""2")
    
pcv_team register_cvar("gren_team""0")
    
pcv_select register_cvar("gren_nadetype""0"// Hegrenade
    // Other cvars that make the nade more configurable
    
    // Register some buy commands    
    
register_clcmd("say buy_nade""buy_nade")
    
    
// We need this because we want to modify nade behaveor 
    
RegisterHam(Ham_Think"grenade""fw_ThinkGrenade")
}

public 
plugin_precache()
{
    
// Precache all the sounds/models that we need
}

public 
buy_nade(id)
{
    
// Use the stock that the plugin provides
    
BuyNade(idgetCvarNadeType(), gID_NadeAmmoID)
    return 
PLUGIN_CONTINUE
}

public 
fw_NAA_ExtentionInit()
{
    
// Here is where the main plugin askes for extension, we register everything 
    // Here we presume that we do not have a model for the armoury entity! So basically it is good to set it to ARMOURY_MODEL_NONE, so that the main plugin will know that the armoury does not have a specific model
    // The function returnes the Ammo_ID of our nade.
    // If we have a model that can set to the armoury we use with EngFunc_ModelIndex
    // Ex: RegisterNade("Flare", getCvarNadeType(), engfunc(EngFunc_ModelIndex, "models/w_flare.mdl"), cvar_price, cvar_limit, cvar_team) // Taken from flare.sma
    
gID_NadeAmmoID RegisterNade("My Awesome Grenade"getCvarNadeType(), ARMOURY_MODEL_NONEpcv_costpcv_limitpcv_team)
}

public 
fw_NAA_ArmouryEffects(armentNadeType:indexammo_type)
{
    
// If the ammo type is the same as the nade, if not do not do anything
    
if (ammo_type != gID_NadeAmmoID)
        return
    
    
// If the nadetype is the same with the one that we have made the set on, if false then do not do nothing
    
if (index != getCvarNadeType())
        return
    
    
// Here we add any kind of effects, sparks, rendering, etc.
    // DO NOT SET MODELS HERE! IF YOU SET MODELS THE ARMOURY ENTITY WILL NOT WORK! 
    // If you want to set models on armoury use the ARMOURY_MODEL argument in the RegisterNade native
    
    // Ex:
    // fm_set_rendering(arment, kRenderFxGlowShell, UGREN_R, UGREN_G, UGREN_B, kRenderTransTexture, 16)
}

public 
fw_NAA_CurNade(idNadeType:index)
{
    
// Here is when we change the weapon if we have a weapon then index will be GRENADE_INVALID, if we have then index will have one of the good GRENADE_ values
    // Here you can use to set the statusicon of the grenade so that user can identify it easily
    
    // This is the code for statusicon
    //if (index != getCvarNadeType())
    //    sendStatusIcon(id, 0, "dmg_whatever")
}

public 
fw_NAA_ChangeAmmo(idNadeType:indexammo_to)
{
    
// If we change the ammo to our nade, if not the ignore
    
if (index != getCvarNadeType())
        return
    
    
// Send status icon for id if the ammo is the one that interests us
    
sendStatusIcon(id, (ammo_to == gID_NadeAmmoID), "dmg_whatever")
}

public 
fw_NAA_NadeThrow(identNadeType:indexammo_type)
{
    if (
ammo_type != gID_NadeAmmoID)
        return
    
    if (
index != getCvarNadeType())
        return
    
    
// If we reached here it means that we have a our nade of interest (the nadetype and also the ammoid)
    
    // Set effects on the nade including models!!!
    // fm_set_rendering(ent, kRenderFxGlowShell, UGREN_R, UGREN_G, UGREN_B, kRenderTransTexture, 16)
    // entity_set_model(...)
}

public 
fw_ThinkGrenade(entity)
{
    
// Invalid entity we do not do anything
    
if (!pev_valid(entity)) return HAM_IGNORED;
    
    
// Get damage time of grenade (the moment when the grenade should explode)
    
static Float:dmgtime
    pev
(entitypev_dmgtimedmgtime)
    
    
// Check if it's time to go off, if not then we do not do anything
    
if (dmgtime get_gametime())
        return 
HAM_IGNORED;
    
    
// pev_NADEAMMOID and EV_INT_NADEAMMOID are the places where the ammotype of the nade is stored. It has been made this way so you can easily check it.
    // If it isn't our nade do not do anything
    
if (pev(entitypev_NADEAMMOID) != gID_NadeAmmoID)
        return 
HAM_IGNORED;
    
    
// If the nadetype is not the same. (Ex: smokegrenade != hegrenade) then don't do anything
    
if (getGrenadeIdentify(entity) != getCvarNadeType())
        return 
HAM_IGNORED;
    
    
// If we reached here means that we have our nade and the nade explodes!
    // We do here anything, explosion effects, damage, and also killing or others
    
    // Get rid of the grenade with the specially made stock!!!
    
fremoveEnt(entity)
    
    
// We stop the engine exploding the nade also
    
return HAM_SUPERCEDE
}

// Set entity's rendering type (from fakemeta_util)
fm_set_rendering(entityfx kRenderFxNone255255255render kRenderNormalamount 16)
{
    static 
Float:color[3]
    
color[0] = float(r)
    
color[1] = float(g)
    
color[2] = float(b)
    
    
set_pev(entitypev_renderfxfx)
    
set_pev(entitypev_rendercolorcolor)
    
set_pev(entitypev_rendermoderender)
    
set_pev(entitypev_renderamtfloat(amount))
}

// This we use to get the selected nade easily
NadeType:getCvarNadeType()
{
    new 
val get_pcvar_num(pcv_select)
    
    
// Default He grenade if inproper values
    
if (val || val 0)
        
val 0
    
    
return NadeType:val
}

// Send status icon for user interface. (Not necesarily!)
sendStatusIcon(idstatussprite_name[])
{
    
message_begin(MSG_ONE_UNRELIABLEget_user_msgid("StatusIcon"), _id);
    
write_byte(status); // status (0=hide, 1=show, 2=flash)
    
write_string(sprite_name); // sprite name
    
write_byte(UGREN_R); // red
    
write_byte(UGREN_G); // green
    
write_byte(UGREN_B); // blue
    
message_end();

How to make the plugin use special players for our nade (admins,zombie etc.)
PHP Code:
// We need to include biohazard for zombie condition tests.
#include <biohazard>

public plugin_init() 
{
    
// We set the team cvar to -1 or -2 which means special players, look at the ACCEPT constants from nadeammoapi includ efile
    
pcv_team register_cvar("gren_team""-1")
}

// When user tries to buy this nade this forward will execute, here we must test the conditions 
// Example zombie
public fw_NAA_CanPickup(idNadeType:indexammo_typePickupType:pickup)

    
// First we check if we deal with our nade type
    
    // Returning 0 means that the condition is invalid!!!! Diferent than 0 means that we have it valid!
    
if (ammo_type != gID_NadeAmmoID
        return 
0
     
    
if (index != getCvarNadeType()) 
        return 
0
    
    
// Ok we are here then we have our nade
    // pickup shows us information if the user picks up the nade or not
    // So now we do this:
    
    // If we buy the nade (this means that we should use a reason to print the player so that next time he should know when to buy the nade)
    
if (pickup == PICK_BUY)
    {
        
// This means that the user can buy!
        
if (is_user_zombie(id))
            return 
1
        
        
// Set the reason why the user can't buy the nade
        
SetReason("you aren't zombie")
        
        return 
0
    
}
    
    
// This means that we try to pickup the nade from the ground so we do not need the reason to print
    
return is_user_zombie(id) ? 0
}

// Admin example
public fw_NAA_CanPickup(idNadeType:indexammo_typePickupType:pickup)

    
// First we check if we deal with our nade type
    
    // Returning 0 means that the condition is invalid!!!! Diferent than 0 means that we have it valid!
    
if (ammo_type != gID_NadeAmmoID
        return 
0
     
    
if (index != getCvarNadeType()) 
        return 
0
    
    
// Ok we are here then we have our nade
    // pickup shows us information if the user picks up the nade or not
    // So now we do this:
    
    // If we buy the nade (this means that we should use a reason to print the player so that next time he should know when to buy the nade)
    
if (pickup == PICK_BUY)
    {
        
// This means that the user can buy!
        
if (get_user_flags(id) & ADMIN_CHAT)
            return 
1
        
        
// Set the reason why the user can't buy the nade
        
SetReason("you aren't admin")
        
        return 
0
    
}
    
    
// This means that we try to pickup the nade from the ground so we do not need the reason to print
    
return (get_user_flags(id) & ADMIN_CHAT) ? 0

Changelog:
PHP Code:
Version 1.0
Initial release

Version 1.1
Added new forwards/natives!
Fixed a small bug.
Added tesla nade

Version 1.2
Fixed a shield model problem
Added a new native for resetting view models
Added more checks for ammo refresh
Added VIP check when buying nades!
Added CreateArmoury native 
Screens:
SlideShow
With Models!
The Models are optional! The plugin works without them!

Credits:
Costin83 - Models! Models! And again Models!
Attached Files
File Type: zip Nade Models.zip (4.94 MB, 5990 views)
File Type: zip NadeAmmoCore.zip (506.2 KB, 5379 views)
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.

Last edited by Arkshine; 10-31-2010 at 11:13. Reason: 1.2 released
ot_207 is offline