Cerere noi efecte explozie frost nade&napalm nade

Categoria cu cereri de pluginuri si nu numai.

Moderators: Moderatori ajutatori, Moderatori, Echipa eXtreamCS.com

Forum rules
Accesează link-ul pentru a putea vedea regulile forumului

Daca doriti sa vi se modifice un plugin, va rugam postati aici .
User avatar
|NGU|Anonymus
Membru, skill +1
Membru, skill +1
Posts: 293
Joined: 26 May 2014, 15:26
Detinator Steam: Nu
CS Status: Citesc forumul eXtreamCS.com...!
Detinator server CS: In progres...
Has thanked: 16 times
Been thanked: 64 times

29 May 2014, 21:56

Descriere plugin cerut: vreau si eu pluginurile napalm nade si frost nade cu efectele de explozie:
http://img600.imageshack.us/img600/3762/74967590.png -napalm nade
http://img442.imageshack.us/img442/4862/77255796.png -frost nade

Alte informatii: Daca are cineva fisierele spr. Eu le-am cautat si nu le-am gasit.
Am incercat sa bag anumite spr. in frost nade dar nu apare efectul pe server

Va las si sma de la fiecare fisier in caz ca aveti nevoie:
Frost nade
| Afiseaza codul
#include <amxmodx>
#include <cstrike>
#include <fakemeta>
#include <fun>
#include <hamsandwich>

new const VERSION[] = "2.14";

#define message_begin_fl(%1,%2,%3,%4) engfunc(EngFunc_MessageBegin, %1, %2, %3, %4)
#define write_coord_fl(%1) engfunc(EngFunc_WriteCoord, %1)

#define m_pPlayer			41
#define m_pActiveItem		373
#define m_flFlashedUntil	514
#define m_flFlashHoldTime	517
#define OFFSET_WEAPON_CSWID	43
#define Ham_Player_ResetMaxSpeed Ham_Item_PreFrame

#define MAX_WEAPONS		32
#define AMMO_FLASHBANG		11
#define AMMO_HEGRENADE		12
#define AMMO_SMOKEGRENADE	13
#define DMG_GRENADE		(1<<24) // thanks arkshine
#define FFADE_IN			0x0000 // just here so we don't pass 0 into the function
#define BREAK_GLASS		0x01
#define STATUS_HIDE		0
#define STATUS_SHOW		1
#define STATUS_FLASH		2

#define GLOW_AMOUNT		1.0
#define FROST_RADIUS		240.0

#define NT_FLASHBANG		(1<<0) // 1; CSW:25
#define NT_HEGRENADE		(1<<1) // 2; CSW:4
#define NT_SMOKEGRENADE		(1<<2) // 4; CSW:9

new const GRENADE_NAMES[][] = {
	"weapon_hegrenade",
	"weapon_flashbang",
	"weapon_smokegrenade"
};

#define ICON_HASNADE		1
#define ICON_ISCHILLED		2

#define TASK_REMOVE_CHILL	100
#define TASK_REMOVE_FREEZE	200

new const MODEL_FROZEN[]	= "models/pi_shrub.mdl";
new const MODEL_GLASSGIBS[]	= "models/glassgibs.mdl";

new const SOUND_EXPLODE[]	= "x/x_shoot1.wav";
new const SOUND_FROZEN[]	= "debris/glass1.wav";
new const SOUND_UNFROZEN[]	= "debris/glass3.wav";
new const SOUND_CHILLED[]	= "player/pl_duct2.wav";
new const SOUND_PICKUP[]	= "items/gunpickup2.wav";

new const SPRITE_TRAIL[]	= "sprites/laserbeam.spr";
new const SPRITE_SMOKE[]	= "sprites/steam1.spr";
new const SPRITE_EXPLO[]	= "sprites/shockwave.spr";

new pcv_enabled, pcv_override, pcv_nadetypes, pcv_teams, pcv_price, pcv_limit, pcv_buyzone, pcv_color, pcv_icon,
		pcv_by_radius, pcv_hitself, pcv_los, pcv_maxdamage, pcv_mindamage, pcv_chill_maxchance, pcv_chill_minchance,
		pcv_chill_duration, pcv_chill_variance, pcv_chill_speed, pcv_freeze_maxchance, pcv_freeze_minchance,
		pcv_freeze_duration, pcv_freeze_variance;

new maxPlayers, gmsgScreenFade, gmsgStatusIcon, gmsgBlinkAcct, gmsgAmmoPickup, gmsgTextMsg,
		gmsgWeapPickup, glassGibs, trailSpr, smokeSpr, exploSpr, mp_friendlyfire, czero, bot_quota, czBotHams, fmFwdPPT,
		fnFwdPlayerChilled, fnFwdPlayerFrozen, bool:roundRestarting;

new isChilled[33], isFrozen[33], frostKilled[33], novaDisplay[33], Float:glowColor[33][3], Float:oldGravity[33], oldRenderFx[33],
		Float:oldRenderColor[33][3], oldRenderMode[33], Float:oldRenderAmt[33], hasFrostNade[33], nadesBought[33];

public plugin_init()
{
	register_plugin("FrostNades",VERSION,"Avalanche");
	register_cvar("fn_version",VERSION,FCVAR_SERVER);

	pcv_enabled = register_cvar("fn_enabled","1");
	pcv_override = register_cvar("fn_override","1");
	pcv_nadetypes = register_cvar("fn_nadetypes","4"); // NT_SMOKEGRENADE
	pcv_teams = register_cvar("fn_teams","3");
	pcv_price = register_cvar("fn_price","300");
	pcv_icon = register_cvar("fn_icon","1");
	pcv_limit = register_cvar("fn_limit","0");
	pcv_buyzone = register_cvar("fn_buyzone","1");
	pcv_color = register_cvar("fn_color","0 206 209");

	pcv_by_radius = register_cvar("fn_by_radius","0.0");
	pcv_hitself = register_cvar("fn_hitself","1");
	pcv_los = register_cvar("fn_los","1");
	pcv_maxdamage = register_cvar("fn_maxdamage","20.0");
	pcv_mindamage = register_cvar("fn_mindamage","1.0");
	pcv_chill_maxchance = register_cvar("fn_chill_maxchance","100.0");
	pcv_chill_minchance = register_cvar("fn_chill_minchance","100.0");
	pcv_chill_duration = register_cvar("fn_chill_duration","7.0");
	pcv_chill_variance = register_cvar("fn_chill_variance","1.0");
	pcv_chill_speed = register_cvar("fn_chill_speed","60.0");
	pcv_freeze_maxchance = register_cvar("fn_freeze_maxchance","110.0");
	pcv_freeze_minchance = register_cvar("fn_freeze_minchance","40.0");
	pcv_freeze_duration = register_cvar("fn_freeze_duration","4.0");
	pcv_freeze_variance = register_cvar("fn_freeze_variance","0.5");
	
	mp_friendlyfire = get_cvar_pointer("mp_friendlyfire");
	
	new mod[6];
	get_modname(mod,5);
	if(equal(mod,"czero"))
	{
		czero = 1;
		bot_quota = get_cvar_pointer("bot_quota");
	}
	
	maxPlayers = get_maxplayers();
	gmsgScreenFade = get_user_msgid("ScreenFade");
	gmsgStatusIcon = get_user_msgid("StatusIcon");
	gmsgBlinkAcct = get_user_msgid("BlinkAcct");
	gmsgAmmoPickup = get_user_msgid("AmmoPickup");
	gmsgWeapPickup = get_user_msgid("WeapPickup");
	gmsgTextMsg = get_user_msgid("TextMsg");

	register_forward(FM_SetModel,"fw_setmodel",1);
	register_message(get_user_msgid("DeathMsg"),"msg_deathmsg");
	
	register_event("ResetHUD", "event_resethud", "b");
	register_event("TextMsg", "event_round_restart", "a", "2=#Game_Commencing", "2=#Game_will_restart_in");
	register_event("HLTV", "event_new_round", "a", "1=0", "2=0");

	RegisterHam(Ham_Spawn,"player","ham_player_spawn",1);
	RegisterHam(Ham_Killed,"player","ham_player_killed",1);
	RegisterHam(Ham_Player_ResetMaxSpeed,"player","ham_player_resetmaxspeed",1);
	RegisterHam(Ham_Think,"grenade","ham_grenade_think",0);
	RegisterHam(Ham_Use, "player_weaponstrip", "ham_player_weaponstrip_use", 1);
	
	for(new i=0; i<sizeof GRENADE_NAMES; i++)
	{
		RegisterHam(Ham_Item_Deploy, GRENADE_NAMES, "ham_grenade_deploy", 1);
		RegisterHam(Ham_Item_Holster, GRENADE_NAMES, "ham_grenade_holster", 1);
		RegisterHam(Ham_Item_AddToPlayer, GRENADE_NAMES, "ham_grenade_addtoplayer", 1);
		RegisterHam(Ham_Item_AddDuplicate, GRENADE_NAMES, "ham_grenade_addduplicate", 1);
	}
	
	register_clcmd("say /fn","buy_frostnade");
	register_clcmd("say_team /fn","buy_frostnade");
	register_clcmd("say /frostnade","buy_frostnade");
	register_clcmd("say_team /frostnade","buy_frostnade");
	
	fnFwdPlayerChilled = CreateMultiForward("frostnades_player_chilled", ET_STOP, FP_CELL, FP_CELL);
	fnFwdPlayerFrozen  = CreateMultiForward("frostnades_player_frozen",  ET_STOP, FP_CELL, FP_CELL);
}

public plugin_end()
{
	DestroyForward(fnFwdPlayerChilled);
	DestroyForward(fnFwdPlayerFrozen);
}

public plugin_precache()
{
	precache_model(MODEL_FROZEN);
	glassGibs = precache_model(MODEL_GLASSGIBS);

	precache_sound(SOUND_EXPLODE); // grenade explodes
	precache_sound(SOUND_FROZEN); // player is frozen
	precache_sound(SOUND_UNFROZEN); // frozen wears off
	precache_sound(SOUND_CHILLED); // player is chilled
	precache_sound(SOUND_PICKUP); // player buys frostnade

	trailSpr = precache_model(SPRITE_TRAIL);
	smokeSpr = precache_model(SPRITE_SMOKE);
	exploSpr = precache_model(SPRITE_EXPLO);
}

public client_putinserver(id)
{
	isChilled[id] = 0;
	isFrozen[id] = 0;
	frostKilled[id] = 0;
	novaDisplay[id] = 0;
	hasFrostNade[id] = 0;
	
	if(czero && !czBotHams && is_user_bot(id) && get_pcvar_num(bot_quota) > 0)
		set_task(0.1,"czbot_hook_ham",id);
}

public client_disconnect(id)
{
	if(isChilled[id]) task_remove_chill(TASK_REMOVE_CHILL+id);
	if(isFrozen[id]) task_remove_freeze(TASK_REMOVE_FREEZE+id);
}

// registering a ham hook for "player" won't register it for CZ bots,
// for some reason. so we have to register it by entity. 
public czbot_hook_ham(id)
{
	if(!czBotHams && is_user_connected(id) && is_user_bot(id) && get_pcvar_num(bot_quota) > 0)
	{
		RegisterHamFromEntity(Ham_Spawn,id,"ham_player_spawn",1);
		RegisterHamFromEntity(Ham_Killed,id,"ham_player_killed",1);
		RegisterHamFromEntity(Ham_Player_ResetMaxSpeed,id,"ham_player_resetmaxspeed",1);
		czBotHams = 1;
	}
}

