Код за потвърждение: Избери целия код
/* AMX Mod
* Snowball War v3.06
*
* / \ / \ ___________________________
* / / \_/ \ \ / \
* \__/\ /\__/ / GIVE ME A CARROT OR I WILL \
* \O O/ \ BLOW UP YOUR HOUSE /
* ___/ ^ \___ / ___________________________/
* \___/ /_/
* _/ \_
* __// \\__
* /___\/_\/___\
*
* (c) Copyright 2008-2012 by FakeNick
*
* This file is provided as is (no warranties)
*
* DESCRIPTION
* My plugin is changing an HE grenade for snowball. When player spawns he receives only
* knife and HE. When snowball hit's wall it will explode with nice spalt effect.
* In this mod there are two teams : blue (CT's) and red (T's). They must kill their opponents
* with snowball. When player gets hit, his health is decreasing and there's
* a chance that player will be chilled. In this mod target is to kill your opponents,soldier!
* Snowball war includes very simple deathmatch (default off). It is also changing players models
* to santa's (T's) and snow soldiers (CT's) - this model can be changed by plugin user.
* Snowball war enables snow effect on server (comment line 83 to disable).
*
* MODULES
* Fun
* VexdUM
*
* CVARS
* sw_toggle - is mod on/off? (default ON - 1)
* sw_damage - damage done by snowball (default 100)
* sw_snowball_gravity - gravity of snowball (default 0.3)
* sw_snowball_velocity - how many times snowball velocity will be multipied (default 2.0 times)
* sw_life - life of snowball splat (default 3.0)
* sw_dm - is deathmatch on/off? (default OFF - 0)
* sw_dm_time - time to respawn (default 2.0)
* sw_spawn_protection - is spawn protection on? (default ON - 1)
* sw_spawn_protection_time - time of spawn protection (default 3.0)
* sw_chill_chance - chance to chill player (from 0 - off, to 100 - maximum chance, default 30)
* sw_chill_duration - duration of chill (default 5.0)
* sw_chill_speed - percentage of speed that player receives when chilled (default 50)
* sw_crosshair_remove - will be crosshair removed (default ON - 1)
* sw_show_message - is the plugin show at each new round an information message? (default ON - 1)
*
*
* Changelog
* Version 3.0 :
* - Initial release
*
* Version 3.01 :
* - Added game description changer
*
* Version 3.02 :
* - Added change velocity of snowball
* - Added change gravity of snowball
* - Added crsoshair remover for more realism
*
* Version 3.03 :
* - Added breaking glass when unchilling player
* - Added random snow skybox generator
* - Added spawn protection
*
* Version 3.04 :
* - Fixed server crashing bug
*
* Version 3.05 :
* - Added support for bots (code from ZP)
*
* Version 3.06 (AMX Mod version) :
* - Fixed server crash (normally)
* - Fast improvements for some parts
* - Removed cvar sw_friendly (works now with mp_friendlyfire)
* - Added NoSteam support for CS 1.5 Won servers (#define NO_STEAM)
*
*/
/*================================================================================
[Plugin Customization]
=================================================================================*/
// Uncomment the following line to force the NO_STEAM support for this plugin (CS 1.5).
//#define NO_STEAM
// Uncomment the following line to enable "snow" effect.
#define EFFECT_SNOW
//Do not touch this!
new const model_nade_world[] = "models/sw/w_snowball.mdl"
new const model_nade_view[] = "models/sw/v_snowball.mdl"
new const model_nade_player[] = "models/sw/p_snowball.mdl"
new const model_splash[] = "sprites/bhit.spr"
//Randomly chosen models and sounds, add as many to the right directory, as you want
new const model_red[][] = { "red1" }
new const model_blue[][] = { "blue1" }
new const sound_pain[][] = { "player/pl_pain2.wav","player/pl_pain4.wav","player/pl_pain5.wav","player/pl_pain6.wav","player/pl_pain7.wav" }
new const sound_hit[][] = { "player/pl_snow1.wav","player/pl_snow2.wav","player/pl_snow3.wav","player/pl_snow4.wav","player/pl_snow5.wav","player/pl_snow6.wav" }
new const sound_chill[][] = { "sw/chill.wav" }
new const sound_unchill[][] = { "sw/unchill.wav" }
new const sound_win_blue[][] = { "sw/blue1.wav" }
new const sound_win_red[][] = { "sw/red1.wav" }
new const sound_win_no_one[][] = { "sw/draw.wav" }
/*================================================================================
[CUSTOMIZATION ENDS HERE!]
=================================================================================*/
#include <translator>
#include <amxmod>
#include <amxmisc>
#include <fun>
#include <VexdUM>
/*================================================================================
[Enums]
=================================================================================*/
enum(+=100)
{
TASK_WELCOME = 100,
TASK_RESPAWN,
TASK_UNCHILL,
TASK_MODEL,
TASK_GOD
}
enum
{
CS_TEAM_UNASSIGNED = 0,
CS_TEAM_T,
CS_TEAM_CT,
CS_TEAM_SPECTATOR
}
/*================================================================================
[Pcvars]
=================================================================================*/
new pcvar_on,pcvar_dmg,pcvar_gravity,pcvar_velocity,pcvar_life,pcvar_dm,
pcvar_dm_time,pcvar_spawn,pcvar_spawn_duration, pcvar_chill_chance,pcvar_chill_duration,
pcvar_chill_speed,pcvar_crosshair,pcvar_message,pcvar_friendly
/*================================================================================
[Player variables]
=================================================================================*/
new bool:g_red[33],bool:g_blue[33],bool:g_IsChilled[33],bool:g_IsInRestart[33],g_LastPlayerTeam[33],
Float:g_maxspeed[33],Float:g_ChillySpeed[33],g_god[33]
/*================================================================================
[Global Variables]
=================================================================================*/
new bool:g_active,g_money,g_weapon,g_crosshair,g_maxplayers,g_endround,
g_spray,g_glass,g_drop,gmsgScreenFade,g_textMsg,g_sendAudio,g_hostagePos
#if !defined NO_STEAM
new g_scenario, g_msgScenario
#endif
new g_defaultSkyName[32]
new g_msgIndexTextMsg, g_msgIndexSendAudio, g_msgHostagePos
//This can affect gameplay
new const g_not_needed[][] =
{
//"weaponbox",
"armoury_entity",
"grenade",
"func_bomb_target",
"info_bomb_target",
"info_vip_start",
"func_vip_safetyzone",
"func_escapezone",
"hostage_entity",
"monster_scientist",
"func_hostage_rescue",
"info_hostage_rescue"
}
//Grenade bounce sounds
new const g_bouncelist[4][] =
{
"weapons/grenade_hit1.wav",
"weapons/grenade_hit2.wav",
"weapons/grenade_hit3.wav",
"weapons/he_bounce-1.wav"
}
//Mod name
new g_modname[] = "Snowball War"
//Skyboxes
new const g_skybox[][] = { "snow","office" }
/*================================================================================
[Light bit improvement]
=================================================================================*/
new g_IsThrowedNade[44], g_IsSplashEnt[44];
#define SetEntBits(%1,%2) %1[%2>>5] |= (1<<(%2&31))
#define RemoveEntBits(%1,%2) %1[%2>>5] &= ~(1<<(%2&31))
#define GetEntBits(%1,%2) (%1[%2>>5] & (1<<(%2&31)))
/*================================================================================
[Offsets and Constants]
=================================================================================*/
#if cellbits == 32
const OFFSET_CSTEAMS = 114
const OFFSET_CSMONEY = 115
#if !defined NO_STEAM
const OFFSET_HE_AMMO = 388
#else
const OFFSET_HE_AMMO = 392
#endif
#else
const OFFSET_CSTEAMS = 139
const OFFSET_CSMONEY = 140
#if !defined NO_STEAM
const OFFSET_HE_AMMO = 437
#else
const OFFSET_HE_AMMO = 441
#endif
#endif
const OFFSET_LINUX = 5
//To hide money displaying
const HIDE_MONEY = (1<<5)
//To hide crosshair
const HIDE_CROSSHAIR = (1<<6)
//For screen fade
const FFADE_IN = 0x0000
//For break glass effect
const BREAK_GLASS = 0x01
//If you experience many SVC_BAD kicks. increase this (for example set it to 0.5)
const Float:MODEL_DELAY = 0.2
//Version information
new const VERSION[] = "3.06"
/*================================================================================
[Code ;)]
=================================================================================*/
public plugin_precache()
{
new a,modelpath[96]
for(a = 0; a < sizeof sound_win_blue; a++)
precache_sound(sound_win_blue[a])
for(a = 0; a < sizeof sound_win_blue; a++)
precache_sound(sound_win_red[a])
for(a = 0; a < sizeof sound_win_blue; a++)
precache_sound(sound_win_no_one[a])
for(a = 0; a < sizeof sound_pain; a++)
precache_sound(sound_pain[a])
for(a = 0; a < sizeof sound_hit; a++)
precache_sound(sound_hit[a])
for(a = 0; a < sizeof sound_chill; a++)
precache_sound(sound_chill[a])
for(a = 0; a < sizeof sound_unchill; a++)
precache_sound(sound_unchill[a])
for(a = 0;a < sizeof model_blue; a++)
{
formatex(modelpath, charsmax(modelpath), "models/player/%s/%s.mdl", model_blue[a], model_blue[a])
precache_model(modelpath)
}
for(a = 0;a < sizeof model_red; a++)
{
formatex(modelpath, charsmax(modelpath), "models/player/%s/%s.mdl", model_red[a], model_red[a])
precache_model(modelpath)
}
precache_model(model_nade_world)
precache_model(model_nade_view)
precache_model(model_nade_player)
precache_model(model_splash)
g_drop = precache_model("sprites/blood.spr")
g_spray = precache_model("sprites/bloodspray.spr")
g_glass = precache_model("models/glassgibs.mdl")
#if defined EFFECT_SNOW
create_entity("env_snow")
#endif
//Fake hostage to force round ending
new ent = create_entity("hostage_entity")
if(ent > 0 && is_entity(ent))
{
entity_set_origin(ent, Float:{8192.0 ,8192.0 ,8192.0})
DispatchSpawn(ent)
}
//Make sure that plugin is on
pcvar_on = register_cvar("sw_toggle","1")
g_active = bool:(get_cvarptr_num(pcvar_on) > 0)
//Set skybox
get_cvar_string("sv_skyname", g_defaultSkyName, charsmax(g_defaultSkyName))
if(g_active)
{
set_cvar_string("sv_skyname", g_skybox[random_num(0, charsmax(g_skybox))])
}
}
public entity_spawn(entity)
{
// Invalid entity
if (!is_entity(entity))
return PLUGIN_CONTINUE
// Get classname
static classname[32]
entity_get_string(entity, EV_SZ_classname, classname, charsmax(classname))
// Check whether it needs to be removed
for(new i = 0; i < sizeof(g_not_needed); i++)
{
if (equal(classname, g_not_needed[i]))
{
remove_entity(entity)
return PLUGIN_HANDLED
}
}
return PLUGIN_CONTINUE
}
public plugin_init()
{
//Register dictionary
load_translations("snowball_war")
//Register plugin name
register_plugin(_T("Snowball War"), VERSION, "FakeNick")
//Events
#if !defined NO_STEAM
register_event("HLTV","event_round_start","a","1=0","2=0")
#else
register_logevent("event_round_start",2,"1=Round_Start")
#endif
register_logevent("logevent_round_end",2,"1=Round_End")
register_event("ResetHUD","eventResetHUD","be")
register_event("CurWeapon","event_weaponchange","be","1=1","2!4")
register_event("DeathMsg","eventDeathMsg","a")
//Pcvars
pcvar_dmg = register_cvar("sw_damage","100")
pcvar_gravity = register_cvar("sw_snowball_gravity","0.3")
pcvar_velocity = register_cvar("sw_snowball_velocity","2.0")
pcvar_life = register_cvar("sw_life","3.0")
pcvar_dm = register_cvar("sw_dm","0")
pcvar_dm_time = register_cvar("sw_dm_time","2.0")
pcvar_spawn = register_cvar("sw_spawn_protection","1")
pcvar_spawn_duration = register_cvar("sw_spawn_protection_time","3.0")
pcvar_chill_chance = register_cvar("sw_chill_chance","30")
pcvar_chill_duration = register_cvar("sw_chill_duration","5.0")
pcvar_chill_speed = register_cvar("sw_chill_speed","50")
pcvar_crosshair = register_cvar("sw_crosshair_remove","1")
pcvar_message = register_cvar("sw_show_message", "1")
pcvar_friendly = get_cvar_pointer("mp_friendlyfire")
//For version recognize and see what server is running this plugin
new version = register_cvar("sw_version",VERSION,FCVAR_SERVER | FCVAR_SPONLY)
set_cvarptr_string(version,VERSION)
//Other stuff
g_money = get_user_msgid("Money")
g_weapon = get_user_msgid("HideWeapon")
g_crosshair = get_user_msgid("Crosshair")
gmsgScreenFade = get_user_msgid("ScreenFade")
g_textMsg = get_user_msgid("TextMsg")
g_sendAudio = get_user_msgid("SendAudio")
g_hostagePos = get_user_msgid("HostagePos")
#if !defined NO_STEAM
g_scenario = get_user_msgid("Scenario")
#endif
g_maxplayers = get_maxplayers()
//Messsages
if(g_active)
{
g_msgIndexTextMsg = register_message(g_textMsg, "message_textmsg")
g_msgIndexSendAudio = register_message(g_sendAudio, "message_audio")
g_msgHostagePos = register_message(g_hostagePos, "message_hostagepos")
#if !defined NO_STEAM
g_msgScenario = register_message(g_scenario, "message_scenario")
#endif
}
}
public plugin_cfg()
{
// Get configs dir
new cfgdir[32],file[64]
get_localinfo("amx_configdir",cfgdir,charsmax(cfgdir))
if(cfgdir[0])
{
formatex(file,charsmax(file),"%s/snowball_war.cfg",cfgdir)
}
else
{
build_path(cfgdir,charsmax(cfgdir),"$configdir/snowball_war.cfg")
}
if(file_exists(file))
{
// Execute config file (sw.cfg)
server_cmd("exec %s", file)
server_exec()
}
else
{
log_amx(_T("Snowball War: Unable to load the configuration file, it doesn't exist (%s)."), file)
}
}
/*================================================================================
[Events]
=================================================================================*/
public event_round_start()
{
//It's not round end
g_endround = false
//Check if plugin is active
new bool:old = g_active
g_active = bool:(get_cvarptr_num(pcvar_on) > 0)
if(g_active == false)
{
if(old == g_active)
return
if(g_msgIndexTextMsg != 0)
{
unregister_message(g_textMsg, g_msgIndexTextMsg)
g_msgIndexTextMsg = 0
}
if(g_msgIndexSendAudio != 0)
{
unregister_message(g_sendAudio, g_msgIndexSendAudio)
g_msgIndexSendAudio = 0
}
if(g_msgHostagePos != 0)
{
unregister_message(g_hostagePos, g_msgHostagePos)
g_msgHostagePos = 0
}
#if !defined NO_STEAM
if(g_msgScenario != 0)
{
unregister_message(g_scenario, g_msgScenario)
g_msgScenario = 0
}
#endif
#if defined EFFECT_SNOW
client_cmd(0, "cl_weather 0")
#endif
set_cvar_string("sv_skyname", g_defaultSkyName)
set_cvar_num("sv_restart", 3)
return
}
for(new i = 0; i < 44; i++)
{
g_IsThrowedNade[i] = g_IsSplashEnt[i] = 0
}
if(g_msgIndexTextMsg == 0)
{
g_msgIndexTextMsg = register_message(g_textMsg, "message_textmsg")
}
if(g_msgIndexSendAudio == 0)
{
g_msgIndexSendAudio = register_message(g_sendAudio, "message_audio")
}
if(g_msgHostagePos == 0)
{
g_msgHostagePos = register_message(g_hostagePos, "message_hostagepos")
}
#if !defined NO_STEAM
if(g_msgScenario == 0)
{
g_msgScenario = register_message(g_scenario, "message_scenario")
}
#endif
#if defined EFFECT_SNOW
if(g_active != old)
{
client_cmd(0, "cl_weather 1")
}
#endif
set_cvar_string("sv_skyname", g_skybox[random_num(0, charsmax(g_skybox))])
//Remove old welcome task and make a new one
if(get_cvarptr_num(pcvar_message) > 1)
{
remove_task(TASK_WELCOME)
set_task(2.5,"func_welcome",TASK_WELCOME)
}
}
public logevent_round_end()
{
if(g_active == false)
return
// Prevent this from getting called twice when restarting (bugfix)
static Float:last
new Float:gametime = get_gametime()
if (gametime - last < 0.5)
return
last = gametime
g_endround = true
// Show HUD notice, play win sound
if (!sw_GetBlue())
{
//Red team wins
set_hudmessage(200, 0, 0, -1.0, 0.17, 0, 0.0, 3.0, 2.0, 1.0, -1)
show_hudmessage(0, _T("Red team wins!"))
// Play win sound
sw_sound(sound_win_red[random_num(0, charsmax(sound_win_red))])
}
else if (!sw_GetRed())
{
//Blue team wins
set_hudmessage(0, 0, 200, -1.0, 0.17, 0, 0.0, 3.0, 2.0, 1.0, -1)
show_hudmessage(0, _T("Blue team wins!"))
// Play win sound
sw_sound(sound_win_blue[random_num(0, charsmax(sound_win_blue))])
}
else
{
// No one wins
set_hudmessage(0, 200, 0, -1.0, 0.17, 0, 0.0, 3.0, 2.0, 1.0, -1)
show_hudmessage(0, _T("Draw..."))
sw_sound(sound_win_no_one[random_num(0, charsmax(sound_win_no_one))])
}
}
/*================================================================================
[Main Part]
=================================================================================*/
public func_welcome(id)
{
id -= TASK_WELCOME
if((id > 0) ? is_user_connected(id) : 1)
{
client_print(id,print_chat,_T("~~~ Snowball war v%s for AMX Mod by FakeNick ~~~"),VERSION)
}
}
public client_authorized(id)
{
if(g_active == false)
return
#if defined EFFECT_SNOW
client_cmd(id, "cl_weather 1")
#endif
}
public client_putinserver(id)
{
g_IsChilled[id] = false
g_blue[id] = false
g_red[id]= false
g_god[id] = false
//Remove old welcome task and make a new one
if(g_active && get_cvarptr_num(pcvar_message) == 1)
{
set_task(30.0,"func_welcome",id+TASK_WELCOME)
}
}
public client_disconnect(id)
{
g_IsChilled[id] = false
g_blue[id] = false
g_red[id]= false
g_god[id] = false
}
/*================================================================================
[Forwards]
=================================================================================*/
public eventResetHUD(id)
{
if(g_active == false)
{
if(g_LastPlayerTeam[id])
{
sw_reset_user_model(id)
}
return
}
if(g_IsInRestart[id])
{
g_IsInRestart[id] = false
}
else
{
set_task(random_float(0.1, 0.25),"resetHUDDelayed",id)
}
}
public resetHUDDelayed(id)
{
if(!is_user_connected(id))
return
g_blue[id] = false
g_red[id] = false
g_IsChilled[id] = false
g_god[id] = false
//Strip player weapons
strip_user_weapons(id)
//Give him "snowball"
give_item(id,"weapon_hegrenade")
//Set ammo
sw_set_user_bpammo(id,999)
//Set view model and player model
entity_set_string(id,EV_SZ_viewmodel,model_nade_view)
entity_set_string(id,EV_SZ_weaponmodel,model_nade_world)
//Strip his cash ;]
sw_set_user_money(id,0,0)
//Hide money displaying
sw_money(id)
//Set his team variable
new team = sw_get_user_team(id)
switch(team)
{
case CS_TEAM_T :
{
g_red[id] = true
//Set his new model
if(g_LastPlayerTeam[id] != team)
{
sw_set_user_model(id, model_red[random(sizeof(model_red))], team)
}
}
case CS_TEAM_CT :
{
g_blue[id] = true
//Set his new model
if(g_LastPlayerTeam[id] != team)
{
sw_set_user_model(id, model_blue[random(sizeof(model_red))], team)
}
}
}
//Check if spawn protection is on
if(get_cvarptr_num(pcvar_spawn) > 0)
{
//Set god
g_god[id] = true
//Remove an old task and make a new one
remove_task(id + TASK_GOD)
set_task(get_cvarptr_float(pcvar_spawn_duration),"task_UnGod",id + TASK_GOD)
//Set glow
switch(team)
{
case CS_TEAM_T : set_user_rendering(id,kRenderFxGlowShell,255,0,0,kRenderNormal,25)
case CS_TEAM_CT : set_user_rendering(id,kRenderFxGlowShell,0,0,255,kRenderNormal,25)
}
}
}
public event_weaponchange(id)
{
if(g_active == false)
return
engclient_cmd(id, "weapon_hegrenade")
//Set view model and player model
entity_set_string(id,EV_SZ_viewmodel,model_nade_view)
entity_set_string(id,EV_SZ_weaponmodel,model_nade_world)
//Remove crosshair
if(get_cvarptr_num(pcvar_crosshair) > 0)
{
message_begin( MSG_ONE_UNRELIABLE, g_weapon, _, id )
write_byte(HIDE_CROSSHAIR)
message_end()
}
}
public eventDeathMsg()
{
//Check if deathmatch is on
if(g_active == false || get_cvarptr_num(pcvar_dm) <= 0)
return
new victim = read_data(2)
//Make sure that it's not round end
if(!g_endround)
{
remove_task(victim + TASK_RESPAWN)
set_task(get_cvarptr_float(pcvar_dm_time),"task_respawn",victim + TASK_RESPAWN)
}
}
public grenade_throw(index, ent, wId)
{
//Check ent validity
if(g_active == false)
return
//If model is equal to HE model, change it to snowball model
if(is_entity(ent) && wId == CSW_HEGRENADE)
{
// Set team
entity_set_edict(ent,EV_ENT_euser1,sw_get_user_team(index))
//Set model
entity_set_model(ent,model_nade_world)
//Block from exploding
entity_set_float(ent, EV_FL_dmgtime, get_gametime() + 99999.0)
//Set less gravity, so it will be "real" snowball
entity_set_float(ent,EV_FL_gravity,get_cvarptr_float(pcvar_gravity))
//Get grenade velocity
new Float:velocity[3]
entity_get_vector(ent,EV_VEC_velocity,velocity)
//Calculate new velocity
new Float:velocity_cvar = get_cvarptr_float(pcvar_velocity)
velocity[0] *= velocity_cvar
velocity[1] *= velocity_cvar
velocity[2] *= velocity_cvar
//Set new velocity
entity_set_vector(ent,EV_VEC_velocity,velocity)
//Set bits info
SetEntBits(g_IsThrowedNade, ent)
}
}
public entity_touch(ent,id)
{
if(g_active == false || ent <= g_maxplayers || !GetEntBits(g_IsThrowedNade, ent) || !is_entity(ent))
return PLUGIN_CONTINUE
static Float:origin[3]
//Player get's hit
if((1 <= id <= g_maxplayers) && is_user_alive(id))
{
//Check god mode
if(g_god[id])
return PLUGIN_CONTINUE
new owner = entity_get_edict(ent,EV_ENT_owner)
//Check friendly fire
new killerteam = entity_get_edict(ent,EV_ENT_euser1)
new victimteam = sw_get_user_team(id)
new bool:ffOn = false
if(killerteam == victimteam && (ffOn = bool:(get_cvarptr_num(pcvar_friendly) != 0)) == false)
return PLUGIN_CONTINUE
new health = get_user_health(id)
new damage = get_cvarptr_num(pcvar_dmg)
if(ffOn)
{
damage /= 2
}
entity_get_vector(ent,EV_VEC_origin,origin)
if(health > damage)
{
//Players health is greater than snowball damage
//Calculate chill chance
if(random_num(0,100) <= get_cvarptr_num(pcvar_chill_chance))
{
//Chill only non-chilled player
if(!g_IsChilled[id])
{
//Emit sound
emit_sound(id,CHAN_AUTO,sound_chill[random_num(0, charsmax(sound_chill))],1.0,ATTN_NORM,0,PITCH_NORM)
//Make light effect
sw_light(origin)
//Chill him!
sw_ChillPlayer(id)
//Set unchill task
remove_task(id + TASK_UNCHILL)
set_task(get_cvarptr_float(pcvar_chill_duration),"task_UnChill",id + TASK_UNCHILL)
}
}
//Create nice effect
sw_effect(origin)
//Emit pain sound
emit_sound(id,CHAN_VOICE,sound_pain[random_num(0, charsmax(sound_pain))],1.0,ATTN_NORM,0,PITCH_NORM)
//Emit hit sound
emit_sound(ent,CHAN_AUTO,sound_hit[random_num(0, charsmax(sound_hit))],1.0,ATTN_NORM,0,PITCH_NORM)
//Do damage to player
set_user_health(id, health - damage)
//Make white splash
sw_splash(ent,origin)
}
else
{
//Players health is lower or equal to snowball damage
//Emit hit sound
emit_sound(ent,CHAN_AUTO,sound_hit[random_num(0, charsmax(sound_hit))],1.0,ATTN_NORM,0,PITCH_NORM)
//Make nice effect
sw_effect(origin)
//Remove entity
RemoveEntBits(g_IsThrowedNade, ent)
remove_entity(ent)
//Kill player
sw_kill(owner,id,"snowball")
}
}
else
{
entity_get_vector(ent,EV_VEC_origin,origin)
//Make nice effect
sw_effect(origin)
//Snowball hit's something, f.e. wall, etc.
sw_splash(ent,origin)
//Emit hit sound
emit_sound(ent,CHAN_AUTO,sound_hit[random_num(0, charsmax(sound_hit))],1.0,ATTN_NORM,0,PITCH_NORM)
}
return PLUGIN_CONTINUE
}
public emitsound(ent,const sound[])
{
//Check if active
if(g_active == false || sound[0] != 'w' || sound[7] != '/' || sound[8] != 'g' && sound[8] != 'h')
return PLUGIN_CONTINUE
//Check if emited sound is equal to one for our list
for(new a; a < sizeof g_bouncelist;a++)
{
//If it's equal - block it
if(equali(sound,g_bouncelist[a]))
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
public entity_think(ent)
{
//Check if active and if valid entity
if(g_active == false || !GetEntBits(g_IsSplashEnt, ent))
return
RemoveEntBits(g_IsThrowedNade, ent)
RemoveEntBits(g_IsSplashEnt, ent)
remove_entity(ent)
}
// Change game name
public gamedescription()
{
set_gamedescription(g_modname)
return PLUGIN_HANDLED
}
/*================================================================================
[Messages]
=================================================================================*/
// Block some text messages
public message_textmsg(const msgid, const msgdest, const id)
{
if(id == 0)
{
new textmsg[22]
new len = get_msg_arg_string(2, textmsg, charsmax(textmsg))
// Game restarting, reset scores and call round end to balance the teams
if(len == 21 && equal(textmsg, "#Game_will_restart_in"))
{
for(new id = 1; id <= g_maxplayers; id++)
{
g_IsInRestart[id] = true
}
logevent_round_end()
return PLUGIN_CONTINUE
}
// Block round end related messages
else if(len == 21 && equal(textmsg, "#Hostages_Not_Rescued")
|| len == 11 && equal(textmsg, "#Round_Draw")
|| len == 15 && equal(textmsg, "#Terrorists_Win")
|| len == 8 && equal(textmsg, "#CTs_Win"))
{
return PLUGIN_HANDLED
}
}
else if(id != 0)
{
//Block "Fire in the hole!" text
new msgArgs
#if !defined NO_STEAM
if((5 <= (msgArgs = get_msg_args()) <= 6) && get_msg_arg_type(msgArgs) == ARG_STRING) {
#else
if((msgArgs = get_msg_args()) == 4) {
#endif
new textmsg[18]
static const fireMsg[] = "#Fire_in_the_hole"
if(get_msg_arg_string(msgArgs, textmsg, charsmax(textmsg)) == 17 && equal(textmsg, fireMsg))
{
return PLUGIN_HANDLED
}
}
}
return PLUGIN_CONTINUE
}
//Block some audio messages
public message_audio()
{
//Create variable
static sample[20]
//Get message arguments
new len = get_msg_arg_string(2, sample, charsmax(sample))
static const samples[4][] = {"!MRAD_FIREINHOLE","terwin","ctwin","rounddraw"}
//Check argument, if it's equal - block it
if(len == 17 && equal(sample[1], samples[0]))
return PLUGIN_HANDLED
len -= 7
if(len == 6 && equal(sample[7], samples[1])
|| len == 5 && equal(sample[7], samples[2])
|| len == 9 && equal(sample[7], samples[3]))
return PLUGIN_HANDLED
return PLUGIN_CONTINUE
}
//Block hostage from appearing on the radar
public message_hostagepos()
{
return PLUGIN_HANDLED
}
//Block hostage HUD display
#if !defined NO_STEAM
public message_scenario()
{
if(get_msg_args() > 1)
{
new sprite[8]
if(get_msg_arg_string(2, sprite, charsmax(sprite)) == 7 && equal(sprite, "hostage"))
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
#endif
/*================================================================================
[TASKS]
=================================================================================*/
public task_respawn(id)
{
id -= TASK_RESPAWN
if(is_user_connected(id) && !is_user_alive(id) && (1 <= sw_get_user_team(id) <= 2))
{
entity_set_int(id, EV_INT_deadflag, DEAD_RESPAWNABLE)
set_task(0.1, "spawnUser", id)
}
}
public spawnUser(id)
{
user_spawn(id)
}
public task_UnChill(id)
{
id -= TASK_UNCHILL
new Float:origin[3]
entity_get_vector(id,EV_VEC_origin,origin)
sw_UnChill(id,origin)
}
public task_UnGod(id)
{
id -= TASK_GOD
g_god[id] = false
set_user_rendering(id,kRenderFxGlowShell,0,0,0,kRenderNormal,25)
}
/*================================================================================
[Stocks]
=================================================================================*/
// Set player money
sw_set_user_money(id,money,flash=1)
{
set_offset_int(id,OFFSET_CSMONEY,money,OFFSET_LINUX)
message_begin(MSG_ONE_UNRELIABLE,g_money,{0,0,0},id)
write_long(money)
write_byte(flash)
message_end()
}
// Get User Team
sw_get_user_team(id)
{
return get_offset_int(id, OFFSET_CSTEAMS, OFFSET_LINUX)
}
// With this stock we can get player model
stock sw_get_user_model(player, model[], len)
{
get_keyvalue(player,"model",model,len)
}
// With this stock we can set player model
sw_set_user_model(player, const modelname[], const team)
{
g_LastPlayerTeam[player] = team
set_user_model(player, modelname)
}
//With this stock we can reset player model
sw_reset_user_model(player)
{
g_LastPlayerTeam[player] = 0
set_user_model(player)
}
// Set user snowballs
sw_set_user_bpammo(id,amount)
{
set_offset_int(id, OFFSET_HE_AMMO, amount, OFFSET_LINUX)
}
// Make death msg
sw_kill(killer, victim, weapon[])
{
client_death(victim, killer, weapon, 0)
#if !defined NO_STEAM
if(CheckFlag(victim, FL_DUCKING)) {
entity_set_int(victim, EV_INT_sequence, 110)
}
#else
if(CheckFlag(victim, FL_DUCKING)) {
entity_set_int(victim, EV_INT_sequence, 94)
}
#endif
}
/*================================================================================
[Other stuff]
=================================================================================*/
sw_GetBlue()
{
static iCt, id
iCt = 0
for (id = 1; id <= g_maxplayers; id++)
{
if(g_blue[id] && is_user_alive(id))
iCt++
}
return iCt
}
sw_GetRed()
{
static iT, id
iT = 0
for (id = 1; id <= g_maxplayers; id++)
{
if(g_red[id] && is_user_alive(id))
iT++
}
return iT
}
sw_money(id)
{
message_begin(MSG_ONE_UNRELIABLE,g_weapon,_,id)
write_byte((get_cvarptr_num(pcvar_crosshair) > 0) ? (HIDE_MONEY|HIDE_CROSSHAIR) : HIDE_MONEY)
message_end()
message_begin(MSG_ONE_UNRELIABLE,g_crosshair,_,id)
write_byte(0)
message_end()
}
sw_sound(const sound[])
{
client_cmd(0, "spk ^"%s^"", sound)
}
sw_splash(ent,const Float:origin[3])
{
//entity_set_string(ent, EV_SZ_classname, "snow_splash")
entity_set_int(ent, EV_INT_solid, SOLID_NOT)
entity_set_int(ent, EV_INT_movetype, MOVETYPE_NONE)
entity_set_origin(ent, origin)
entity_set_model(ent, model_splash)
entity_set_float(ent, EV_FL_nextthink, get_gametime() + get_cvarptr_float(pcvar_life))
set_rendering(ent, kRenderFxNoDissipation, 255, 255, 255, kRenderGlow, 255)
SetEntBits(g_IsSplashEnt, ent)
}
sw_effect(Float:fOrigin[3])
{
new origin[3]
FVecIVec(fOrigin,origin)
message_begin(MSG_PVS,SVC_TEMPENTITY,origin)
write_byte(TE_BLOODSPRITE)
write_coord(origin[0]+random_num(-20,20))
write_coord(origin[1]+random_num(-20,20))
write_coord(origin[2]+random_num(-20,20))
write_short(g_spray)
write_short(g_drop)
write_byte(255)
write_byte(15)
message_end()
}
sw_light(Float:originF[3])
{
new origin[3]
FVecIVec(originF,origin)
// light effect
message_begin(MSG_PVS,SVC_TEMPENTITY,origin)
write_byte(TE_DLIGHT)
write_coord(origin[0]) // x
write_coord(origin[1]) // y
write_coord(origin[2]) // z
write_byte(floatround(240.0/5.0)) // radius
write_byte(0) // r
write_byte(206)// g
write_byte(209) // b
write_byte(8) // life
write_byte(60) // decay rate
message_end()
}
sw_ChillPlayer(id)
{
//Set glow
set_user_rendering(id,kRenderFxGlowShell,0,206,209,kRenderNormal,25)
//Set chill state
g_IsChilled[id] = true
//Retrieve player old maxspeed
g_maxspeed[id] = entity_get_float(id,EV_FL_maxspeed)
//Calculate his new maxspeed
g_ChillySpeed[id] = g_maxspeed[id] * get_cvarptr_float(pcvar_chill_speed) / 100.0
//Set his new maxspeed
entity_set_float(id,EV_FL_maxspeed,g_ChillySpeed[id])
//Add blue fade on players screen
new Float:duration = get_cvarptr_float(pcvar_chill_duration)
message_begin(MSG_ONE_UNRELIABLE,gmsgScreenFade,_,id)
write_short(floatround(4096.0 * duration)) // duration
write_short(floatround(3072.0 * duration)) // hold time
write_short(FFADE_IN) // flags
write_byte(0) // red
write_byte(206) // green
write_byte(209) // blue
write_byte(100) // alpha
message_end()
}
sw_UnChill(id,Float:fOrigin[3])
{
//Make some variables
new origin[3]
//Change origin from float to integer
FVecIVec(fOrigin,origin)
//Delete glow
set_user_rendering(id,kRenderFxGlowShell,0,0,0,kRenderNormal,25)
//Restore his maxspeed
entity_set_float(id,EV_FL_maxspeed,g_maxspeed[id])
//Set chill state
g_IsChilled[id] = false
// clear tint
message_begin(MSG_ONE_UNRELIABLE,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()
//Make glass effect
message_begin(MSG_PVS,SVC_TEMPENTITY,origin)
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(g_glass) // model
write_byte(10) // count
write_byte(25) // life
write_byte(BREAK_GLASS) // flags
message_end()
//Emit sound
emit_sound(id,CHAN_AUTO,sound_unchill[random_num(0, charsmax(sound_unchill))],1.0,ATTN_NORM,0,PITCH_NORM)
}