rockett702 |
08-11-2007 05:03 |
Re: Sticky Nades
Hello, I am trying to use this mod on my gun game server.
I have put the .amxx and the .sma file in teh corect directories and have edited the .sma file to allow custom nades since I have custom skins on my server. The code is below:
Code:
/* AMX Mod X
* Sticky Nades
*
* (c) Copyright 2005-2006 by VEN
*
* This file is provided as is (no warranties)
*
* DESCRIPTION
* Plugin provide sticky effect for throwed (with +attack) grenades.
*
* FEATURES
* - ability to make nades stick to any object (default: stick to players only)
* - ability to exclude certain nade type from being sticky
*
* MODULES
* engine
* fakemeta (first feature only)
*
* CONFIGURATION
* ANY_OBJECT - uncomment to enable first feature
* Chahge other options only if you want to use second feature.
* CUSTOM_NADES - uncomment to enable second feature
* NADE_TYPES - number of total types of sticky nades (default: 3)
* NADE_MODEL - remove certain model to exclude appropriate nade
*
* CVARS
* amx_sticky_nades (0: OFF, 1: ON, default: 1) - disables/enables the plugin
*
* THANKS
* lickityspliff - for initial idea
*/
/* *************************************************** Init **************************************************** */
#include <amxmodx>
#include <engine>
#define CVAR "amx_sticky_nades"
#define ANY_OBJECT
#define CUSTOM_NADES
#if defined ANY_OBJECT
#include <fakemeta>
// do not change
#define BOUNCE_SOUNDS 4
new const BOUNCE_SOUND[BOUNCE_SOUNDS][] = {"weapons/grenade_hit1.wav", "weapons/grenade_hit2.wav", "weapons/grenade_hit3.wav", "weapons/he_bounce-1.wav"}
#endif
#if defined CUSTOM_NADES
#define NADE_TYPES 3
new const NADE_MODEL[NADE_TYPES][] = {"models/w_hegrenade.mdl", "models/w_flashbang.mdl", "models/w_smokegrenade.mdl"}
#endif
public plugin_init() {
register_plugin("Sticky Nades", "0.1", "VEN")
register_touch("grenade", "player", "touch_nade")
#if defined ANY_OBJECT
register_forward(FM_EmitSound, "forward_emit_sound")
#endif
register_cvar(CVAR, "1")
}
/* *************************************************** Base **************************************************** */
public touch_nade(nade, id) {
if (!is_nade_bounce(nade) || !get_cvar_num(CVAR) || is_nade_excluded(nade))
return
entity_set_edict(nade, EV_ENT_aiment, id)
entity_set_int(nade, EV_INT_movetype, MOVETYPE_FOLLOW)
entity_set_int(nade, EV_INT_sequence, 0)
}
#if defined ANY_OBJECT
public forward_emit_sound(nade, channel, sound[]) {
if (is_nade_bounce(nade)) {
for (new i = 0; i < BOUNCE_SOUNDS; ++i) {
if (equal(sound, BOUNCE_SOUND[i]) && !is_nade_excluded(nade)) {
entity_set_int(nade, EV_INT_movetype, MOVETYPE_NONE)
entity_set_int(nade, EV_INT_sequence, 0)
break
}
}
}
}
#endif
/* ************************************************** Stocks *************************************************** */
stock bool:is_nade_bounce(nade) {
return entity_get_int(nade, EV_INT_movetype) == MOVETYPE_BOUNCE
}
stock bool:is_nade_excluded(nade) {
#if defined CUSTOM_NADES
new i, model[32]
for (i = 0; i < NADE_TYPES; ++i) {
entity_get_string(nade, EV_SZ_model, model, 31)
if (equal(model, NADE_MODEL[i]))
break
}
if (i == NADE_TYPES)
return true
return false
#else
return nade != nade // i know what you are thinking about, i'm not insane, i use this to avoid the compile warning
#endif
}
/* **************************************************** EOF **************************************************** */
I am not sure what file I am supposed to put amx_sticky_nades
I have also activated the plugin by putting the .amxx under 3rd party plugins in the plugins.ini file.
P.S. I am a noob when it comes to this stuff and am amazed that I have gotten done what I have. Any help would be much appreciated. Thank you
|