// intercept server log messages to replace grenade kills with frostgrenade kills
public plugin_log()
{
	static arg[512];
	
	if(get_pcvar_num(pcv_enabled) && read_logargc() >= 5)
	{
		read_logargv(1, arg, 7); // "killed"
		
		if(equal(arg, "killed"))
		{
			read_logargv(2, arg, 127); // info of player that was killed
			
			// get ID of player that was killed
			new dummy[1], killedUserId;
			parse_loguser(arg, dummy, 0, killedUserId);
			new killedId = find_player("k", killedUserId);
			
			if(killedId && frostKilled[killedId])
			{	
				// override with frostgrenade message
				read_logdata(arg, 511);
				replace(arg, 511, "with ^"grenade^"", "with ^"frostgrenade^"");				
				log_message("%s", arg);

				return PLUGIN_HANDLED;
			}
		}
	}
	
	return PLUGIN_CONTINUE;
}

/****************************************
* PRIMARY FUNCTIONS AND SUCH
****************************************/

public buy_frostnade(id)
{
	if(!get_pcvar_num(pcv_enabled) || get_pcvar_num(pcv_override))
		return PLUGIN_CONTINUE;

	if(!is_user_alive(id)) return PLUGIN_HANDLED;

	if(get_pcvar_num(pcv_buyzone) && !cs_get_user_buyzone(id))
	{
		// #Cstrike_NotInBuyZone won't work for some reason
		client_print(id,print_center,"You are not in a buy zone.");

		return PLUGIN_HANDLED;
	}

	if(!(get_pcvar_num(pcv_teams) & _:cs_get_user_team(id)))
	{
		// have to do it this way to format
		message_begin(MSG_ONE,gmsgTextMsg,_,id);
		write_byte(print_center);
		write_string("#Alias_Not_Avail");
		write_string("Frost Grenade");
		message_end();

		return PLUGIN_HANDLED;
	}

	if(hasFrostNade[id])
	{
		client_print(id,print_center,"#Cstrike_Already_Own_Weapon");
		return PLUGIN_HANDLED;
	}
	
	new limit = get_pcvar_num(pcv_limit);
	if(limit && nadesBought[id] >= limit)
	{
		client_print(id,print_center,"#Cstrike_TitlesTXT_Cannot_Carry_Anymore");
		return PLUGIN_HANDLED;
	}
	
	new money = cs_get_user_money(id), price = get_pcvar_num(pcv_price);

	// need more vespene gas
	if(money < price)
	{
		client_print(id,print_center,"#Cstrike_TitlesTXT_Not_Enough_Money");
		
		message_begin(MSG_ONE_UNRELIABLE,gmsgBlinkAcct,_,id);
		write_byte(2);
		message_end();

		return PLUGIN_HANDLED;
	}
	
	// try to use smokegrenade, then flashbang, then hegrenade
	new wpnid = CSW_SMOKEGRENADE, ammoid = AMMO_SMOKEGRENADE, wpnName[20] = "weapon_smokegrenade", type = get_pcvar_num(pcv_nadetypes);
	if(!(type & NT_SMOKEGRENADE))
	{
		if(type & NT_FLASHBANG)
		{
			wpnid = CSW_FLASHBANG;
			ammoid = AMMO_FLASHBANG;
			wpnName = "weapon_flashbang";
		}
		else if(type & NT_HEGRENADE)
		{
			wpnid = CSW_HEGRENADE;
			ammoid = AMMO_HEGRENADE;
			wpnName = "weapon_hegrenade";
		}
	}
	
	hasFrostNade[id] = wpnid;
	nadesBought[id]++;
	cs_set_user_money(id,money - price);

	new ammo = cs_get_user_bpammo(id,wpnid);

	// give him one
	if(!ammo) give_item(id,wpnName);
	else
	{
		cs_set_user_bpammo(id,wpnid,ammo+1);
		
		// just so the player can see what kind it is on his HUD

		message_begin(MSG_ONE,gmsgAmmoPickup,_,id);
		write_byte(ammoid);
		write_byte(ammo+1);
		message_end();

		message_begin(MSG_ONE,gmsgWeapPickup,_,id);
		write_byte(wpnid);
		message_end();
		
		// won't play via cs_set_user_bpammo
		engfunc(EngFunc_EmitSound,id,CHAN_ITEM,SOUND_PICKUP,VOL_NORM,ATTN_NORM,0,PITCH_NORM);
		
		// for icon management
		grenade_added(id, wpnid);
	}
	
	return PLUGIN_HANDLED;
}

// entity is given a model (used to detect for thrown grenades)
public fw_setmodel(ent,model[])
{
	if(!get_pcvar_num(pcv_enabled)) return FMRES_IGNORED;

	new owner = pev(ent,pev_owner);
	if(!is_user_connected(owner)) return FMRES_IGNORED;
	
	// this isn't going to explode
	new Float:dmgtime;
	pev(ent,pev_dmgtime,dmgtime);
	if(dmgtime == 0.0) return FMRES_IGNORED;
	
	new type, csw;
	if(model[7] == 'w' && model[8] == '_')
	{
		switch(model[9])
		{
			case 'h': { type = NT_HEGRENADE; csw = CSW_HEGRENADE; }
			case 'f': { type = NT_FLASHBANG; csw = CSW_FLASHBANG; }
			case 's': { type = NT_SMOKEGRENADE; csw = CSW_SMOKEGRENADE; }
		}
	}
	if(!type) return FMRES_IGNORED;
	
	new team = _:cs_get_user_team(owner);

	// have a frostnade (override off) ;OR; override enabled, on valid team, using valid frostnade type
	if(hasFrostNade[owner] == csw || (get_pcvar_num(pcv_override)
			&& (get_pcvar_num(pcv_teams) & team) && (get_pcvar_num(pcv_nadetypes) & type)))
	{
		// not using override
		if(hasFrostNade[owner] == csw)
		{
			hasFrostNade[owner] = 0;
			if(get_pcvar_num(pcv_icon) == ICON_HASNADE)
			{
				show_icon(owner, STATUS_HIDE);
			}
		}

		set_pev(ent,pev_team,team);
		set_pev(ent,pev_bInDuck,1); // flag it as a frostnade

		new rgb[3], Float:rgbF[3];
		get_rgb_colors(team,rgb);
		IVecFVec(rgb, rgbF);
		
		// glowshell
		set_pev(ent,pev_rendermode,kRenderNormal);
		set_pev(ent,pev_renderfx,kRenderFxGlowShell);
		set_pev(ent,pev_rendercolor,rgbF);
		set_pev(ent,pev_renderamt,16.0);

		set_beamfollow(ent,10,10,rgb,100);
	}

	return FMRES_IGNORED;
}

// freeze a player in place whilst he's frozen
public fw_playerprethink(id)
{
	/*if(isChilled[id])
	{
		// remember rendering changes
		new fx = pev(id,pev_renderfx), Float:color[3], mode = pev(id,pev_rendermode), Float:amount;
		pev(id,pev_rendercolor,color);
		pev(id,pev_renderamt,amount);

		if(fx != kRenderFxGlowShell)
		{
			oldRenderFx[id] = fx;
			set_pev(id,pev_renderfx,kRenderFxGlowShell);
		}
		if(color[0] != glowColor[id][0] || color[1] != glowColor[id][1] || color[2] != glowColor[id][2])
		{
			oldRenderColor[id] = color;
			set_pev(id,pev_rendercolor,glowColor[id]);
		}
		if(mode != kRenderNormal)
		{
			oldRenderMode[id] = mode;
			set_pev(id,pev_rendermode,kRenderNormal);
		}
		if(amount != GLOW_AMOUNT)
		{
			oldRenderAmt[id] = amount;
			set_pev(id,pev_renderamt,GLOW_AMOUNT);
		}
	}*/

	if(isFrozen[id])
	{
		set_pev(id,pev_velocity,Float:{0.0,0.0,0.0}); // stop motion
		
		new Float:gravity;
		pev(id,pev_gravity,gravity);
		
		// remember any gravity changes
		if(gravity != 0.000000001 && gravity != 999999999.9)
			oldGravity[id] = gravity;

		// if are on the ground and about to jump, set the gravity too high to really do so
		if((pev(id,pev_button) & IN_JUMP) && !(pev(id,pev_oldbuttons) & IN_JUMP) && (pev(id,pev_flags) & FL_ONGROUND))
			set_pev(id,pev_gravity,999999999.9);

		// otherwise, set the gravity so low that they don't fall
		else set_pev(id,pev_gravity,0.000000001);
	}
	
	return FMRES_IGNORED;
}

// override grenade kill message with skull and crossbones
public msg_deathmsg(msg_id,msg_dest,msg_entity)
{
	new victim = get_msg_arg_int(2);
	if(!is_user_connected(victim) || !frostKilled[victim]) return PLUGIN_CONTINUE;

	static weapon[8];
	get_msg_arg_string(4,weapon,7);
	if(equal(weapon,"grenade")) set_msg_arg_string(4,"frostgrenade");

	//frostKilled[victim] = 0;
	return PLUGIN_CONTINUE;
}

// catch HUD reset to re-display icon if necessary
public event_resethud(id)
{
	if(!is_user_alive(id) || !get_pcvar_num(pcv_enabled)) return;

	if(get_pcvar_num(pcv_icon) == ICON_HASNADE)
	{
		new status = player_has_frostnade(id);
		show_icon(id, status);
	}

	return;
}

// round is restarting (TAG: sv_restartround)
public event_round_restart()
{
	// just remember for event_new_round
	roundRestarting = true;
}

// start of a new round
public event_new_round()
{
	if(roundRestarting)
	{
		roundRestarting = false;
		
		// clear frost grenades from all players (for override mode)
		for(new i=1;i<=maxPlayers;i++)
		{
			hasFrostNade = 0;
		}
	}
}

// rezzed
public ham_player_spawn(id)
{
	nadesBought[id] = 0;
	
	if(is_user_alive(id))
	{
		if(isChilled[id]) task_remove_chill(TASK_REMOVE_CHILL+id);
		if(isFrozen[id]) task_remove_freeze(TASK_REMOVE_FREEZE+id);
	}
	
	return HAM_IGNORED;
}

// killed to death
public ham_player_killed(id)
{
	hasFrostNade[id] = 0;

	if(get_pcvar_num(pcv_enabled) && get_pcvar_num(pcv_icon) == ICON_HASNADE)
	{
		show_icon(id, STATUS_HIDE);
	}

	if(isChilled[id]) task_remove_chill(TASK_REMOVE_CHILL+id);
	if(isFrozen[id]) task_remove_freeze(TASK_REMOVE_FREEZE+id);
	
	return HAM_IGNORED;
}

// movement speed is changed
public ham_player_resetmaxspeed(id)
{
	if(get_pcvar_num(pcv_enabled))
	{
		set_user_chillfreeze_speed(id);
	}

	return HAM_IGNORED;
}

// grenade is ticking away
public ham_grenade_think(ent)
{
	// not a frostnade
	if(!pev_valid(ent) || !pev(ent,pev_bInDuck)) return HAM_IGNORED;
	
	new Float:dmgtime;
	pev(ent,pev_dmgtime,dmgtime);
	if(dmgtime > get_gametime()) return HAM_IGNORED;
	
	// and boom goes the dynamite
	frostnade_explode(ent);

	return HAM_SUPERCEDE;
}

