NadeType Ammo API v1.2

Post Reply
greenie
Full Member
Full Member
Posts: 1815
Joined: Sun Nov 21, 2021 4:55 pm
Jucator SA:MP ?: Nu
Nick:: greenie
Jucator CS ?: Nu

NadeType Ammo API v1.2

Post by greenie »

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
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
Extension coding:
General example:
// 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_cost, pcv_limit, pcv_team, pcv_select

new gID_NadeAmmoID

public plugin_init()
{
// Register the plugin
register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_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(id, getCvarNadeType(), 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_NONE, pcv_cost, pcv_limit, pcv_team)
}

public fw_NAA_ArmouryEffects(arment, NadeType:index, ammo_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(id, NadeType: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(id, NadeType:index, ammo_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(id, ent, NadeType:index, ammo_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(entity, pev_dmgtime, dmgtime)

// 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(entity, pev_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(entity, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16)
{
static Float:color[3]
color[0] = float(r)
color[1] = float(g)
color[2] = float(b)

set_pev(entity, pev_renderfx, fx)
set_pev(entity, pev_rendercolor, color)
set_pev(entity, pev_rendermode, render)
set_pev(entity, pev_renderamt, float(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 > 2 || val < 0)
val = 0

return NadeType:val
}

// Send status icon for user interface. (Not necesarily!)
sendStatusIcon(id, status, sprite_name[])
{
message_begin(MSG_ONE_UNRELIABLE, get_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();
}
.zip
Post Reply

Return to “Fun Stuff”