but when I started this plugin it doesn't work.
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fakemeta>
#include <fakemeta_util>
#include <fun>
#include <engine>
#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
#define PLUGIN "Frostnade"
#define VERSION "1.0"
#define AUTHOR "MeRcyLeZZ"
#define TEAM_T 1
#define TEAM_CT 2
#define TASK_FROSTNADE 1100
enum
{
TA_T,
TA_CT,
TA_SIZE
}
new cvar_hudcolor;
new cvar_fadecolor;
new cvar_frostnade_color;
new cvar_frostnade_duration;
new cvar_frostnade_frostself;
new cvar_frostnade_dmg;
new const sound_frost[] = "warcraft3/frostnova.wav";
new const sound_frost_player[] = "warcraft3/impalehit.wav";
new const sound_frost_break[] = "warcraft3/impalelaunch1.wav";
new const model_frostnade[] = "models/glassgibs.mdl";
new const model_frostnade_trail[] = "sprites/laserbeam.spr";
new const model_frostnade_explotion[] = "sprites/shockwave.spr";
new frostnade;
new frostnade_trail;
new frostnade_explotion;
new g_msgid_screenfade;
new g_timer;
new bool:bool_frosted[33];
new bool:bool_checkfrost[33];
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_touch("grenade", "player", "touch_nade")
register_event( "Damage", "event_damage_he", "be" )
cvar_hudcolor = register_cvar("hns_hudcolor", "255 0 0")
cvar_fadecolor = register_cvar("hns_fadecolor", "random")
cvar_frostnade_color = register_cvar("hns_frostnade_color", "255 0 0")
cvar_frostnade_duration = register_cvar("hns_frostnade_duration", "5")
cvar_frostnade_frostself = register_cvar("hns_frostnade_frostself", "1")
cvar_frostnade_dmg = register_cvar("hns_frostnade_dmg", "0")
g_msgid_screenfade = get_user_msgid("ScreenFade");
register_message(g_msgid_screenfade, "message_screenfade");
register_forward(FM_PlayerPreThink,"fwd_playerprethink");
register_forward(FM_PlayerPostThink, "fwd_playerpostthink")
register_forward(FM_Think,"fwd_think");
register_forward(FM_Touch, "fwd_touch");
register_forward(FM_SetModel, "fwd_setmodel");
register_forward(FM_AlertMessage, "fwd_alertmessage");
register_forward(FM_CreateNamedEntity, "fwd_createnamedentity");
register_forward(FM_GetGameDescription,"fwd_getgamedescription");
}
public plugin_cfg()
{
new file[64];
get_configsdir(file, 63)
format(file, 63, "%s/frost.cfg", file)
if(file_exists(file))
server_cmd("exec %s", file), server_exec()
}
public plugin_precache()
{
precache_sound(sound_frost)
precache_sound(sound_frost_player)
precache_sound(sound_frost_break)
frostnade = precache_model(model_frostnade)
frostnade_trail = precache_model(model_frostnade_trail)
frostnade_explotion = precache_model(model_frostnade_explotion)
}
public logevent_startround()
{
remove_task(TASK_FROSTNADE)
}
public fwd_setmodel(entity, const model[])
{
// Get grenade owner
static id
id = pev(entity, pev_owner);
// Grenade not yet thrown or owner not a player
if (!is_user_connected(id))
return FMRES_IGNORED;
if (equal(model,"models/w_smokegrenade.mdl")) // frost grenade
{
new r, g, b;
get_color(r, g, b, 3)
// Give it a glow
fm_set_rendering(entity,kRenderFxGlowShell, r, g, b, kRenderNormal, 16);
// And a colored trail
message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
write_byte(TE_BEAMFOLLOW);
write_short(entity); // entity
write_short(frostnade_trail);// sprite
write_byte(10); // life
write_byte(10); // width
write_byte(r); // r
write_byte(g); // g
write_byte(b); // b
write_byte(200); // brightness
message_end();
// Prevent flashbang from exploding
set_pev(entity, pev_nextthink, get_gametime() +2.0);
static args[2] // our task params
args[0] = entity; // entity id
args[1] = id;
// Actual explode event
set_task(1.5, "task_frost", TASK_FROSTNADE, args, sizeof args)
}
return FMRES_IGNORED;
}
/* FORWARDS */
public fwd_playerprethink(id)
{
if(is_user_alive(id))
{
if (bool_frosted[id])
{
set_pev(id, pev_velocity, Float:{0.0,0.0,0.0}) // stop motion
set_pev(id, pev_flags, pev(id, pev_flags) | FL_FROZEN); // prevent from moving
}
else if(bool_checkfrost[id])
{
if(g_timer <= 0 || get_user_team(id) == 1)
set_pev(id, pev_flags, pev(id, pev_flags) & ~FL_FROZEN); // prevent from moving
}
}
return FMRES_IGNORED;
}
public event_deathmsg()
{
new id = read_data(2);
set_task(0.1, "task_removefrost", id)
set_pev(id, pev_flags, pev(id, pev_flags) & ~FL_FROZEN);
}
public task_frost(const args[2])
{
static ent
ent = args[0]
new id = args[1];
// invalid entity
if (!pev_valid(ent)) return;
// get origin
static origin[3], Float:originF[3]
pev(ent, pev_origin, originF);
FVecIVec(originF, origin);
// explosion
create_blast3(origin);
// frost nade explode sound
engfunc(EngFunc_EmitSound, ent, CHAN_WEAPON, sound_frost, 1.0, ATTN_NORM, 0, PITCH_NORM)
// collisions
static victim
victim = -1;
while((victim = engfunc(EngFunc_FindEntityInSphere, victim, originF, 240.0)) != 0)
{
if(get_pcvar_num(cvar_frostnade_frostself))
{
if(!is_user_alive(victim) || bool_frosted[victim] || get_user_team(id) == get_user_team(victim))
{
if(victim != id || !is_user_alive(id))
continue;
}
}
else
{
if(!is_user_alive(victim) || bool_frosted[victim] || get_user_team(id) == get_user_team(victim))
continue;
}
new r, g, b;
get_color(r, g, b, 3)
// light blue glow while freezed
fm_set_rendering(victim,kRenderFxGlowShell,r ,g, b,kRenderNormal,25)
// play freeze sound
engfunc(EngFunc_EmitSound, victim, CHAN_WEAPON, sound_frost_player, 1.0, ATTN_NORM, 0, PITCH_NORM)
// add a blue tint to their screen
message_begin(MSG_ONE, g_msgid_screenfade, _, victim);
write_short(~0); // duration
write_short(~0); // hold time
write_short(0x0004); // flags: FFADE_STAYOUT
write_byte(r); // red
write_byte(g); // green
write_byte(b); // blue
write_byte(100); // alpha
message_end();
// prevent from jumping
if (pev(victim, pev_flags) & FL_ONGROUND)
set_pev(victim, pev_gravity, 999999.9) // set really high
else
set_pev(victim, pev_gravity, 0.000001) // no gravity
if(get_pcvar_num(cvar_frostnade_dmg))
{
new Float:health;
pev(victim, pev_health, health);
health -= float(get_pcvar_num(cvar_frostnade_dmg))
if(health <= 0)
{
user_silentkill(victim);
make_deathmsg(id, victim, 0, "frostnade")
}
else
set_pev(victim, pev_health, health);
}
// freeze the victim, and set a task to remove the freeze
bool_frosted[victim] = true;
bool_checkfrost[victim] = true;
set_task(get_pcvar_float(cvar_frostnade_duration), "task_removefrost", victim)
}
// get rid of the old grenade
engfunc(EngFunc_RemoveEntity, ent)
}
public task_removefrost(id) {
if (!bool_frosted[id]) // not alive / not frozen anymore
return;
// unfreeze
bool_frosted[id] = false;
set_task(1.0, "task_checkfrost", id)
// restore normal gravity
set_pev(id, pev_gravity, 1.0)
// play the broken glass sound
engfunc(EngFunc_EmitSound, id, CHAN_VOICE, sound_frost_break, 1.0, ATTN_NORM, 0, PITCH_NORM)
fm_set_rendering(id)
// clear screen fade
message_begin(MSG_ONE, g_msgid_screenfade, _, id);
write_short(0); // duration
write_short(0); // hold time
write_short(0); // flags
write_byte(0); // red
write_byte(0); // green
write_byte(0); // blue
write_byte(0); // alpha
message_end();
// get player's origin
static origin[3], Float:originF[3]
pev(id, pev_origin, originF)
FVecIVec(originF, origin)
// glass shatter
message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
write_byte(TE_BREAKMODEL);
write_coord(origin[0]); // x
write_coord(origin[1]); // y
write_coord(origin[2] + 24); // z
write_coord(16); // size x
write_coord(16); // size y
write_coord(16); // size z
write_coord(random_num(-50,50));// velocity x
write_coord(random_num(-50,50));// velocity y
write_coord(25); // velocity z
write_byte(10); // random velocity
write_short(frostnade); // model
write_byte(10); // count
write_byte(25); // life
write_byte(0x01); // flags: BREAK_GLASS
message_end();
}
public task_checkfrost(id) {
bool_checkfrost[id] = false;
}
get_color(&red, &grn, &blu, cvarid)
{
new color[16], r[4], g[4], b[4];
if(cvarid == 1)
get_pcvar_string(cvar_hudcolor, color, 15)
else if(cvarid == 2)
get_pcvar_string(cvar_fadecolor, color, 15)
else if(cvarid == 3)
get_pcvar_string(cvar_frostnade_color, color, 15)
parse(color, r, 3, g, 3, b, 3)
red = str_to_num(r);
grn = str_to_num(g);
blu = str_to_num(b);
}
create_blast3(const origin[3]) {
// smallest ring
new r, g, b;
get_color(r, g, b, 3)
message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
write_byte(TE_BEAMCYLINDER);
write_coord(origin[0]); // start X
write_coord(origin[1]); // start Y
write_coord(origin[2]); // start Z
write_coord(origin[0]); // something X
write_coord(origin[1]); // something Y
write_coord(origin[2] + 385); // something Z
write_short(frostnade_explotion); // sprite
write_byte(0); // startframe
write_byte(0); // framerate
write_byte(4); // life
write_byte(60); // width
write_byte(0); // noise
write_byte(r); // red
write_byte(g); // green
write_byte(b); // blue
write_byte(200); // brightness
write_byte(0); // speed
message_end();
// medium ring
message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
write_byte(TE_BEAMCYLINDER);
write_coord(origin[0]); // start X
write_coord(origin[1]); // start Y
write_coord(origin[2]); // start Z
write_coord(origin[0]); // something X
write_coord(origin[1]); // something Y
write_coord(origin[2] + 470); // something Z
write_short(frostnade_explotion); // sprite
write_byte(0); // startframe
write_byte(0); // framerate
write_byte(4); // life
write_byte(60); // width
write_byte(0); // noise
write_byte(r); // red
write_byte(g); // green
write_byte(b); // blue
write_byte(200); // brightness
write_byte(0); // speed
message_end();
// largest ring
message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
write_byte(TE_BEAMCYLINDER);
write_coord(origin[0]); // start X
write_coord(origin[1]); // start Y
write_coord(origin[2]); // start Z
write_coord(origin[0]); // something X
write_coord(origin[1]); // something Y
write_coord(origin[2] + 555); // something Z
write_short(frostnade_explotion); // sprite
write_byte(0); // startframe
write_byte(0); // framerate
write_byte(4); // life
write_byte(60); // width
write_byte(0); // noise
write_byte(r); // red
write_byte(g); // green
write_byte(b); // blue
write_byte(200); // brightness
write_byte(0); // speed
message_end();
}
(Sorry for my bad english. I'm from Poland)