// a player_weaponstrip is used
public ham_player_weaponstrip_use(ent, idcaller, idactivator, use_type, Float:value)
{
	if(idcaller >= 1 && idcaller <= maxPlayers)
	{
		// clear frostnade when using override
		hasFrostNade[idcaller] = 0;

		if(is_user_alive(idcaller) && get_pcvar_num(pcv_enabled) && get_pcvar_num(pcv_icon) == ICON_HASNADE)
		{
			new status = player_has_frostnade(idcaller);
			show_icon(idcaller, status);
		}
	}

	return HAM_IGNORED;
}

// some kind of grenade is deployed
public ham_grenade_deploy(ent)
{	
	if(pev_valid(ent))
	{
		grenade_deployed(get_pdata_cbase(ent, m_pPlayer, 4),
			get_pdata_int(ent, OFFSET_WEAPON_CSWID, 4));
	}
	
	return HAM_IGNORED;
}

// some kind of grenade is holstered
public ham_grenade_holster(ent)
{
	if(pev_valid(ent))
	{
		grenade_holstered(get_pdata_cbase(ent, m_pPlayer, 4),
			get_pdata_int(ent, OFFSET_WEAPON_CSWID, 4));
	}
	
	return HAM_IGNORED;
}

// some kind of grenade is added to a player's inventory
public ham_grenade_addtoplayer(ent, id)
{
	if(pev_valid(ent))
	{
		grenade_added(id, get_pdata_int(ent, OFFSET_WEAPON_CSWID, 4));
	}

	return HAM_IGNORED;
}

// some kind of grenade is added to a player's inventory, when he already has one
public ham_grenade_addduplicate(ent, orig)
{
	if(pev_valid(orig))
	{
		grenade_added(pev(orig, pev_owner), get_pdata_int(orig, OFFSET_WEAPON_CSWID, 4));
	}
	
	return HAM_IGNORED;
}

// handle when player id deploys a grenade with weapon id wid
grenade_deployed(id, wid)
{
	// if we should worry about managing my icon now
	if(get_pcvar_num(pcv_enabled) && is_user_alive(id) && get_pcvar_num(pcv_icon) == ICON_HASNADE)
	{
		// if I just switched to a frost grenade
		if( wid == hasFrostNade[id]
			|| (get_pcvar_num(pcv_override) && (get_pcvar_num(pcv_teams) & _:cs_get_user_team(id)) && is_wid_in_nadetypes(wid)) )
		{
			show_icon(id, STATUS_FLASH);
		}
	}
}

// handle when player id holsters a grenade with weapon id wid
grenade_holstered(id, wid)
{	
	// if we should worry about managing my icon now
	if(get_pcvar_num(pcv_enabled) && is_user_alive(id) && get_pcvar_num(pcv_icon) == ICON_HASNADE)
	{
		// if I just holstered a frost grenade		
		if( wid == hasFrostNade[id]
			|| (get_pcvar_num(pcv_override) && (get_pcvar_num(pcv_teams) & _:cs_get_user_team(id)) && is_wid_in_nadetypes(wid)) )
		{
			// only do STATUS_SHOW or STATUS_HIDE... during holster, current weapon
			// will still technically be the frost grenade, but we don't want to
			// mistakenly flash the icon				
			new status = (player_has_frostnade(id) != STATUS_HIDE ? STATUS_SHOW : STATUS_HIDE);
			show_icon(id, status);
		}
	}
}

// handle when player id gets a grenade with weapon id wid added to his inventory
grenade_added(id, wid)
{
	// if we should worry about managing my icon now
	if(get_pcvar_num(pcv_enabled) && is_user_alive(id) && get_pcvar_num(pcv_icon) == ICON_HASNADE)
	{
		// if I just got a frost grenade
		if( wid == hasFrostNade[id]
			|| (get_pcvar_num(pcv_override) && (get_pcvar_num(pcv_teams) & _:cs_get_user_team(id)) && is_wid_in_nadetypes(wid)) )
		{
			new status = player_has_frostnade(id);
			show_icon(id, status);
		}
	}
}

// a frost grenade explodes
public frostnade_explode(ent)
{
	new nadeTeam = pev(ent,pev_team), owner = pev(ent,pev_owner), Float:nadeOrigin[3];
	pev(ent,pev_origin,nadeOrigin);
	
	// make the smoke
	message_begin_fl(MSG_PVS,SVC_TEMPENTITY,nadeOrigin,0);
	write_byte(TE_SMOKE);
	write_coord_fl(nadeOrigin[0]); // x
	write_coord_fl(nadeOrigin[1]); // y
	write_coord_fl(nadeOrigin[2]); // z
	write_short(smokeSpr); // sprite
	write_byte(random_num(30,40)); // scale
	write_byte(5); // framerate
	message_end();
	
	// explosion
	create_blast(nadeTeam,nadeOrigin);
	emit_sound(ent,CHAN_ITEM,SOUND_EXPLODE,VOL_NORM,ATTN_NORM,0,PITCH_HIGH);

	// cache our cvars
	new ff = get_pcvar_num(mp_friendlyfire), Float:by_radius = get_pcvar_float(pcv_by_radius),
			hitself = get_pcvar_num(pcv_hitself), los = get_pcvar_num(pcv_los), Float:maxdamage = get_pcvar_float(pcv_maxdamage),
			Float:mindamage = get_pcvar_float(pcv_mindamage), Float:chill_maxchance = get_pcvar_float(pcv_chill_maxchance),
			Float:chill_minchance = get_pcvar_float(pcv_chill_minchance), Float:freeze_maxchance, Float:freeze_minchance;

	if(!by_radius)
	{
		freeze_maxchance = get_pcvar_float(pcv_freeze_maxchance);
		freeze_minchance = get_pcvar_float(pcv_freeze_minchance);
	}

	new ta, Float:targetOrigin[3], Float:distance, tr = create_tr2(), Float:fraction, Float:damage, gotFrozen = 0;
	for(new target=1;target<=maxPlayers;target++)
	{
		// dead, invincible, or self attack that is not allowed
		if(!is_user_alive(target) || pev(target,pev_takedamage) == DAMAGE_NO
		|| (pev(target,pev_flags) & FL_GODMODE) ||(target == owner && !hitself))
			continue;
		
		// this is a team attack with ff disabled, excluding self attack
		ta = (_:cs_get_user_team(target) == nadeTeam);
		if(ta && !ff && target != owner) continue;
		
		pev(target,pev_origin,targetOrigin);
		distance = vector_distance(nadeOrigin,targetOrigin);
		
		// too far
		if(distance > FROST_RADIUS) continue;

		// check line of sight
		if(los)
		{
			nadeOrigin[2] += 2.0;
			engfunc(EngFunc_TraceLine,nadeOrigin,targetOrigin,DONT_IGNORE_MONSTERS,ent,tr);
			nadeOrigin[2] -= 2.0;

			get_tr2(tr,TR_flFraction,fraction);
			if(fraction != 1.0 && get_tr2(tr,TR_pHit) != target) continue;
		}

		// damaged
		if(maxdamage > 0.0)
		{
			damage = radius_calc(distance,FROST_RADIUS,maxdamage,mindamage);
			if(ta) damage /= 2.0; // half damage for friendlyfire

			if(damage > 0.0)
			{
				frostKilled[target] = 1;
				ExecuteHamB(Ham_TakeDamage,target,ent,owner,damage,DMG_GRENADE);
				if(!is_user_alive(target)) continue; // dead now
				frostKilled[target] = 0;
			}
		}

		// frozen
		if((by_radius && radius_calc(distance,FROST_RADIUS,100.0,0.0) >= by_radius)
		|| (!by_radius && random_num(1,100) <= floatround(radius_calc(distance,FROST_RADIUS,freeze_maxchance,freeze_minchance))))
		{
			if(freeze_player(target,owner,nadeTeam))
			{
				gotFrozen = 1;
				emit_sound(target,CHAN_ITEM,SOUND_FROZEN,1.0,ATTN_NONE,0,PITCH_LOW);
			}
		}
		
		// chilled
		if(by_radius || random_num(1,100) <= floatround(radius_calc(distance,FROST_RADIUS,chill_maxchance,chill_minchance)))
		{
			if(chill_player(target,owner,nadeTeam))
			{
				if(!gotFrozen) emit_sound(target,CHAN_ITEM,SOUND_CHILLED,VOL_NORM,ATTN_NORM,0,PITCH_HIGH);
			}
		}
	}

	free_tr2(tr);
	set_pev(ent,pev_flags,pev(ent,pev_flags)|FL_KILLME);
}

freeze_player(id,attacker,nadeTeam)
{
	new fwdRetVal = PLUGIN_CONTINUE;
	ExecuteForward(fnFwdPlayerFrozen, fwdRetVal, id, attacker);
	
	if(fwdRetVal == PLUGIN_HANDLED || fwdRetVal == PLUGIN_HANDLED_MAIN)
	{
		return 0;
	}

	if(!isFrozen[id])
	{
		pev(id,pev_gravity,oldGravity[id]);

		// register our forward only when we need it
		if(!fmFwdPPT)
		{
			fmFwdPPT = register_forward(FM_PlayerPreThink,"fw_playerprethink",0);
		}
	}

	isFrozen[id] = nadeTeam;
	
	set_pev(id,pev_velocity,Float:{0.0,0.0,0.0});
	set_user_chillfreeze_speed(id);
	
	new Float:duration = get_pcvar_float(pcv_freeze_duration), Float:variance = get_pcvar_float(pcv_freeze_variance);
	duration += random_float(-variance,variance);

	remove_task(TASK_REMOVE_FREEZE+id);
	set_task(duration,"task_remove_freeze",TASK_REMOVE_FREEZE+id);
	
	if(!pev_valid(novaDisplay[id])) create_nova(id);
	
	if(get_pcvar_num(pcv_icon) == ICON_ISCHILLED)
	{
		show_icon(id, STATUS_FLASH);
	}
	
	return 1;
}

public task_remove_freeze(taskid)
{
	new id = taskid-TASK_REMOVE_FREEZE;
	
	if(pev_valid(novaDisplay[id]))
	{
		new Float:origin[3];
		pev(novaDisplay[id],pev_origin,origin);

		// add some tracers
		message_begin_fl(MSG_PVS,SVC_TEMPENTITY,origin,0);
		write_byte(TE_IMPLOSION);
		write_coord_fl(origin[0]); // x
		write_coord_fl(origin[1]); // y
		write_coord_fl(origin[2] + 8.0); // z
		write_byte(64); // radius
		write_byte(10); // count
		write_byte(3); // duration
		message_end();

		// add some sparks
		message_begin_fl(MSG_PVS,SVC_TEMPENTITY,origin,0);
		write_byte(TE_SPARKS);
		write_coord_fl(origin[0]); // x
		write_coord_fl(origin[1]); // y
		write_coord_fl(origin[2]); // z
		message_end();

		// add the shatter
		message_begin_fl(MSG_PAS,SVC_TEMPENTITY,origin,0);
		write_byte(TE_BREAKMODEL);
		write_coord_fl(origin[0]); // x
		write_coord_fl(origin[1]); // y
		write_coord_fl(origin[2] + 24.0); // z
		write_coord_fl(16.0); // size x
		write_coord_fl(16.0); // size y
		write_coord_fl(16.0); // size z
		write_coord(random_num(-50,50)); // velocity x
		write_coord(random_num(-50,50)); // velocity y
		write_coord_fl(25.0); // velocity z
		write_byte(10); // random velocity
		write_short(glassGibs); // model
		write_byte(10); // count
		write_byte(25); // life
		write_byte(BREAK_GLASS); // flags
		message_end();

		emit_sound(novaDisplay[id],CHAN_ITEM,SOUND_UNFROZEN,VOL_NORM,ATTN_NORM,0,PITCH_LOW);
		set_pev(novaDisplay[id],pev_flags,pev(novaDisplay[id],pev_flags)|FL_KILLME);
	}

	isFrozen[id] = 0;
	novaDisplay[id] = 0;
	
	// unregister forward if we are no longer using it
	unregister_prethink();

	if(!is_user_connected(id)) return;
	
	// restore speed, but then check for chilled
	ExecuteHam(Ham_Player_ResetMaxSpeed, id);
	set_user_chillfreeze_speed(id);

	set_pev(id,pev_gravity,oldGravity[id]);
	
	new status = STATUS_HIDE;
	
	// sometimes trail fades during freeze, reapply
	if(isChilled[id])
	{
		status = STATUS_SHOW;
		
		new rgb[3];
		get_rgb_colors(isChilled[id],rgb);
		set_beamfollow(id,30,8,rgb,100);
	}
	
	if(get_pcvar_num(pcv_icon) == ICON_ISCHILLED)
	{
		show_icon(id, status);
	}
}

chill_player(id,attacker,nadeTeam)
{
	new fwdRetVal = PLUGIN_CONTINUE;
	ExecuteForward(fnFwdPlayerChilled, fwdRetVal, id, attacker);
	
	if(fwdRetVal == PLUGIN_HANDLED || fwdRetVal == PLUGIN_HANDLED_MAIN)
	{
		return 0;
	}

	// we aren't already been chilled
	if(!isChilled[id])
	{
		oldRenderFx[id] = pev(id,pev_renderfx);
		pev(id,pev_rendercolor,oldRenderColor[id]);
		oldRenderMode[id] = pev(id,pev_rendermode);
		pev(id,pev_renderamt,oldRenderAmt[id]);

		isChilled[id] = nadeTeam; // fix -- thanks Exolent

		// register our forward only when we need it
		//if(!fmFwdPPT) fmFwdPPT = register_forward(FM_PlayerPreThink,"fw_playerprethink",0);
	}

	isChilled[id] = nadeTeam;
	
	set_user_chillfreeze_speed(id);
	
	new Float:duration = get_pcvar_float(pcv_chill_duration), Float:variance = get_pcvar_float(pcv_chill_variance);
	duration += random_float(-variance,variance);

	remove_task(TASK_REMOVE_CHILL+id);
	set_task(duration,"task_remove_chill",TASK_REMOVE_CHILL+id);

	new rgb[3];
	get_rgb_colors(nadeTeam,rgb);
	
	IVecFVec(rgb, glowColor[id]);
	
	// glowshell
	set_user_rendering(id, kRenderFxGlowShell, rgb[0], rgb[1], rgb[2], kRenderNormal, floatround(GLOW_AMOUNT));

	set_beamfollow(id,30,8,rgb,100);

	// I decided to let the frostnade tint override a flashbang,
	// because if you are frozen, then you have much bigger problems.

	// add a blue tint to their screen
	message_begin(MSG_ONE,gmsgScreenFade,_,id);
	write_short(floatround(4096.0 * duration)); // duration
	write_short(floatround(3072.0 * duration)); // hold time (4096.0 * 0.75)
	write_short(FFADE_IN); // flags
	write_byte(rgb[0]); // red
	write_byte(rgb[1]); // green
	write_byte(rgb[2]); // blue
	write_byte(100); // alpha
	message_end();
	
	if(get_pcvar_num(pcv_icon) == ICON_ISCHILLED && !isFrozen[id])
	{
		show_icon(id, STATUS_SHOW);
	}
	
	return 1;
}

public task_remove_chill(taskid)
{
	new id = taskid-TASK_REMOVE_CHILL;

	isChilled[id] = 0;
	
	// unregister forward if we are no longer using it
	//unregister_prethink();

	if(!is_user_connected(id)) return;
	
	// set speed to normal, then check for frozen
	ExecuteHam(Ham_Player_ResetMaxSpeed, id);
	set_user_chillfreeze_speed(id);

	// reset rendering
	set_user_rendering(id, oldRenderFx[id], floatround(oldRenderColor[id][0]), floatround(oldRenderColor[id][1]),
		floatround(oldRenderColor[id][2]), oldRenderMode[id], floatround(oldRenderAmt[id]));

	clear_beamfollow(id);

	// calculate end of flashbang
	new Float:flashedUntil = get_pdata_float(id,m_flFlashedUntil),
			Float:flashHoldTime = get_pdata_float(id,m_flFlashHoldTime),
			Float:endOfFlash = flashedUntil + (flashHoldTime * 0.67);
	
	// not blinded
	if(get_gametime() >= endOfFlash)
	{
		// clear tint
		message_begin(MSG_ONE,gmsgScreenFade,_,id);
		write_short(0); // duration
		write_short(0); // hold time
		write_short(FFADE_IN); // flags
		write_byte(0); // red
		write_byte(0); // green
		write_byte(0); // blue
		write_byte(255); // alpha
		message_end();
	}
	
	if(get_pcvar_num(pcv_icon) == ICON_ISCHILLED && !isFrozen[id])
	{
		show_icon(id, STATUS_HIDE);
	}
}

// make a frost nova at a player's feet
create_nova(id)
{
	new nova = engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"info_target"));

	engfunc(EngFunc_SetSize,nova,Float:{-8.0,-8.0,-4.0},Float:{8.0,8.0,4.0});
	engfunc(EngFunc_SetModel,nova,MODEL_FROZEN);

	// random orientation
	new Float:angles[3];
	angles[1] = random_float(0.0,360.0);
	set_pev(nova,pev_angles,angles);

	// put it at their feet
	new Float:novaOrigin[3];
	pev(id,pev_origin,novaOrigin);
	engfunc(EngFunc_SetOrigin,nova,novaOrigin);

	// make it translucent
	new rgb[3];
	get_rgb_colors(isFrozen[id], rgb);
	IVecFVec(rgb, angles); // let's just use angles

	set_pev(nova,pev_rendercolor,angles); // see above
	set_pev(nova,pev_rendermode,kRenderTransAlpha);
	set_pev(nova,pev_renderfx,kRenderFxGlowShell);
	set_pev(nova,pev_renderamt,128.0);

	novaDisplay[id] = nova;
}

/****************************************
* UTILITY FUNCTIONS
****************************************/

// check if prethink is still being used, if not, unhook it
unregister_prethink()
{
	if(fmFwdPPT)
	{
		new i;
		for(i=1;i<=maxPlayers;i++) if(/*isChilled ||*/ isFrozen) break;
		if(i > maxPlayers)
		{
			unregister_forward(FM_PlayerPreThink,fmFwdPPT,0);
			fmFwdPPT = 0;
		}
	}
}

// make the explosion effects
create_blast(team,Float:origin[3])
{
	new rgb[3];
	get_rgb_colors(team,rgb);

	// smallest ring
	message_begin_fl(MSG_PVS,SVC_TEMPENTITY,origin,0);
	write_byte(TE_BEAMCYLINDER);
	write_coord_fl(origin[0]); // x
	write_coord_fl(origin[1]); // y
	write_coord_fl(origin[2]); // z
	write_coord_fl(origin[0]); // x axis
	write_coord_fl(origin[1]); // y axis
	write_coord_fl(origin[2] + 385.0); // z axis
	write_short(exploSpr); // sprite
	write_byte(0); // start frame
	write_byte(0); // framerate
	write_byte(4); // life
	write_byte(60); // width
	write_byte(0); // noise
	write_byte(rgb[0]); // red
	write_byte(rgb[1]); // green
	write_byte(rgb[2]); // blue
	write_byte(100); // brightness
	write_byte(0); // speed
	message_end();

	// medium ring
	message_begin_fl(MSG_PVS,SVC_TEMPENTITY,origin,0);
	write_byte(TE_BEAMCYLINDER);
	write_coord_fl(origin[0]); // x
	write_coord_fl(origin[1]); // y
	write_coord_fl(origin[2]); // z
	write_coord_fl(origin[0]); // x axis
	write_coord_fl(origin[1]); // y axis
	write_coord_fl(origin[2] + 470.0); // z axis
	write_short(exploSpr); // sprite
	write_byte(0); // start frame
	write_byte(0); // framerate
	write_byte(4); // life
	write_byte(60); // width
	write_byte(0); // noise
	write_byte(rgb[0]); // red
	write_byte(rgb[1]); // green
	write_byte(rgb[2]); // blue
	write_byte(100); // brightness
	write_byte(0); // speed
	message_end();

	// largest ring
	message_begin_fl(MSG_PVS,SVC_TEMPENTITY,origin,0);
	write_byte(TE_BEAMCYLINDER);
	write_coord_fl(origin[0]); // x
	write_coord_fl(origin[1]); // y
	write_coord_fl(origin[2]); // z
	write_coord_fl(origin[0]); // x axis
	write_coord_fl(origin[1]); // y axis
	write_coord_fl(origin[2] + 555.0); // z axis
	write_short(exploSpr); // sprite
	write_byte(0); // start frame
	write_byte(0); // framerate
	write_byte(4); // life
	write_byte(60); // width
	write_byte(0); // noise
	write_byte(rgb[0]); // red
	write_byte(rgb[1]); // green
	write_byte(rgb[2]); // blue
	write_byte(100); // brightness
	write_byte(0); // speed
	message_end();

	// light effect
	message_begin_fl(MSG_PAS,SVC_TEMPENTITY,origin,0);
	write_byte(TE_DLIGHT);
	write_coord_fl(origin[0]); // x
	write_coord_fl(origin[1]); // y
	write_coord_fl(origin[2]); // z
	write_byte(floatround(FROST_RADIUS/5.0)); // radius
	write_byte(rgb[0]); // r
	write_byte(rgb[1]); // g
	write_byte(rgb[2]); // b
	write_byte(8); // life
	write_byte(60); // decay rate
	message_end();
}

// give an entity a beam trail
set_beamfollow(ent,life,width,rgb[3],brightness)
{
	clear_beamfollow(ent);

	message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
	write_byte(TE_BEAMFOLLOW);
	write_short(ent); // entity
	write_short(trailSpr); // sprite
	write_byte(life); // life
	write_byte(width); // width
	write_byte(rgb[0]); // red
	write_byte(rgb[1]); // green
	write_byte(rgb[2]); // blue
	write_byte(brightness); // brightness
	message_end();
}

// removes beam trails from an entity
clear_beamfollow(ent)
{
	message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
	write_byte(TE_KILLBEAM);
	write_short(ent); // entity
	message_end();
}

// gets the appropriate color and displays the frostnade icon to the player with the given status
show_icon(id, status)
{
	static rgb[3];
	if(status) get_rgb_colors(_:cs_get_user_team(id), rgb); // only get colors if we need to
	
	message_begin(MSG_ONE,gmsgStatusIcon,_,id);
	write_byte(status); // status (0=hide, 1=show, 2=flash)
	write_string("dmg_cold"); // sprite name
	write_byte(rgb[0]); // red
	write_byte(rgb[1]); // green
	write_byte(rgb[2]); // blue
	message_end();
}

// checks if a weapon id is included in fn_nadetypes
is_wid_in_nadetypes(wid)
{
	new types = get_pcvar_num(pcv_nadetypes);
	
	return ( (wid == CSW_HEGRENADE && (types & NT_HEGRENADE))
		|| (wid == CSW_FLASHBANG && (types & NT_FLASHBANG))
		|| (wid == CSW_SMOKEGRENADE && (types & NT_SMOKEGRENADE)) );
}

// checks if a player has a frostnade, taking into account fn_override and such.
// returns: STATUS_HIDE = no frostnade, STATUS_SHOW = has frostnade but not deployed, STATUS_FLASH = has frostnade and deployed
player_has_frostnade(id)
{
	new retVal = STATUS_HIDE, curwpn = get_user_weapon(id);
	
	// no override, variable explicitly set
	if(hasFrostNade[id])
	{
		retVal = (curwpn == hasFrostNade[id] ? STATUS_FLASH : STATUS_SHOW);
	}
	
	// override enabled, and I'm on the right team
	else if(get_pcvar_num(pcv_override) && (get_pcvar_num(pcv_teams) & _:cs_get_user_team(id)))
	{		
		new types = get_pcvar_num(pcv_nadetypes);
					
		if((types & NT_HEGRENADE) && cs_get_user_bpammo(id, CSW_HEGRENADE) > 0)
		{
			retVal = (curwpn == CSW_HEGRENADE ? STATUS_FLASH : STATUS_SHOW);
		}
		
		if(retVal != STATUS_FLASH && (types & NT_FLASHBANG) && cs_get_user_bpammo(id, CSW_FLASHBANG) > 0)
		{
			retVal = (curwpn == CSW_FLASHBANG ? STATUS_FLASH : STATUS_SHOW);
		}
		
		if(retVal != STATUS_FLASH && (types & NT_SMOKEGRENADE) && cs_get_user_bpammo(id, NT_SMOKEGRENADE) > 0)
		{
			retVal = (curwpn == NT_SMOKEGRENADE ? STATUS_FLASH : STATUS_SHOW);
		}
	}
	
	return retVal;
}

// gets RGB colors from the cvar
get_rgb_colors(team,rgb[3])
{
	static color[12], parts[3][4];
	get_pcvar_string(pcv_color,color,11);
	
	// if cvar is set to "team", use colors based on the given team
	if(equali(color,"team",4))
	{
		if(team == 1)
		{
			rgb[0] = 150;
			rgb[1] = 0;
			rgb[2] = 0;
		}
		else
		{
			rgb[0] = 0;
			rgb[1] = 0;
			rgb[2] = 150;
		}
	}
	else
	{
		parse(color,parts[0],3,parts[1],3,parts[2],3);
		rgb[0] = str_to_num(parts[0]);
		rgb[1] = str_to_num(parts[1]);
		rgb[2] = str_to_num(parts[2]);
	}
}

// scale a value equally (inversely?) with the distance that something
// is from the center of another thing. that makes pretty much no sense,
// so basically, the closer we are to the center of a ring, the higher
// our value gets.
//
// EXAMPLE: distance = 60.0, radius = 240.0, maxVal = 100.0, minVal = 20.0
// we are 0.75 (1.0-(60.0/240.0)) of the way to the radius, so scaled with our
// values, it comes out to 80.0 (20.0 + (0.75 * (100.0 - 20.0)))
Float:radius_calc(Float:distance,Float:radius,Float:maxVal,Float:minVal)
{
	if(maxVal <= 0.0) return 0.0;
	if(minVal >= maxVal) return minVal;
	return minVal + ((1.0 - (distance / radius)) * (maxVal - minVal));
}

// sets a user's chilled/frozen speed if applicable
// (NOTE: does NOT reset his maxspeed if he is not chilled/frozen)
set_user_chillfreeze_speed(id)
{
	if(isFrozen[id])
	{
		set_user_maxspeed(id, 1.0);
	}
	else if(isChilled[id])
	{
		set_user_maxspeed(id, get_default_maxspeed(id)*(get_pcvar_float(pcv_chill_speed)/100.0));
	}
}

// gets the maxspeed a user should have, given his current weapon
stock Float:get_default_maxspeed(id)
{	
	new wEnt = get_pdata_cbase(id, m_pActiveItem), Float:result = 250.0;

	if(pev_valid(wEnt))
	{
		ExecuteHam(Ham_CS_Item_GetMaxSpeed, wEnt, result);
	}
	
	return result;
}

Napalm nade:
| Afiseaza codul
/*================================================================================
	
	------------------------
	-*- Napalm Nades 1.3 -*-
	------------------------
	
	~~~~~~~~~~~~~~~
	- Description -
	~~~~~~~~~~~~~~~
	
	This plugin turns one of the default grenades into a napalm bomb that
	can set players on fire. Basically a CS port of the "fire grenades"
	I originally developed for Zombie Plague, at the request of some people
	and since there were no similiar plugins around. Have fun!
	
	~~~~~~~~~~~~~~~~
	- Requirements -
	~~~~~~~~~~~~~~~~
	
	* Mods: Counter-Strike 1.6 or Condition-Zero
	* AMXX: Version 1.8.0 or later
	
	~~~~~~~~~~~~~~~~
	- Installation -
	~~~~~~~~~~~~~~~~
	
	* Extract .amxx file to your plugins folder, and add its name to plugins.ini
	* Extract flame.spr to the "sprites" folder on your server
	* To change models or sounds, open up the .sma with any text editor and look
	   for the customization section. When you're done, recompile.
	
	~~~~~~~~~~~~
	- Commands -
	~~~~~~~~~~~~
	
	* say /napalm - Buy a napalm grenade (when override is off)
	
	~~~~~~~~~
	- CVARS -
	~~~~~~~~~
	
	* napalm_on <1> - Enable/Disable Napalm Nades
	* napalm_affect <1> - Which nades should be napalms (1-HE // 2-FB // 3-SG)
	* napalm_team <0> - Determines which team can buy/use napalm nades
	   (0-both teams // 1-Terrorists only // 2-CTs only)
	* napalm_override <1> - If enabled, grenades will automatically become
	   napalms without players having to buy them
	* napalm_price <1000> - Money needed to buy a napalm (when override is off)
	* napalm_buyzone <0> - If enabled, players need to be in a buyzone to
	   purchase a napalm (when override is off)
	* napalm_carrylimit <1> - How many napalms can be carried at once
	
	* napalm_radius <240> - Napalm explosion radius
	* napalm_hitself <1> - If enabled, napalms will also affect their owner
	* napalm_ff <0> - If enabled, napalms will also affect teammates
	* napalm_spread <0> - If enabled, players will be able to catch fire
	   from others when they touch
	* napalm_keepexplosion <0> - Wether to keep the default CS explosion
	
	* napalm_duration <5> - How long the burning lasts in seconds
	* napalm_damage <2> - How much damage the burning does (every 0.2 secs)
	* napalm_cankill <0> - If set, burning will be able to kill the victim
	* napalm_slowdown <0.5> - Burning slow down, set between: 0.1 (slower) and
	   0.9 (faster). Use 0 to disable.
	* napalm_screamrate <20> - How often players will scream when on fire
	   (lower values = more screams). Use 0 to disable.
	
	~~~~~~~~~~~~~
	- Changelog -
	~~~~~~~~~~~~~
	
	* v1.0: (Jul 26, 2008)
	   - First release
	
	* v1.1: (Aug 15, 2008)
	   - Grenades now explode based on their pev_dmgtime (means the
	      plugin is now compatible with Nade Modes)
	   - Changed method to identify napalm nades when override is off
	   - Fire spread feature now fully working with CZ bots
	
	* v1.1b: (Aug 23, 2008)
	   - Optimized bandwidth usage for temp entity messages
	
	* v1.1c: (Aug 26, 2008)
	   - Fixed possible bugs with plugins that change a player's team
	      after throwing a napalm nade
	
	* v1.2: (Oct 05, 2008)
	   - Added a few cvars that allow more customization
	   - Optimized the code a bit
	   - Fixed a bug where buying 2 napalms too quick would sometimes
	      result in the second acting as a normal nade

	* v1.3: (Feb 17, 2009)
	   - Added ability to carry multiple napalms at once (+CVAR)
	
	* v1.3a: (Mar 16, 2009)
	   - Code optimized (+CVARs now cached at round start)
	
================================================================================*/

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <xs>

/*================================================================================
 [Plugin Customization]
=================================================================================*/

// Uncomment the following if you wish to set custom models for napalms
//#define USE_NAPALM_CUSTOM_MODELS

#if defined USE_NAPALM_CUSTOM_MODELS // Then set your custom models here
new const g_model_napalm_view[] = "models/v_hegrenade"
new const g_model_napalm_player[] = "models/p_hegrenade.mdl"
new const g_model_napalm_world[] = "models/w_hegrenade.mdl"
#endif

// Explosion sounds
new const grenade_fire[][] = { "weapons/hegrenade-1.wav" }

// Player burning sounds
new const grenade_fire_player[][] = { "scientist/sci_fear8.wav", "scientist/sci_pain1.wav", "scientist/scream02.wav" }

// Grenade sprites
new const sprite_grenade_fire[] = "sprites/flame.spr"
new const sprite_grenade_smoke[] = "sprites/black_smoke3.spr"
new const sprite_grenade_trail[] = "sprites/laserbeam.spr"
new const sprite_grenade_ring[] = "sprites/shockwave.spr"

// Glow and trail colors (red, green, blue)
const NAPALM_R = 200
const NAPALM_G = 0
const NAPALM_B = 0

/*===============================================================================*/

// Burning task
const TASK_BURN = 1000
#define ID_BURN (taskid - TASK_BURN)
#define BURN_DURATION args[0]
#define BURN_ATTACKER args[1]

// CS Player PData Offsets (win32)
const OFFSET_CSTEAMS = 114
const OFFSET_CSMONEY = 115
const OFFSET_MAPZONE = 235
new const AFFECTED_BPAMMO_OFFSETS[] = { 388, 387, 389 }
const OFFSET_LINUX = 5 // offsets +5 in Linux builds

// CS Player CBase Offsets (win32)
const OFFSET_ACTIVE_ITEM = 373

// CS Weapon PData Offsets (win32)
const OFFSET_WEAPONID = 43
const OFFSET_LINUX_WEAPONS = 4 // weapon offsets are only 4 steps higher on Linux

// CS Weapon CBase Offsets (win32)
const OFFSET_WEAPONOWNER = 41

// Some constants
const PLAYER_IN_BUYZONE = (1<<0)

// pev_ field used to store custom nade types and their values
const PEV_NADE_TYPE = pev_flTimeStepSound
const NADE_TYPE_NAPALM = 681856

// pev_ field used to store napalm's custom ammo
const PEV_NAPALM_AMMO = pev_flSwimTime

// Weapons that can be napalms
new const AFFECTED_NAMES[][] = { "HE", "FB", "SG" }
new const AFFECTED_CLASSNAMES[][] = { "weapon_hegrenade", "weapon_flashbang", "weapon_smokegrenade" }
new const AFFECTED_MODELS[][] = { "w_he", "w_fl", "w_sm" }
new const AFFECTED_AMMOID[] = { 12, 11, 13 }
#if defined USE_NAPALM_CUSTOM_MODELS
new const AFFECTED_WEAPONS[] = { CSW_HEGRENADE, CSW_FLASHBANG, CSW_SMOKEGRENADE }
#endif

// CS Sounds
new const sound_buyammo[] = "items/9mmclip1.wav"

// Whether ham forwards are registered for CZ bots
new g_hamczbots

// Precached sprites indices
new g_flameSpr, g_smokeSpr, g_trailSpr, g_exploSpr

// Messages
new g_msgDamage, g_msgMoney, g_msgBlinkAcct, g_msgAmmoPickup

// CVAR pointers
new cvar_radius, cvar_price, cvar_hitself, cvar_duration, cvar_slowdown, cvar_override,
cvar_damage, cvar_on, cvar_buyzone, cvar_ff, cvar_cankill, cvar_spread, cvar_botquota,
cvar_teamrestrict, cvar_screamrate, cvar_keepexplosion, cvar_affect, cvar_carrylimit

// Cached stuff
new g_maxplayers, g_on, g_affect, g_override, g_allowedteam, g_keepexplosion, g_spread,
g_ff, g_duration, g_buyzone, g_price, g_carrylimit, g_hitself, g_screamrate, g_damage,
Float:g_slowdown, g_cankill, Float:g_radius

// Precache all custom stuff
public plugin_precache()
{
	new i
	for (i = 0; i < sizeof grenade_fire; i++)
		engfunc(EngFunc_PrecacheSound, grenade_fire)
	for (i = 0; i < sizeof grenade_fire_player; i++)
		engfunc(EngFunc_PrecacheSound, grenade_fire_player)
	
	g_flameSpr = engfunc(EngFunc_PrecacheModel, sprite_grenade_fire)
	g_smokeSpr = engfunc(EngFunc_PrecacheModel, sprite_grenade_smoke)
	g_trailSpr = engfunc(EngFunc_PrecacheModel, sprite_grenade_trail)
	g_exploSpr = engfunc(EngFunc_PrecacheModel, sprite_grenade_ring)
	
	// CS sounds (just in case)
	engfunc(EngFunc_PrecacheSound, sound_buyammo)
	
#if defined USE_NAPALM_CUSTOM_MODELS
	engfunc(EngFunc_PrecacheModel, g_model_napalm_view)
	engfunc(EngFunc_PrecacheModel, g_model_napalm_player)
	engfunc(EngFunc_PrecacheModel, g_model_napalm_world)
#endif
}

public plugin_init()
{
	// Register plugin call
	register_plugin("Napalm Nades", "1.3a", "MeRcyLeZZ")
	
	// Events
	register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
	
	// Forwards
	register_forward(FM_SetModel, "fw_SetModel")
	RegisterHam(Ham_Think, "grenade", "fw_ThinkGrenade")
	RegisterHam(Ham_Touch, "player", "fw_TouchPlayer")
#if defined USE_NAPALM_CUSTOM_MODELS
	for (new i = 0; i < sizeof AFFECTED_CLASSNAMES; i++)
		RegisterHam(Ham_Item_Deploy, AFFECTED_CLASSNAMES, "fw_Item_Deploy_Post", 1)
#endif
	
	// Client commands
	register_clcmd("say napalm", "buy_napalm")
	register_clcmd("say /napalm", "buy_napalm")
	
	// CVARS
	cvar_on = register_cvar("napalm_on", "1")
	cvar_affect = register_cvar("napalm_affect", "1")
	cvar_teamrestrict = register_cvar("napalm_team", "0")
	cvar_override = register_cvar("napalm_override", "0")
	cvar_price = register_cvar("napalm_price", "1000")
	cvar_buyzone = register_cvar("napalm_buyzone", "1")
	cvar_carrylimit = register_cvar("napalm_carrylimit", "1")
	
	cvar_radius = register_cvar("napalm_radius", "240")
	cvar_hitself = register_cvar("napalm_hitself", "1")
	cvar_ff = register_cvar("napalm_ff", "0")
	cvar_spread = register_cvar("napalm_spread", "1")
	cvar_keepexplosion = register_cvar("napalm_keepexplosion", "0")
	
	cvar_duration = register_cvar("napalm_duration", "5")
	cvar_damage = register_cvar("napalm_damage", "2")
	cvar_cankill = register_cvar("napalm_cankill", "1")
	cvar_slowdown = register_cvar("napalm_slowdown", "0.5")
	cvar_screamrate = register_cvar("napalm_screamrate", "20")
	
	cvar_botquota = get_cvar_pointer("bot_quota")
	g_maxplayers = get_maxplayers()
	
	// Message ids
	g_msgDamage = get_user_msgid("Damage")
	g_msgMoney = get_user_msgid("Money")
	g_msgBlinkAcct = get_user_msgid("BlinkAcct")
	g_msgAmmoPickup = get_user_msgid("AmmoPickup")
}

public plugin_cfg()
{
	// Cache CVARs after configs are loaded
	set_task(0.5, "event_round_start")
}

// Round Start Event
public event_round_start()
{
	// Cache CVARs
	g_on = get_pcvar_num(cvar_on)
	g_affect = get_pcvar_num(cvar_affect)
	g_override = get_pcvar_num(cvar_override)
	g_allowedteam = get_pcvar_num(cvar_teamrestrict)
	g_keepexplosion = get_pcvar_num(cvar_keepexplosion)
	g_spread = get_pcvar_num(cvar_spread)
	g_ff = get_pcvar_num(cvar_ff)
	g_duration = get_pcvar_num(cvar_duration)
	g_buyzone = get_pcvar_num(cvar_buyzone)
	g_price = get_pcvar_num(cvar_price)
	g_carrylimit = get_pcvar_num(cvar_carrylimit)
	g_hitself = get_pcvar_num(cvar_hitself)
	g_screamrate = get_pcvar_num(cvar_screamrate)
	g_slowdown = get_pcvar_float(cvar_slowdown)
	g_damage = floatround(get_pcvar_float(cvar_damage), floatround_ceil)
	g_cankill = get_pcvar_num(cvar_cankill)
	g_radius = get_pcvar_float(cvar_radius)
	
	// Stop any burning tasks on players
	for (new id = 1; id <= g_maxplayers; id++)
		remove_task(id+TASK_BURN);
}

// Client joins the game
public client_putinserver(id)
{
	// CZ bots seem to use a different "classtype" for player entities
	// (or something like that) which needs to be hooked separately
	if (!g_hamczbots && cvar_botquota && is_user_bot(id))
	{
		// Set a task to let the private data initialize
		set_task(0.1, "register_ham_czbots", id)
	}
}

// Set Model Forward
public fw_SetModel(entity, const model[])
{
	// Napalm grenades disabled
	if (!g_on) return FMRES_IGNORED;
	
	// Get damage time of grenade
	static Float:dmgtime
	pev(entity, pev_dmgtime, dmgtime)
	
	// Grenade not yet thrown
	if (dmgtime == 0.0)
		return FMRES_IGNORED;
	
	// Not an affected grenade
	if (!equal(model[7], AFFECTED_MODELS[g_affect-1], 4))
		return FMRES_IGNORED;
	
	// Get owner of grenade and napalm weapon entity
	static owner, napalm_weaponent
	owner = pev(entity, pev_owner)
	napalm_weaponent = fm_get_user_current_weapon_ent(owner)
	
	// Not a napalm grenade (because the weapon entity of its owner doesn't have the flag set)
	if (!g_override && pev(napalm_weaponent, PEV_NADE_TYPE) != NADE_TYPE_NAPALM)
		return FMRES_IGNORED;
	
	// Get owner's team
	static owner_team
	owner_team = fm_get_user_team(owner)
	
	// Player is on a restricted team
	if (g_allowedteam > 0 && g_allowedteam != owner_team)
		return FMRES_IGNORED;
	
	// Give it a glow
	fm_set_rendering(entity, kRenderFxGlowShell, NAPALM_R, NAPALM_G, NAPALM_B, kRenderNormal, 16)
	
	// And a colored trail
	message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
	write_byte(TE_BEAMFOLLOW) // TE id
	write_short(entity) // entity
	write_short(g_trailSpr) // sprite
	write_byte(10) // life
	write_byte(10) // width
	write_byte(NAPALM_R) // r
	write_byte(NAPALM_G) // g
	write_byte(NAPALM_B) // b
	write_byte(200) // brightness
	message_end()
	
	// Reduce napalm ammo
	static napalm_ammo
	napalm_ammo = pev(napalm_weaponent, PEV_NAPALM_AMMO)
	set_pev(napalm_weaponent, PEV_NAPALM_AMMO, --napalm_ammo)
	
	// Run out of napalms?
	if (napalm_ammo < 1)
	{
		// Remove napalm flag from the owner's weapon entity
		set_pev(napalm_weaponent, PEV_NADE_TYPE, 0)
	}
	
	// Set grenade type on the thrown grenade entity
	set_pev(entity, PEV_NADE_TYPE, NADE_TYPE_NAPALM)
	
	// Set owner's team on the thrown grenade entity
	set_pev(entity, pev_team, owner_team)
	
#if defined USE_NAPALM_CUSTOM_MODELS
	// Set custom model and supercede the original forward
	engfunc(EngFunc_SetModel, entity, g_model_napalm_world)
	return FMRES_SUPERCEDE;
#else
	return FMRES_IGNORED;
#endif
}

// Grenade Think Forward
public fw_ThinkGrenade(entity)
{
	// Invalid entity
	if (!pev_valid(entity)) return HAM_IGNORED;
	
	// Get damage time of grenade
	static Float:dmgtime
	pev(entity, pev_dmgtime, dmgtime)
	
	// Check if it's time to go off
	if (dmgtime > get_gametime())
		return HAM_IGNORED;
	
	// Not a napalm grenade
	if (pev(entity, PEV_NADE_TYPE) != NADE_TYPE_NAPALM)
		return HAM_IGNORED;
	
	// Explode event
	napalm_explode(entity)
	
	// Keep the original explosion?
	if (g_keepexplosion)
	{
		set_pev(entity, PEV_NADE_TYPE, 0)
		return HAM_IGNORED;
	}
	
	// Get rid of the grenade
	engfunc(EngFunc_RemoveEntity, entity)
	return HAM_SUPERCEDE;
}

// Player Touch Forward
public fw_TouchPlayer(self, other)
{
	// Spread cvar disabled or not touching a player
	if (!g_spread || !is_user_alive(other))
		return;
	
	// Toucher not on fire or touched player already on fire
	if (!task_exists(self+TASK_BURN) || task_exists(other+TASK_BURN))
		return;
	
	// Check if friendly fire is allowed
	if (!g_ff && fm_get_user_team(self) == fm_get_user_team(other))
		return;
	
	// Heat icon
	message_begin(MSG_ONE_UNRELIABLE, g_msgDamage, _, other)
	write_byte(0) // damage save
	write_byte(0) // damage take
	write_long(DMG_BURN) // damage type
	write_coord(0) // x
	write_coord(0) // y
	write_coord(0) // z
	message_end()
	
	// Our task params
	static params[2]
	params[0] = g_duration * 2 // duration (reduced a bit)
	params[1] = self // attacker
	
	// Set burning task on victim
	set_task(0.1, "burning_flame", other+TASK_BURN, params, sizeof params)
}

#if defined USE_NAPALM_CUSTOM_MODELS
// Ham Weapon Deploy Forward
public fw_Item_Deploy_Post(entity)
{
	// Napalm grenades disabled
	if (!g_on) return;
	
	// Not a napalm grenade (because the weapon entity of its owner doesn't have the flag set)
	if (!g_override && pev(entity, PEV_NADE_TYPE) != NADE_TYPE_NAPALM)
		return;
	
	// Get weapon's id
	static weaponid
	weaponid = fm_get_weapon_ent_id(entity)
	
	// Not an affected grenade
	if (weaponid != AFFECTED_WEAPONS[g_affect-1])
		return;
	
	// Get weapon's owner
	static owner
	owner = fm_get_weapon_ent_owner(entity)
	
	// Player is on a restricted team
	if (g_allowedteam > 0 && g_allowedteam != fm_get_user_team(owner))
		return;
	
	// Replace models
	set_pev(owner, pev_viewmodel2, g_model_napalm_view)
	set_pev(owner, pev_weaponmodel2, g_model_napalm_player)
}
#endif

// Napalm purchase command
public buy_napalm(id)
{
	// Napalm grenades disabled
	if (!g_on) return PLUGIN_CONTINUE;
	
	// Check if override setting is enabled instead
	if (g_override)
	{
		client_print(id, print_center, "Just buy a %s grenade and get a napalm automatically!", AFFECTED_NAMES[g_affect-1])
		return PLUGIN_HANDLED;
	}
	
	// Check if player is alive
	if (!is_user_alive(id))
	{
		client_print(id, print_center, "You can't buy when you're dead!")
		return PLUGIN_HANDLED;
	}
	
	// Check if the player is on a restricted team
	if (g_allowedteam > 0 && g_allowedteam != fm_get_user_team(id))
	{
		client_print(id, print_center, "Your team cannot buy napalm nades!")
		return PLUGIN_HANDLED;
	}
	
	// Check if player needs to be in a buyzone
	if (g_buyzone && !fm_get_user_buyzone(id))
	{
		client_print(id, print_center, "You are not in a buyzone!")
		return PLUGIN_HANDLED;
	}
	
	// Check that player has the money
	if (fm_get_user_money(id) < g_price)
	{
		client_print(id, print_center, "#Cstrike_TitlesTXT_Not_Enough_Money")
		
		// Blink money
		message_begin(MSG_ONE_UNRELIABLE, g_msgBlinkAcct, _, id)
		write_byte(2) // times
		message_end()
		
		return PLUGIN_HANDLED;
	}
	
	// Get napalm weapon entity
	static napalm_weaponent
	napalm_weaponent = fm_get_napalm_entity(id, g_affect)
	
	// Does the player have a napalm already?
	if (napalm_weaponent != 0)
	{
		// Retrieve napalm ammo
		static napalm_ammo
		napalm_ammo = pev(napalm_weaponent, PEV_NAPALM_AMMO)
		
		// Check if allowed to have this many napalms
		if (napalm_ammo < g_carrylimit)
		{
			// Increase napalm ammo
			set_pev(napalm_weaponent, PEV_NAPALM_AMMO, ++napalm_ammo)
			
			// Increase player's backpack ammo
			set_pdata_int(id, AFFECTED_BPAMMO_OFFSETS[g_affect-1], get_pdata_int(id, AFFECTED_BPAMMO_OFFSETS[g_affect-1]) + 1, OFFSET_LINUX)
			
			// Flash ammo in hud
			message_begin(MSG_ONE_UNRELIABLE, g_msgAmmoPickup, _, id)
			write_byte(AFFECTED_AMMOID[g_affect-1]) // ammo id
			write_byte(1) // ammo amount
			message_end()
			
			// Play clip purchase sound
			engfunc(EngFunc_EmitSound, id, CHAN_ITEM, sound_buyammo, 1.0, ATTN_NORM, 0, PITCH_NORM)
			
			// Set napalm flag on the weapon entity (bugfix)
			set_pev(napalm_weaponent, PEV_NADE_TYPE, NADE_TYPE_NAPALM)
		}
		else
		{
			client_print(id, print_center, "You cannot carry any more napalms!")
			return PLUGIN_HANDLED;
		}
	}
	else
	{
		// Give napalm
		fm_give_item(id, AFFECTED_CLASSNAMES[g_affect-1])
		
		// Get napalm weapon entity now it exists
		napalm_weaponent = fm_get_napalm_entity(id, g_affect)
		
		// Set napalm flag on the weapon entity
		set_pev(napalm_weaponent, PEV_NADE_TYPE, NADE_TYPE_NAPALM)
		
		// Set napalm ammo
		set_pev(napalm_weaponent, PEV_NAPALM_AMMO, 1)
	}
	
	// Calculate new money amount
	static newmoney
	newmoney = fm_get_user_money(id) - g_price
	
	// Update money offset
	fm_set_user_money(id, newmoney)
	
	// Update money on HUD
	message_begin(MSG_ONE, g_msgMoney, _, id)
	write_long(newmoney) // amount
	write_byte(1) // flash
	message_end()
	
	return PLUGIN_HANDLED;
}

// Napalm Grenade Explosion
napalm_explode(ent)
{
	// Get attacker and its team
	static attacker, attacker_team
	attacker = pev(ent, pev_owner)
	attacker_team = pev(ent, pev_team)
	
	// Get origin
	static Float:originF[3]
	pev(ent, pev_origin, originF)
	
	// Custom explosion effect
	create_blast2(originF)
	
	// Napalm explosion sound
	engfunc(EngFunc_EmitSound, ent, CHAN_WEAPON, grenade_fire[random_num(0, sizeof grenade_fire - 1)], 1.0, ATTN_NORM, 0, PITCH_NORM)
	
	// Collisions
	static victim
	victim = -1
	
	while ((victim = engfunc(EngFunc_FindEntityInSphere, victim, originF, g_radius)) != 0)
	{
		// Only effect alive players
		if (!is_user_alive(victim))
			continue;
		
		// Check if myself is allowed
		if (!g_hitself && victim == attacker)
			continue;
		
		// Check if friendly fire is allowed
		if (!g_ff && victim != attacker && attacker_team == fm_get_user_team(victim))
			continue;
		
		// Heat icon
		message_begin(MSG_ONE_UNRELIABLE, g_msgDamage, _, victim)
		write_byte(0) // damage save
		write_byte(0) // damage take
		write_long(DMG_BURN) // damage type
		write_coord(0) // x
		write_coord(0) // y
		write_coord(0) // z
		message_end()
		
		// Our task params
		static params[2]
		params[0] = g_duration * 5 // duration
		params[1] = attacker // attacker
		
		// Set burning task on victim
		set_task(0.1, "burning_flame", victim+TASK_BURN, params, sizeof params)
	}
}

// Burning Task
public burning_flame(args[2], taskid)
{
	// Player died/disconnected
	if (!is_user_alive(ID_BURN))
		return;
	
	// Get player origin and flags
	static Float:originF[3], flags
	pev(ID_BURN, pev_origin, originF)
	flags = pev(ID_BURN, pev_flags)
	
	// In water or burning stopped
	if ((flags & FL_INWATER) || BURN_DURATION < 1)
	{
		// Smoke sprite
		engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
		write_byte(TE_SMOKE) // TE id
		engfunc(EngFunc_WriteCoord, originF[0]) // x
		engfunc(EngFunc_WriteCoord, originF[1]) // y
		engfunc(EngFunc_WriteCoord, originF[2]-50.0) // z
		write_short(g_smokeSpr) // sprite
		write_byte(random_num(15, 20)) // scale
		write_byte(random_num(10, 20)) // framerate
		message_end()
		
		return;
	}
	
	// Randomly play burning sounds
	if (g_screamrate > 0 && random_num(1, g_screamrate) == 1)
		engfunc(EngFunc_EmitSound, ID_BURN, CHAN_VOICE, grenade_fire_player[random_num(0, sizeof grenade_fire_player - 1)], 1.0, ATTN_NORM, 0, PITCH_NORM)
	
	// Fire slow down
	if (g_slowdown > 0.0 && (flags & FL_ONGROUND))
	{
		static Float:velocity[3]
		pev(ID_BURN, pev_velocity, velocity)
		xs_vec_mul_scalar(velocity, g_slowdown, velocity)
		set_pev(ID_BURN, pev_velocity, velocity)
	}
	
	// Get victim's health
	static health
	health = pev(ID_BURN, pev_health)
	
	// Take damage from the fire
	if (health - g_damage > 0)
		set_pev(ID_BURN, pev_health, float(health - g_damage))
	else if (g_cankill)
	{
		// Kill victim
		ExecuteHamB(Ham_Killed, ID_BURN, BURN_ATTACKER, 0)
		
		// Smoke sprite
		engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
		write_byte(TE_SMOKE) // TE id
		engfunc(EngFunc_WriteCoord, originF[0]) // x
		engfunc(EngFunc_WriteCoord, originF[1]) // y
		engfunc(EngFunc_WriteCoord, originF[2]-50.0) // z
		write_short(g_smokeSpr) // sprite
		write_byte(random_num(15, 20)) // scale
		write_byte(random_num(10, 20)) // framerate
		message_end()
		
		return;
	}
	
	// Flame sprite
	engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
	write_byte(TE_SPRITE) // TE id
	engfunc(EngFunc_WriteCoord, originF[0]+random_float(-5.0, 5.0)) // x
	engfunc(EngFunc_WriteCoord, originF[1]+random_float(-5.0, 5.0)) // y
	engfunc(EngFunc_WriteCoord, originF[2]+random_float(-10.0, 10.0)) // z
	write_short(g_flameSpr) // sprite
	write_byte(random_num(5, 10)) // scale
	write_byte(200) // brightness
	message_end()
	
	// Decrease task cycle count
	BURN_DURATION -= 1;
	
	// Keep sending flame messages
	set_task(0.2, "burning_flame", taskid, args, sizeof args)
}

// Napalm Grenade: Fire Blast (originally made by Avalanche in Frostnades)
create_blast2(const Float:originF[3])
{
	// Smallest ring
	engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
	write_byte(TE_BEAMCYLINDER) // TE id
	engfunc(EngFunc_WriteCoord, originF[0]) // x
	engfunc(EngFunc_WriteCoord, originF[1]) // y
	engfunc(EngFunc_WriteCoord, originF[2]) // z
	engfunc(EngFunc_WriteCoord, originF[0]) // x axis
	engfunc(EngFunc_WriteCoord, originF[1]) // y axis
	engfunc(EngFunc_WriteCoord, originF[2]+385.0) // z axis
	write_short(g_exploSpr) // sprite
	write_byte(0) // startframe
	write_byte(0) // framerate
	write_byte(4) // life
	write_byte(60) // width
	write_byte(0) // noise
	write_byte(200) // red
	write_byte(100) // green
	write_byte(0) // blue
	write_byte(200) // brightness
	write_byte(0) // speed
	message_end()
	
	// Medium ring
	engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
	write_byte(TE_BEAMCYLINDER) // TE id
	engfunc(EngFunc_WriteCoord, originF[0]) // x
	engfunc(EngFunc_WriteCoord, originF[1]) // y
	engfunc(EngFunc_WriteCoord, originF[2]) // z
	engfunc(EngFunc_WriteCoord, originF[0]) // x axis
	engfunc(EngFunc_WriteCoord, originF[1]) // y axis
	engfunc(EngFunc_WriteCoord, originF[2]+470.0) // z axis
	write_short(g_exploSpr) // sprite
	write_byte(0) // startframe
	write_byte(0) // framerate
	write_byte(4) // life
	write_byte(60) // width
	write_byte(0) // noise
	write_byte(200) // red
	write_byte(50) // green
	write_byte(0) // blue
	write_byte(200) // brightness
	write_byte(0) // speed
	message_end()
	
	// Largest ring
	engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
	write_byte(TE_BEAMCYLINDER) // TE id
	engfunc(EngFunc_WriteCoord, originF[0]) // x
	engfunc(EngFunc_WriteCoord, originF[1]) // y
	engfunc(EngFunc_WriteCoord, originF[2]) // z
	engfunc(EngFunc_WriteCoord, originF[0]) // x axis
	engfunc(EngFunc_WriteCoord, originF[1]) // y axis
	engfunc(EngFunc_WriteCoord, originF[2]+555.0) // z axis
	write_short(g_exploSpr) // sprite
	write_byte(0) // startframe
	write_byte(0) // framerate
	write_byte(4) // life
	write_byte(60) // width
	write_byte(0) // noise
	write_byte(200) // red
	write_byte(0) // green
	write_byte(0) // blue
	write_byte(200) // brightness
	write_byte(0) // speed
	message_end()
}

// Register Ham Forwards for CZ bots
public register_ham_czbots(id)
{
	// Make sure it's a CZ bot and it's still connected
	if (g_hamczbots || !get_pcvar_num(cvar_botquota) || !is_user_connected(id))
		return;
	
	RegisterHamFromEntity(Ham_Touch, id, "fw_TouchPlayer")
	
	// Ham forwards for CZ bots succesfully registered
	g_hamczbots = true;
}

// Set entity's rendering type (from fakemeta_util)
stock 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))
}

// Give an item to a player (from fakemeta_util)
stock fm_give_item(id, const item[])
{
	static ent
	ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item));
	if (!pev_valid(ent)) return;
	
	static Float:originF[3]
	pev(id, pev_origin, originF);
	set_pev(ent, pev_origin, originF);
	set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN);
	dllfunc(DLLFunc_Spawn, ent);
	
	static save
	save = pev(ent, pev_solid);
	dllfunc(DLLFunc_Touch, ent, id);
	if (pev(ent, pev_solid) != save)
		return;
	
	engfunc(EngFunc_RemoveEntity, ent);
}

// Find entity by its owner (from fakemeta_util)
stock fm_find_ent_by_owner(entity, const classname[], owner)
{
	while ((entity = engfunc(EngFunc_FindEntityByString, entity, "classname", classname)) && pev(entity, pev_owner) != owner) {}
	
	return entity;
}

// Finds napalm grenade weapon entity of a player
stock fm_get_napalm_entity(id, g_affect)
{
	return fm_find_ent_by_owner(-1, AFFECTED_CLASSNAMES[g_affect-1], id);
}

// Get User Current Weapon Entity
stock fm_get_user_current_weapon_ent(id)
{
	return get_pdata_cbase(id, OFFSET_ACTIVE_ITEM, OFFSET_LINUX);
}

// Get Weapon Entity's CSW_ ID
stock fm_get_weapon_ent_id(ent)
{
	return get_pdata_int(ent, OFFSET_WEAPONID, OFFSET_LINUX_WEAPONS);
}

// Get Weapon Entity's Owner
stock fm_get_weapon_ent_owner(ent)
{
	return get_pdata_cbase(ent, OFFSET_WEAPONOWNER, OFFSET_LINUX_WEAPONS);
}

// Get User Money
stock fm_get_user_money(id)
{
	return get_pdata_int(id, OFFSET_CSMONEY, OFFSET_LINUX);
}

// Set User Money
stock fm_set_user_money(id, amount)
{
	set_pdata_int(id, OFFSET_CSMONEY, amount, OFFSET_LINUX);
}

// Get User Team
stock fm_get_user_team(id)
{
	return get_pdata_int(id, OFFSET_CSTEAMS, OFFSET_LINUX);
}

// Returns whether user is in a buyzone
stock fm_get_user_buyzone(id)
{
	if (get_pdata_int(id, OFFSET_MAPZONE) & PLAYER_IN_BUYZONE)
		return 1;
	
	return 0;
}

P.S:Acum e bine #Vali ??
RoyalServer 2
User avatar
|NGU|Anonymus
Membru, skill +1
Membru, skill +1
Posts: 293
Joined: 26 May 2014, 15:26
Detinator Steam: Nu
CS Status: Citesc forumul eXtreamCS.com...!
Detinator server CS: In progres...
Has thanked: 16 times
Been thanked: 64 times

01 Jun 2014, 19:55

Up....
User avatar
EuSemakka
Membru, skill +1
Membru, skill +1
Posts: 301
Joined: 26 Nov 2013, 17:40
Detinator Steam: Da
Detinator server CS: Furien.FaraLaG.Ro
Has thanked: 38 times
Been thanked: 7 times

02 Jun 2014, 21:57

Sa-mi dai pm pe ce sv ai facut ss ;) si ati modific eu pluginul..
User avatar
CryWolf
Administrator
Administrator
Posts: 6505
Joined: 07 Aug 2008, 16:33
Detinator Steam: Da
Reputatie: Administrator
Fost Scripter
Manager CS2.eXtream.Ro
Fost Detinator ZM.eXtream.Ro
Fost manager CS.eXtream.Ro
Fost manager CSGO.eXtream.Ro
Fost manager global
Location: Botosani
Discord: crywolf1989
Has thanked: 202 times
Been thanked: 850 times
Contact:

02 Jun 2014, 22:42

Iti plac astea care le aveam eu pe server aici
http://www.extreamcs.com/forum/servere/ ... 14692.html

Parca le mai am .amxx-urile si .spru-urile daca vrei functioneaza pe orice mod nu stiu sigur de .SMA
NU IMI MAI DA-TI PM CU CERERE AJUTOR/SAMD, FOLOSITI FORUMUL, CITESC MAJORITATEA TOPICURILOR.
www.dark-arena.com , SERVERE CS / CS2 / L4D AU REVENIT ONLINE.
www.diasporaiptv.ro - SERVICII PREMIUM IPTV

Image

Image
User avatar
|NGU|Anonymus
Membru, skill +1
Membru, skill +1
Posts: 293
Joined: 26 May 2014, 15:26
Detinator Steam: Nu
CS Status: Citesc forumul eXtreamCS.com...!
Detinator server CS: In progres...
Has thanked: 16 times
Been thanked: 64 times

04 Jun 2014, 17:12

Sa-mi dai pm pe ce sv ai facut ss ;) si ati modific eu pluginul..
Nu am serverul respectiv oricum nu era din Romania de aia nici spr. nu le am ...
Iti plac astea care le aveam eu pe server aici
servere/hl2-zombie-mod-t214692.html

Parca le mai am .amxx-urile si .spru-urile daca vrei functioneaza pe orice mod nu stiu sigur de .SMA
Sunt destul de tari daca imi poti da amxx sa vad cum ruleaza pe server ar fi perfect :P
User avatar
AZzeL
Membru, skill +2
Membru, skill +2
Posts: 981
Joined: 02 Oct 2012, 15:24
Detinator Steam: Da
CS Status: Invat ingerasii sa moara !
Detinator server CS: VALCEA.FIREON.RO
Location: Valcea
Has thanked: 64 times
Been thanked: 27 times
Contact:

04 Jun 2014, 17:49

Acele sprites-uri le gasesti in arhiva plugin-ului ZPS : http://www.extreamcs.com/forum/pluginur ... 00938.html
[ EntrySoft Hosting SRL ( Reducere 20% prin codul AZZEL20 ) ]
[ MxHost™ ]
User avatar
|NGU|Anonymus
Membru, skill +1
Membru, skill +1
Posts: 293
Joined: 26 May 2014, 15:26
Detinator Steam: Nu
CS Status: Citesc forumul eXtreamCS.com...!
Detinator server CS: In progres...
Has thanked: 16 times
Been thanked: 64 times

04 Jun 2014, 20:09

AZzeL wrote:Acele sprites-uri le gasesti in arhiva plugin-ului ZPS : http://www.extreamcs.com/forum/pluginur ... 00938.html
Din cate stiu eu acele sprite-uri sunt facute pentru ZP sid esi nu ar trebui sa aiba legatura cu He-urile are.Am incercat sa folosesc spr. de la un addons de Zp si in joc nu-mi apareau efectele respective.
User avatar
|NGU|Anonymus
Membru, skill +1
Membru, skill +1
Posts: 293
Joined: 26 May 2014, 15:26
Detinator Steam: Nu
CS Status: Citesc forumul eXtreamCS.com...!
Detinator server CS: In progres...
Has thanked: 16 times
Been thanked: 64 times

05 Jun 2014, 23:21

Up time
User avatar
Jorj
Fost moderator
Fost moderator
Posts: 3494
Joined: 13 Aug 2013, 18:10
Detinator Steam: Da
Detinator server CS: Furien.LsZ.Ro
SteamID: clic_lsz
Reputatie: Fost eXtream Mod
Fost Membru Club eXtreamCS (patru luni)
Nume anterior: Clic
Location: Piatra Neamt
Has thanked: 1 time
Been thanked: 20 times
Contact:

06 Jun 2014, 09:13

Si eu l-as dori.

EDIT: Am gasit ceva ...https://forums.alliedmods.net/showthread.php?t=193947
Intermediez tranzactii cand am chef si timp ! :)

Image
User avatar
CsN^ ;x
Membru eXtream
Membru eXtream
Posts: 3560
Joined: 02 Apr 2012, 16:58
Detinator Steam: Nu
CS Status: Retras din domeniul Counter-Strike
Reputatie: Fost moderator
Location: Bucuresti
Has thanked: 797 times
Been thanked: 607 times

06 Jun 2014, 18:56

Clic wrote:Si eu l-as dori.

EDIT: Am gasit ceva ...https://forums.alliedmods.net/showthread.php?t=193947
Ce ai tu are un efect mic,adica arunci smok-ul si apare acea flacara albastra si dispare dupa 2-3 secunde.Daca s-ar face careva timp sa ne ofere si noua acest plugin cu efectele alea :) .
Si eu il caut.
Addons HNS level,gravity,xp DOWNLOAD ( e țeapă)
https://5filme.com/ - un simplu site de filme pentru timpul liber
User avatar
CryWolf
Administrator
Administrator
Posts: 6505
Joined: 07 Aug 2008, 16:33
Detinator Steam: Da
Reputatie: Administrator
Fost Scripter
Manager CS2.eXtream.Ro
Fost Detinator ZM.eXtream.Ro
Fost manager CS.eXtream.Ro
Fost manager CSGO.eXtream.Ro
Fost manager global
Location: Botosani
Discord: crywolf1989
Has thanked: 202 times
Been thanked: 850 times
Contact:

06 Jun 2014, 21:49

Eu le am doar pentru ZM / ZP [Biohazard si Zombie Plague] . amxx daca doriti deoarece .sma-urile le-am pierdut anu trecut cand mi sa ars HDD-ul la laptop si .AMXX le aveam pe host!

Lasati reply nu imi mai dati PM
NU IMI MAI DA-TI PM CU CERERE AJUTOR/SAMD, FOLOSITI FORUMUL, CITESC MAJORITATEA TOPICURILOR.
www.dark-arena.com , SERVERE CS / CS2 / L4D AU REVENIT ONLINE.
www.diasporaiptv.ro - SERVICII PREMIUM IPTV

Image

Image
User avatar
|NGU|Anonymus
Membru, skill +1
Membru, skill +1
Posts: 293
Joined: 26 May 2014, 15:26
Detinator Steam: Nu
CS Status: Citesc forumul eXtreamCS.com...!
Detinator server CS: In progres...
Has thanked: 16 times
Been thanked: 64 times

06 Jun 2014, 21:56

CryWolf wrote:Eu le am doar pentru ZM / ZP [Biohazard si Zombie Plague] . amxx daca doriti deoarece .sma-urile le-am pierdut anu trecut cand mi sa ars HDD-ul la laptop si .AMXX le aveam pe host!

Lasati reply nu imi mai dati PM
Pentru Zp deja erau pe allied dar din pacate nu pentru asta imi trebuie.
P.S:De ce cand adaug alte fisiere .spr nu au efect??
Post Reply

Return to “Cereri”

  • Information
  • Who is online

    Users browsing this forum: Yandex [Bot] and 33 guests