Plugin:
Код за потвърждение: Избери целия код
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <hamsandwich>
#include <fun>
#include <engine>
#include <fakemeta>
#pragma tabsize 0
new keysmenu = (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<7)|(1<<8)|(1<<9)
new name[31], invis[33], hamelion[33], hasFrostNade[33], isChilled[33], isFrozen[33], novaDisplay[33], Float:oldSpeed[33]
new GravCost, SpeedCost, HPCost, HP, HECost, ICECost, DECost, InvisCost, LifeCost, HamelionCost, LifeOn, DEBullet, GravOn, SpeedOn, HPOn, HEOn, ICEOn, DEOn, InvisOn, HamelionOn, ShieldCost, ShieldOn
new bool:gl_not_map
new glassGibs;
new trailSpr;
new smokeSpr;
new exploSpr;
new const g_szShopFile[] = "market.cfg";
#define FROST_RADIUS 240.0
#define FROST_R 0
#define FROST_G 206
#define FROST_B 209
#define TASK_REMOVE_CHILL 200
#define TASK_REMOVE_FREEZE 250
#define MAX_TEXT_LENGTH 200
#define MAX_NAME_LENGTH 40
public plugin_init()
{
register_plugin("СуперМаркет", "3.0", "Pain")
register_cvar("market_ice_on","1");
register_cvar("market_hitself","0");
register_cvar("market_los","0");
register_cvar("market_ice_maxdamage","0");
register_cvar("market_ice_mindamage","0");
register_cvar("market_ice_override","1");
register_cvar("market_ice_price","300");
register_cvar("market_ice_chill_maxchance","100");
register_cvar("market_ice_chill_minchance","40");
register_cvar("market_ice_chill_duration","2");
register_cvar("market_ice_chill_speed","60");
register_cvar("market_ice_freeze_maxchance","100");
register_cvar("market_ice_freeze_minchance","40");
register_cvar("market_ice_freeze_duration","5");
register_clcmd("say /fn","buy_frostnade",-1);
register_clcmd("say_team /fn","buy_frostnade",-1);
register_clcmd("say /frostnade","buy_frostnade",-1);
register_clcmd("say_team /frostnade","buy_frostnade",-1);
register_event("DeathMsg","event_deathmsg","a");
register_event("CurWeapon","event_curweapon","b","1=1");
register_forward(FM_SetModel,"fw_setmodel");
register_think("grenade","think_grenade");
register_concmd("say /shop", "market")
register_concmd("say_team /shop", "market")
register_event("DeathMsg", "death_msg", "a")
register_menu("Menu 1", keysmenu, "shoped")
register_menu("Menu 2", keysmenu, "lifemenu")
RegisterHam(Ham_Spawn, "player", "event_PlayerSpawn_post",1)
GravCost = register_cvar( "market_gravity_cost", "6000" );
SpeedCost = register_cvar( "market_speed_cost", "7000" );
HPCost = register_cvar( "market_hp_cost", "4000" );
HP = register_cvar( "market_hp_buy", "100" );
HECost = register_cvar( "market_he_cost", "5000" );
ICECost = register_cvar( "market_ice_cost", "6000" );
DECost = register_cvar( "market_deagle_cost", "14000" );
InvisCost = register_cvar( "market_invisible_cost", "16000" );
LifeCost = register_cvar( "market_life_cost", "5000" );
LifeOn = register_cvar( "market_life_on", "1" );
HamelionCost = register_cvar( "market_hamelion_cost", "10000" );
ShieldCost = register_cvar( "market_shield_cost", "4000" );
GravOn = register_cvar( "market_gravity_on", "1" );
SpeedOn = register_cvar( "market_speed_on", "1" );
HPOn = register_cvar( "market_hp_on", "1" );
ShieldOn = register_cvar( "market_shield_on", "1" );
HEOn = register_cvar( "market_he_on", "1" );
ICEOn = register_cvar( "market_ice_on", "1" );
DEOn = register_cvar( "market_deagle_on", "1" );
InvisOn = register_cvar( "market_invis_on", "1" );
HamelionOn = register_cvar( "market_hamelion_on", "1" );
DEBullet = register_cvar( "market_deagle_bullet", "1" );
register_dictionary("market.txt")
}
public event_PlayerSpawn_post(id)
{
if(is_user_connected(id) && is_user_alive(id))
{
cs_reset_user_model(id)
hamelion[id] = 0
}
}
public market(id)
{
static menu[650], iLen
new money = cs_get_user_money(id)
iLen = 0
if (cs_get_user_team(id) == CS_TEAM_T || cs_get_user_team(id) == CS_TEAM_CT)
{
iLen = formatex(menu[iLen], charsmax(menu) - iLen, "%L", LANG_PLAYER, "MARKET_NAME", money)
if(cs_get_user_money(id) < get_pcvar_num( GravCost ))
iLen += formatex(menu[iLen], charsmax(menu) - iLen, "%L", LANG_PLAYER, "MARKET_GRAV_1_1", get_pcvar_num( GravCost ))
else
iLen += formatex(menu[iLen], charsmax(menu) - iLen, "%L", LANG_PLAYER, "MARKET_GRAV_1_2", get_pcvar_num( GravCost ))
if(cs_get_user_money(id) < get_pcvar_num( SpeedCost ))
iLen += formatex(menu[iLen], charsmax(menu) - iLen, "%L", LANG_PLAYER, "MARKET_SPEED_1_1", get_pcvar_num( SpeedCost ))
else
iLen += formatex(menu[iLen], charsmax(menu) - iLen, "%L", LANG_PLAYER, "MARKET_SPEED_1_2", get_pcvar_num( SpeedCost ))
if(cs_get_user_money(id) < get_pcvar_num( HPCost ))
iLen += formatex(menu[iLen], charsmax(menu) - iLen, "%L", LANG_PLAYER, "MARKET_HP_1_1", get_pcvar_num( HPCost ))
else
iLen += formatex(menu[iLen], charsmax(menu) - iLen, "%L", LANG_PLAYER, "MARKET_HP_1_2", get_pcvar_num( HPCost ))
if(cs_get_user_money(id) < get_pcvar_num( ShieldCost ))
iLen += formatex(menu[iLen], charsmax(menu) - iLen, "%L", LANG_PLAYER, "MARKET_SHIELD_1_1", get_pcvar_num( ShieldCost ))
else
iLen += formatex(menu[iLen], charsmax(menu) - iLen, "%L", LANG_PLAYER, "MARKET_SHIELD_1_2", get_pcvar_num( ShieldCost ))
if(cs_get_user_money(id) < get_pcvar_num( HECost ))
iLen += formatex(menu[iLen], charsmax(menu) - iLen, "%L", LANG_PLAYER, "MARKET_HE_1_1", get_pcvar_num( HECost ))
else
iLen += formatex(menu[iLen], charsmax(menu) - iLen, "%L", LANG_PLAYER, "MARKET_HE_1_2", get_pcvar_num( HECost ))
if(cs_get_user_money(id) < get_pcvar_num( ICECost ))
iLen += formatex(menu[iLen], charsmax(menu) - iLen, "%L", LANG_PLAYER, "MARKET_ICE_1_1", get_pcvar_num( ICECost ))
else
iLen += formatex(menu[iLen], charsmax(menu) - iLen, "%L", LANG_PLAYER, "MARKET_ICE_1_2", get_pcvar_num( ICECost ))
if(cs_get_user_money(id) < get_pcvar_num( DECost ))
iLen += formatex(menu[iLen], charsmax(menu) - iLen, "%L", LANG_PLAYER, "MARKET_DE_1_1", get_pcvar_num( DECost ))
else
iLen += formatex(menu[iLen], charsmax(menu) - iLen, "%L", LANG_PLAYER, "MARKET_DE_1_2", get_pcvar_num( DECost ))
if(cs_get_user_money(id) < get_pcvar_num( InvisCost ))
iLen += formatex(menu[iLen], charsmax(menu) - iLen, "%L", LANG_PLAYER, "MARKET_INVIS_1_1", get_pcvar_num( InvisCost ))
else
iLen += formatex(menu[iLen], charsmax(menu) - iLen, "%L", LANG_PLAYER, "MARKET_INVIS_1_2", get_pcvar_num( InvisCost ))
if(cs_get_user_money(id) < get_pcvar_num( HamelionCost ))
iLen += formatex(menu[iLen], charsmax(menu) - iLen, "%L", LANG_PLAYER, "MARKET_HAMELION_1_1", get_pcvar_num( HamelionCost ))
else
iLen += formatex(menu[iLen], charsmax(menu) - iLen, "%L", LANG_PLAYER, "MARKET_HAMELION_1_2", get_pcvar_num( HamelionCost ))
iLen += formatex(menu[iLen], charsmax(menu) - iLen, "\r0. \yВыход^n")
show_menu(id, keysmenu, menu, -1, "Menu 1")
}
return PLUGIN_HANDLED
}
public shoped(id, key)
{
get_user_name(id, name ,31)
switch(key)
{
case 0:
{
if(get_pcvar_num(GravOn) == 0)
{
Color_Print(id, "%L", LANG_PLAYER, "MARKET_GRAV_OFF")
return PLUGIN_HANDLED
}
if(get_pcvar_num(GravOn) == 1)
{
if(cs_get_user_money(id) >= get_pcvar_num( GravCost ))
{
set_user_gravity(id, 0.5)
Color_Print(0, "%L", LANG_PLAYER, "MARKET_GRAV_MSG", name)
cs_set_user_money(id, cs_get_user_money(id) - get_pcvar_num( GravCost ))
}
else
{
Color_Print(id, "%L", LANG_PLAYER, "MARKET_NOMONEY", name)
}
}
}
case 1:
{
if(get_pcvar_num(SpeedOn) == 0)
{
Color_Print(id, "%L", LANG_PLAYER, "MARKET_SPEED_OFF")
return PLUGIN_HANDLED
}
if(get_pcvar_num(SpeedOn) == 1)
{
if(cs_get_user_money(id) >= get_pcvar_num( SpeedCost ))
{
set_user_maxspeed(id, 490.0)
Color_Print(0, "%L", LANG_PLAYER, "MARKET_SPEED_MSG", name)
cs_set_user_money(id, cs_get_user_money(id) - get_pcvar_num( SpeedCost ))
}
else
{
Color_Print(id, "%L", LANG_PLAYER, "MARKET_NOMONEY", name)
}
}
}
case 2:
{
if (gl_not_map) {
Color_Print(id, "%L", LANG_PLAYER, "MARKET_NO_HP_THIS_MAP")
return PLUGIN_HANDLED
}
if(get_pcvar_num(HPOn) == 0)
{
Color_Print(id, "%L", LANG_PLAYER, "MARKET_HP_OFF")
return PLUGIN_HANDLED
}
if(get_pcvar_num(HPOn) == 1)
{
if(cs_get_user_money(id) >= get_pcvar_num( HPCost ))
{
set_user_health(id, get_pcvar_num( HP ))
Color_Print(0, "%L", LANG_PLAYER, "MARKET_HP_MSG", name)
cs_set_user_money(id, cs_get_user_money(id) - get_pcvar_num( HPCost ))
}
else
{
Color_Print(id, "%L", LANG_PLAYER, "MARKET_NOMONEY", name)
}
}
}
case 3:
{
if(get_pcvar_num(ShieldOn) == 0)
{
Color_Print(id, "%L", LANG_PLAYER, "MARKET_SHIELD_OFF")
return PLUGIN_HANDLED
}
if(get_pcvar_num(ShieldOn) == 1)
{
if(cs_get_user_money(id) >= get_pcvar_num( ShieldCost ))
{
strip_user_weapons(id)
give_item(id, "weapon_knife")
give_item(id, "weapon_shield")
Color_Print(0, "%L", LANG_PLAYER, "MARKET_SHIELD_MSG", name)
cs_set_user_money(id, cs_get_user_money(id) - get_pcvar_num( ShieldCost ))
}
else
{
Color_Print(id, "%L", LANG_PLAYER, "MARKET_NOMONEY", name)
}
}
}
case 4:
{
if(get_pcvar_num(HEOn) == 0)
{
Color_Print(id, "%L", LANG_PLAYER, "MARKET_HE_OFF")
return PLUGIN_HANDLED
}
if(get_pcvar_num(HEOn) == 1)
{
if(cs_get_user_money(id) >= get_pcvar_num( HECost ))
{
give_item(id, "weapon_hegrenade")
Color_Print(0, "%L", LANG_PLAYER, "MARKET_HE_MSG", name)
cs_set_user_money(id, cs_get_user_money(id) - get_pcvar_num( HECost ))
}
else
{
Color_Print(id, "%L", LANG_PLAYER, "MARKET_NOMONEY", name)
}
}
}
case 5:
{
if(get_pcvar_num(ICEOn) == 0)
{
Color_Print(id, "%L", LANG_PLAYER, "MARKET_ICE_OFF")
return PLUGIN_HANDLED
}
if(get_pcvar_num(ICEOn) == 1)
{
if(cs_get_user_money(id) >= get_pcvar_num( ICECost ))
{
give_item(id, "weapon_smokegrenade")
Color_Print(0, "%L", LANG_PLAYER, "MARKET_ICE_MSG", name)
cs_set_user_money(id, cs_get_user_money(id) - get_pcvar_num( ICECost ))
}
else
{
Color_Print(id, "%L", LANG_PLAYER, "MARKET_NOMONEY", name)
}
}
}
case 6:
{
if(get_pcvar_num(DEOn) == 0)
{
Color_Print(id, "%L", LANG_PLAYER, "MARKET_DEAGLE_OFF")
return PLUGIN_HANDLED
}
if(get_pcvar_num(DEOn) == 1)
{
if(cs_get_user_money(id) >= get_pcvar_num( DECost ))
{
new bullet = get_pcvar_num( DEBullet )
new weapon = give_item(id, "weapon_deagle")
if(weapon > 0)
cs_set_weapon_ammo(weapon, bullet)
Color_Print(0, "%L", LANG_PLAYER, "MARKET_DEAGLE_MSG", name)
cs_set_user_money(id, cs_get_user_money(id) - get_pcvar_num( DECost ))
}
else
{
Color_Print(id, "%L", LANG_PLAYER, "MARKET_NOMONEY", name)
}
}
}
case 7:
{
if(get_pcvar_num(InvisOn) == 0)
{
Color_Print(id, "%L", LANG_PLAYER, "MARKET_INVIS_OFF")
return PLUGIN_HANDLED
}
if(get_pcvar_num(InvisOn) == 1)
{
if(cs_get_user_money(id) >= get_pcvar_num( InvisCost ))
{
invisible(id)
}
else
{
Color_Print(id, "%L", LANG_PLAYER, "MARKET_NOMONEY", name)
}
}
}
case 8:
{
if(get_pcvar_num(HamelionOn) == 0)
{
Color_Print(id, "%L", LANG_PLAYER, "MARKET_HAMELION_OFF")
return PLUGIN_HANDLED
}
if(get_pcvar_num(HamelionOn) == 1)
{
if(!is_user_alive(id) || cs_get_user_money(id) < get_pcvar_num( HamelionCost ) || hamelion[id] >= 1)
return PLUGIN_CONTINUE
if(get_user_team(id) & 1)
{
cs_set_user_model(id, "gsg9")
Color_Print(0, "%L", LANG_PLAYER, "MARKET_HAMELION_MSG")
Color_Print(id, "%L", LANG_PLAYER, "MARKET_HAMELION_MSG_T")
hamelion[id]++
cs_set_user_money(id, cs_get_user_money(id) - get_pcvar_num( HamelionCost ))
}
else if(get_user_team(id) & 2)
{
cs_set_user_model(id, "terror")
Color_Print(0, "%L", LANG_PLAYER, "MARKET_HAMELION_MSG")
Color_Print(id, "%L", LANG_PLAYER, "MARKET_HAMELION_MSG_CT")
hamelion[id]++
cs_set_user_money(id, cs_get_user_money(id) - get_pcvar_num( HamelionCost ))
}
else
{
Color_Print(id, "%L", LANG_PLAYER, "MARKET_NOMONEY", name)
}
}
}
}
return PLUGIN_HANDLED
}
public client_authorized(id)
{
invis[id] = 0
hamelion[id] = 0
}
public startround()
{
for(new id = 1;id <= get_maxplayers(); id++)
{
invis[id] = 0
hamelion[id] = 0
}
}
public invisible(id)
{
if(invis[id] <= 1)
{
invis[id]++
set_user_rendering( id, kRenderFxNone, 0, 0, 0, kRenderTransAlpha, 0 )
new name[32]
get_user_name(id,name,31)
Color_Print(0, "%L", LANG_PLAYER, "MARKET_INVIS_MSG", name)
set_task(15.0, "offinvis", id)
cs_set_user_money(id, cs_get_user_money(id) - get_pcvar_num( InvisCost ))
}
}
public offinvis(id)
{
set_user_rendering(id, kRenderFxGlowShell, 0, 0, 0, kRenderNormal,0)
new name[32]
get_user_name(id,name,31)
Color_Print(id, "%L", LANG_PLAYER, "MARKET_INVIS_MSG_OFF", name)
}
public render(id)
{
new iRed = random_num(0, 255)
new iGreen = random_num(0, 255)
new iBlue = random_num(0, 255)
set_user_rendering(id,kRenderFxGlowShell,iRed,iGreen,iBlue,kRenderNormal,0)
}
stock Color_Print(const id, const input[], any:...)
{
new count = 1, players[32]
static msg[191]
vformat(msg, 190, input, 3)
replace_all(msg, 190, "\g", "^4") // Green Color
replace_all(msg, 190, "\y", "^1") // Default Color
replace_all(msg, 190, "\t", "^3") // Team Color
if (id) players[0] = id; else get_players(players, count, "ch")
{
for (new i = 0; i < count; i++)
{
if (is_user_connected(players[i]))
{
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i])
write_byte(players[i]);
write_string(msg);
message_end();
}
}
}
}
public death_msg()
{
new id = read_data(2)
new CTS[32], TS[32], CT, T
for(new i = 1; i <= 32; i++)
{
if(!is_user_connected(i) || !is_user_alive(i))
{
continue
}
if(cs_get_user_team(i)!=CS_TEAM_T)
{
TS[T++] = i
}
else
if(cs_get_user_team(i)!=CS_TEAM_T)
{
CTS[T++] = i
}
if(T > 3)
{
if(cs_get_user_money(id) > get_pcvar_num( LifeCost ))
set_task(2.0, "life", id)
}
else
if(cs_get_user_team(i)!=CS_TEAM_CT)
{
CTS[CT++] = i
}
}
if(CT > 3)
{
if(cs_get_user_money(id) > get_pcvar_num( LifeCost ))
set_task(2.0, "life", id)
}
}
public life(id)
if(get_pcvar_num(LifeOn) == 1) {
static menu[500], len
len = 0
len += formatex(menu[len], charsmax(menu) - len, "\yВозродитьÑÑ Ð·Ð° \r%d $ ?^n^n", get_pcvar_num( LifeCost ))
len += formatex(menu[len], charsmax(menu) - len, "\r1.\w Да^n")
len += formatex(menu[len], charsmax(menu) - len, "\r2.\w Ðет^n")
len += formatex(menu[len], charsmax(menu) - len, "\r0. \yВыход^n")
show_menu(id, keysmenu, menu, -1, "Menu 2")
}
public lifemenu(id, key)
{
get_user_name(id, name ,31)
switch(key)
{
case 0:
{
ExecuteHamB( Ham_CS_RoundRespawn, id)
cs_set_user_money(id, cs_get_user_money(id) - get_pcvar_num( LifeCost ))
Color_Print(0, "%L", LANG_PLAYER, "MARKET_RESPAWN", name)
}
case 1:
{
Color_Print(id, "^%L", LANG_PLAYER, "MARKET_RESPAWN_NO")
}
}
return PLUGIN_HANDLED
}
public plugin_cfg()
{
new ConfigsDir[64]
get_localinfo("amxx_configsdir", ConfigsDir, charsmax(ConfigsDir))
format(ConfigsDir, charsmax(ConfigsDir), "%s/%s", ConfigsDir, g_szShopFile)
if (!file_exists(ConfigsDir))
{
server_print("Market файл [%s] не найден!", ConfigsDir)
return;
}
server_cmd("exec ^"%s^"", ConfigsDir)
}
public plugin_precache() {
if (check_map()) {
gl_not_map = true
return
}
precache_model("models/icegrenade.mdl");
glassGibs = precache_model("models/glassgibs.mdl");
precache_sound("supermarket/icegrena.wav"); // grenade explodes
precache_sound("supermarket/ice.wav"); // player is frozen
precache_sound("supermarket/ice1.wav"); // frozen wears off
precache_sound("player/pl_duct2.wav"); // player is chilled
trailSpr = precache_model("sprites/laserbeam.spr");
smokeSpr = precache_model("sprites/steam1.spr");
exploSpr = precache_model("sprites/shockwave.spr");
}
/*------------
HOOK HANDLERS
-------------*/
// player wants to buy a grenade
public buy_frostnade(id)
{
if(!get_cvar_num("market_ice_on"))
return PLUGIN_CONTINUE;
// can't buy while dead
if(!is_user_alive(id))
return PLUGIN_HANDLED;
// no custom buy needed
if(get_cvar_num("market_ice_override"))
return PLUGIN_HANDLED;
// not in a buyzone
if(!cs_get_user_buyzone(id))
return PLUGIN_HANDLED;
// not enough money
new money = cs_get_user_money(id);
if(money < get_cvar_num("market_ice_price"))
{
client_print(id,print_center,"#Not_Enough_Money");
return PLUGIN_HANDLED;
}
// already have a frost grenade
if(hasFrostNade[id])
{
client_print(id,print_center,"#Cstrike_Already_Own_Weapon");
return PLUGIN_HANDLED;
}
// already have a smoke grenade
new weapons[32], num, i;
get_user_weapons(id,weapons,num);
for(i=0;i<num;i++)
{
if(weapons[i] == CSW_FLASHBANG)
{
client_print(id,print_center,"You already own a smoke grenade.");
return PLUGIN_HANDLED;
}
}
// gimme gimme
hasFrostNade[id] = 1;
give_item(id,"weapon_flashbang");
cs_set_user_money(id,money - get_cvar_num("market_ice_price"));
// display icon
message_begin(MSG_ONE,get_user_msgid("StatusIcon"),{0,0,0},id);
write_byte(1); // status (0=hide, 1=show, 2=flash)
write_string("dmg_cold"); // sprite name
write_byte(FROST_R); // red
write_byte(FROST_G); // green
write_byte(FROST_B); // blue
message_end();
return PLUGIN_HANDLED;
}
// prethinking
public client_PreThink(id)
{
if(!get_cvar_num("market_ice_on"))
return;
// if they are frozen, make sure they don't move at all
if(isFrozen[id])
{
// stop motion
entity_set_vector(id,EV_VEC_velocity,Float:{0.0,0.0,0.0});
new button = get_user_button(id), oldbuttons = entity_get_int(id,EV_INT_oldbuttons);
new flags = entity_get_int(id,EV_INT_flags);
// if are on the ground and about to jump, set the gravity too high to really do so
if((button & IN_JUMP) && !(oldbuttons & IN_JUMP) && (flags & FL_ONGROUND))
entity_set_float(id,EV_FL_gravity,999999.9); // I CAN'T STAND THE PRESSURE
// otherwise, set the gravity so low that they don't fall
else
entity_set_float(id,EV_FL_gravity,0.000001); // 0.0 doesn't work
}
}
// someone dies
public event_deathmsg()
{
if(!get_cvar_num("market_ice_on"))
return;
new id = read_data(2);
if(hasFrostNade[id])
{
hasFrostNade[id] = 0;
message_begin(MSG_ONE,get_user_msgid("StatusIcon"),{0,0,0},id);
write_byte(0); // status (0=hide, 1=show, 2=flash)
write_string("dmg_cold"); // sprite name
write_byte(FROST_R); // red
write_byte(FROST_G); // green
write_byte(FROST_B); // blue
message_end();
}
if(isChilled[id])
remove_chill(TASK_REMOVE_CHILL+id);
if(isFrozen[id])
remove_freeze(TASK_REMOVE_FREEZE+id);
}
// a player changes weapons
public event_curweapon(id)
{
if(!get_cvar_num("market_ice_on"))
return;
// flash icon if frost grenade is out
if(hasFrostNade[id] && read_data(2) == CSW_FLASHBANG)
{
message_begin(MSG_ONE,get_user_msgid("StatusIcon"),{0,0,0},id);
write_byte(2); // status (0=hide, 1=show, 2=flash)
write_string("dmg_cold"); // sprite name
write_byte(FROST_R); // red
write_byte(FROST_G); // green
write_byte(FROST_B); // blue
message_end();
}
else if(hasFrostNade[id])
{
message_begin(MSG_ONE,get_user_msgid("StatusIcon"),{0,0,0},id);
write_byte(1); // status (0=hide, 1=show, 2=flash)
write_string("dmg_cold"); // sprite name
write_byte(FROST_R); // red
write_byte(FROST_G); // green
write_byte(FROST_B); // blue
message_end();
}
if(isChilled[id])
chill_player(id);
if(isFrozen[id])
freeze_player(id);
}
// when a model is set
public fw_setmodel(ent,model[])
{
if(get_cvar_num("market_ice_on") < 1 || !is_valid_ent(ent))
return FMRES_IGNORED;
// not a smoke grenade
if(!equali(model,"models/w_smokegrenade.mdl"))
return FMRES_IGNORED;
// not yet thrown
if(entity_get_float(ent,EV_FL_gravity) == 0.0)
return FMRES_IGNORED;
new owner = entity_get_edict(ent,EV_ENT_owner);
// check to see if this isn't a frost grenade
if(!get_cvar_num("market_ice_override") && !hasFrostNade[owner])
return FMRES_IGNORED;
// store team in the grenade
entity_set_int(ent,EV_INT_team,get_user_team(owner));
// hide icon
if(hasFrostNade[owner])
{
hasFrostNade[owner] = 0;
message_begin(MSG_ONE,get_user_msgid("StatusIcon"),{0,0,0},owner);
write_byte(0); // status (0=hide, 1=show, 2=flash)
write_string("dmg_cold"); // sprite name
write_byte(FROST_R); // red
write_byte(FROST_G); // green
write_byte(FROST_B); // blue
message_end();
}
// give it a blue glow and a blue trail
set_rendering(ent,kRenderFxGlowShell,FROST_R,FROST_G,FROST_B);
set_beamfollow(ent,10,10,FROST_R,FROST_G,FROST_B,100);
// hack? flag to remember to track this grenade's think
entity_set_int(ent,EV_INT_bInDuck,1);
// track for when it will explode
set_task(1.6,"grenade_explode",ent);
return FMRES_IGNORED;
}
// think, grenade. think, damnit!
public think_grenade(ent)
{
if(get_cvar_num("market_ice_on") < 1 || !is_valid_ent(ent))
return PLUGIN_CONTINUE;
// hack? not a smoke grenade, or at least not a popular one
if(!entity_get_int(ent,EV_INT_bInDuck))
return PLUGIN_CONTINUE;
// stop it from exploding
return PLUGIN_HANDLED;
}
// the round ends
public event_roundend()
{
new i;
for(i=1;i<=32;i++)
{
if(isChilled[i])
remove_chill(TASK_REMOVE_CHILL+i);
if(isFrozen[i])
remove_freeze(TASK_REMOVE_FREEZE+i);
}
}
/*-------------------
OTHER MAIN FUNCTIONS
--------------------*/
// and boom goes the dynamite
public grenade_explode(ent)
{
if(get_cvar_num("market_ice_on") < 1 || !is_valid_ent(ent))
return;
// make the smoke
new origin[3], Float:originF[3];
entity_get_vector(ent,EV_VEC_origin,originF);
FVecIVec(originF,origin);
message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
write_byte(5); // TE_SMOKE
write_coord(origin[0]); // x
write_coord(origin[1]); // y
write_coord(origin[2]); // z
write_short(smokeSpr); // sprite
write_byte(random_num(35,45)); // scale
write_byte(5); // framerate
message_end();
// debug
//show_xyz(origin,floatround(FROST_RADIUS));
// explosion
create_blast(origin);
emit_sound(ent,CHAN_WEAPON,"warcraft3/frostnova.wav",1.0,ATTN_NORM,0,PITCH_NORM);
// get grenade's owner
new owner = entity_get_edict(ent,EV_ENT_owner);
// get grenades team
new nadeTeam = entity_get_int(ent,EV_INT_team);
// collisions
new player;
while((player = find_ent_in_sphere(player,originF,FROST_RADIUS)) != 0)
{
// not a player, or a dead one
if(!is_user_alive(player))
continue;
// don't hit teammates if friendlyfire is off, but don't count self as teammate
if((!get_cvar_num("mp_friendlyfire") && nadeTeam == get_user_team(player)) && owner != player)
continue;
// don't hit self if the cvar is set
if(owner == player && !get_cvar_num("market_hitself"))
continue;
// if user was frozen this check
new wasFrozen;
// get this player's origin for calculations
new Float:playerOrigin[3];
entity_get_vector(player,EV_VEC_origin,playerOrigin);
// check for line of sight
if(get_cvar_num("market_los"))
{
new Float:endPos[3];
trace_line(ent,originF,playerOrigin,endPos);
// no line of sight (end point not at player's origin)
if(endPos[0] != playerOrigin[0] && endPos[1] != playerOrigin[1] && endPos[2] != playerOrigin[2])
continue;
}
// calculate our odds
new Float:chillChance = radius_calucation(playerOrigin,originF,FROST_RADIUS,get_cvar_float("market_ice_chill_maxchance"),get_cvar_float("market_ice_chill_minchance"));
new Float:freezeChance = radius_calucation(playerOrigin,originF,FROST_RADIUS,get_cvar_float("market_ice_freeze_maxchance"),get_cvar_float("market_ice_freeze_minchance"));
// deal damage
if(get_cvar_float("market_ice_maxdamage") > 0.0)
{
new Float:damage = radius_calucation(playerOrigin,originF,FROST_RADIUS,get_cvar_float("market_ice_maxdamage"),get_cvar_float("market_ice_mindamage"));
// half damage for friendlyfire
if(nadeTeam == get_user_team(player))
damage *= 0.5;
// see if this will kill player
if(floatround(entity_get_float(player,EV_FL_health)) - damage <= 0)
{
user_silentkill(player);
make_deathmsg(owner,player,0,"frostgrenade");
// update score
if(nadeTeam == get_user_team(player))
{
set_user_frags(owner,get_user_frags(owner)-1);
if(get_cvar_num("mp_tkpunish"))
cs_set_user_tked(owner,1,0);
}
else
set_user_frags(owner,get_user_frags(owner)+1);
// update scoreboard
message_begin(MSG_BROADCAST,get_user_msgid("ScoreInfo"));
write_byte(owner);
write_short(get_user_frags(owner));
write_short(cs_get_user_deaths(owner));
write_short(0);
write_short(get_user_team(owner));
message_end();
message_begin(MSG_BROADCAST,get_user_msgid("ScoreInfo"));
write_byte(player);
write_short(get_user_frags(player));
write_short(cs_get_user_deaths(player));
write_short(0);
write_short(get_user_team(player));
message_end();
continue;
}
fakedamage(player,"frostgrenade",damage,3);
}
// check for freeze
if(random_num(1,100) <= floatround(freezeChance) && !isFrozen[player])
{
wasFrozen = 1;
freeze_player(player);
isFrozen[player] = 1;
emit_sound(player,CHAN_BODY,"warcraft3/impalehit.wav",1.0,ATTN_NORM,0,PITCH_HIGH);
set_task(get_cvar_float("market_ice_freeze_duration"),"remove_freeze",TASK_REMOVE_FREEZE+player);
// if they don't already have a frostnova
if(!is_valid_ent(novaDisplay[player]))
{
// create the entity
new nova = create_entity("info_target");
// give it a size
new Float:maxs[3], Float:mins[3];
maxs = Float:{ 8.0, 8.0, 4.0 };
mins = Float:{ -8.0, -8.0, -4.0 };
entity_set_size(nova,mins,maxs);
// random orientation
new Float:angles[3];
angles[1] = float(random_num(0,359));
entity_set_vector(nova,EV_VEC_angles,angles);
// put it at their feet
new Float:playerMins[3], Float:novaOrigin[3];
entity_get_vector(player,EV_VEC_mins,playerMins);
entity_get_vector(player,EV_VEC_origin,novaOrigin);
novaOrigin[2] += playerMins[2];
entity_set_vector(nova,EV_VEC_origin,novaOrigin);
// mess with the model
entity_set_model(nova,"models/icegrenade.mdl");
entity_set_float(nova,EV_FL_animtime,1.0)
entity_set_float(nova,EV_FL_framerate,1.0)
entity_set_int(nova,EV_INT_sequence,0);
set_rendering(nova,kRenderFxNone,FROST_R,FROST_G,FROST_B,kRenderTransColor,100);
// remember this
novaDisplay[player] = nova;
}
}
// check for chill
if(random_num(1,100) <= floatround(chillChance) && !isChilled[player])
{
chill_player(player);
isChilled[player] = 1;
// don't play sound if player just got frozen,
// reason being it will be overriden and I like the other sound better
if(!wasFrozen)
emit_sound(player,CHAN_BODY,"player/pl_duct2.wav",1.0,ATTN_NORM,0,PITCH_LOW);
set_task(get_cvar_float("market_ice_chill_duration"),"remove_chill",TASK_REMOVE_CHILL+player);
}
}
// get rid of the old grenade
remove_entity(ent);
}
// apply the effects of being chilled
public chill_player(id)
{
// don't mess with their speed if they are frozen
if(isFrozen[id])
set_user_maxspeed(id,1.0); // 0.0 doesn't work
else
{
new speed = floatround(get_user_maxspeed(id) * (get_cvar_float("market_ice_chill_speed") / 100.0));
set_user_maxspeed(id,float(speed));
}
// add a blue tint to their screen
message_begin(MSG_ONE,get_user_msgid("ScreenFade"),{0,0,0},id);
write_short(~0); // duration
write_short(~0); // hold time
write_short(0x0004); // flags: FFADE_STAYOUT, ignores the duration, stays faded out until new ScreenFade message received
write_byte(FROST_R); // red
write_byte(FROST_G); // green
write_byte(FROST_B); // blue
write_byte(100); // alpha
message_end();
// make them glow and have a trail
set_user_rendering(id,kRenderFxGlowShell,FROST_R,FROST_G,FROST_B,kRenderNormal,1);
// bug fix
if(!isFrozen[id])
set_beamfollow(id,30,8,FROST_R,FROST_G,FROST_B,100);
}
// apply the effects of being frozen
public freeze_player(id)
{
new Float:speed = get_user_maxspeed(id);
// remember their old speed for when they get unfrozen,
// but don't accidentally save their frozen speed
if(speed > 1.0 && speed != oldSpeed[id])
{
// save their unchilled speed
if(isChilled[id])
{
new speed = floatround(get_user_maxspeed(id) / (get_cvar_float("market_ice_chill_speed") / 100.0));
oldSpeed[id] = float(speed);
}
else
oldSpeed[id] = speed;
}
// stop them from moving
set_user_maxspeed(id,1.0); // 0.0 doesn't work
entity_set_vector(id,EV_VEC_velocity,Float:{0.0,0.0,0.0});
entity_set_float(id,EV_FL_gravity,0.000001); // 0.0 doesn't work
}
// a player's chill runs out
public remove_chill(taskid)
{
remove_task(taskid);
new id = taskid - TASK_REMOVE_CHILL;
// no longer chilled
if(!isChilled[id])
return;
isChilled[id] = 0;
// only apply effects to this player if they are still connected
if(is_user_connected(id))
{
// clear screen fade
message_begin(MSG_ONE,get_user_msgid("ScreenFade"),{0,0,0},id);
write_short(0); // duration
write_short(0); // hold time
write_short(0); // flags
write_byte(0); // red
write_byte(0); // green
write_byte(0); // blue
write_byte(0); // alpha
message_end();
// restore speed and remove glow
new speed = floatround(get_user_maxspeed(id) / (get_cvar_float("market_ice_chill_speed") / 100.0));
set_user_maxspeed(id,float(speed));
set_user_rendering(id);
// kill their trail
message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
write_byte(99); // TE_KILLBEAM
write_short(id);
message_end();
}
}
// a player's freeze runs out
public remove_freeze(taskid)
{
remove_task(taskid);
new id = taskid - TASK_REMOVE_FREEZE;
// no longer frozen
if(!isFrozen[id])
return;
// if nothing happened to the model
if(is_valid_ent(novaDisplay[id]))
{
// get origin of their frost nova
new origin[3], Float:originF[3];
entity_get_vector(novaDisplay[id],EV_VEC_origin,originF);
FVecIVec(originF,origin);
// add some tracers
message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
write_byte(14); // TE_IMPLOSION
write_coord(origin[0]); // x
write_coord(origin[1]); // y
write_coord(origin[2] + 8); // z
write_byte(64); // radius
write_byte(10); // count
write_byte(3); // duration
message_end();
// add some sparks
message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
write_byte(9); // TE_SPARKS
write_coord(origin[0]); // x
write_coord(origin[1]); // y
write_coord(origin[2]); // z
message_end();
// add the shatter
message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
write_byte(108); // 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(glassGibs); // model
write_byte(10); // count
write_byte(25); // life
write_byte(0x01); // flags: BREAK_GLASS
message_end();
// play a sound and remove the model
emit_sound(novaDisplay[id],CHAN_BODY,"warcraft3/impalelaunch1.wav",1.0,ATTN_NORM,0,PITCH_LOW);
remove_entity(novaDisplay[id]);
}
isFrozen[id] = 0;
novaDisplay[id] = 0;
// only apply effects to this player if they are still connected
if(is_user_connected(id))
{
// restore gravity
entity_set_float(id,EV_FL_gravity,1.0);
// if they are still chilled, set the speed rightly so. otherwise, restore it to complete regular.
if(isChilled[id])
{
set_beamfollow(id,30,8,FROST_R,FROST_G,FROST_B,100); // bug fix
new speed = floatround(oldSpeed[id] * (get_cvar_float("market_ice_chill_speed") / 100.0));
set_user_maxspeed(id,float(speed));
}
else
set_user_maxspeed(id,oldSpeed[id]);
}
oldSpeed[id] = 0.0;
}
/*----------------
UTILITY FUNCTIONS
-----------------*/
// my own radius calculations...
//
// 1. figure out how far a player is from a center point
// 2. figure the percentage this distance is of the overall radius
// 3. find a value between maxVal and minVal based on this percentage
//
// example: origin1 is 96 units away from origin2, and radius is 240.
// this player is then 60% towards the center from the edge of the sphere.
// let us say maxVal is 100.0 and minVal is 25.0. 60% progression from minimum
// to maximum becomes 70.0. tada!
public Float:radius_calucation(Float:origin1[3],Float:origin2[3],Float:radius,Float:maxVal,Float:minVal)
{
if(maxVal <= 0.0)
return 0.0;
if(minVal >= maxVal)
return minVal;
new Float:percent;
// figure out how far away the points are
new Float:distance = vector_distance(origin1,origin2);
// if we are close enough, assume we are at the center
if(distance < 40.0)
return maxVal;
// otherwise, calculate the distance range
else
percent = 1.0 - (distance / radius);
// we have the technology...
return minVal + (percent * (maxVal - minVal));
}
// displays x y z axis
public show_xyz(origin[3],radius)
{
message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
write_byte(0); // TE_BEAMPOINTS
write_coord(origin[0]); // start x
write_coord(origin[1]); // starty
write_coord(origin[2] + 1); // start z
write_coord(origin[0] + radius); // end x
write_coord(origin[1]); // end y
write_coord(origin[2] + 1); // end z
write_short(trailSpr); // sprite
write_byte(0); // starting frame
write_byte(0); // framerate
write_byte(100); // life
write_byte(8); // line width
write_byte(0); // noise
write_byte(255); // r
write_byte(0); // g
write_byte(0); // b
write_byte(200); // brightness
write_byte(0); // scroll speed
message_end();
message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
write_byte(0); // TE_BEAMPOINTS
write_coord(origin[0]); // start x
write_coord(origin[1]); // starty
write_coord(origin[2] + 1); // start z
write_coord(origin[0]); // end x
write_coord(origin[1] + radius); // end y
write_coord(origin[2] + 1); // end z
write_short(trailSpr); // sprite
write_byte(0); // starting frame
write_byte(0); // framerate
write_byte(100); // life
write_byte(8); // line width
write_byte(0); // noise
write_byte(0); // r
write_byte(255); // g
write_byte(0); // b
write_byte(200); // brightness
write_byte(0); // scroll speed
message_end();
message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
write_byte(0); // TE_BEAMPOINTS
write_coord(origin[0]); // start x
write_coord(origin[1]); // starty
write_coord(origin[2]); // start z
write_coord(origin[0]); // end x
write_coord(origin[1]); // end y
write_coord(origin[2] + radius); // end z
write_short(trailSpr); // sprite
write_byte(0); // starting frame
write_byte(0); // framerate
write_byte(100); // life
write_byte(8); // line width
write_byte(0); // noise
write_byte(0); // r
write_byte(0); // g
write_byte(255); // b
write_byte(200); // brightness
write_byte(0); // scroll speed
message_end();
}
// give an entity a trail
public set_beamfollow(ent,life,width,r,g,b,brightness)
{
message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
write_byte(22); // TE_BEAMFOLLOW
write_short(ent); // ball
write_short(trailSpr); // sprite
write_byte(life); // life
write_byte(width); // width
write_byte(r); // r
write_byte(g); // g
write_byte(b); // b
write_byte(brightness); // brightness
message_end();
}
// blue blast
public create_blast(origin[3])
{
// smallest ring
message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
write_byte(21); // TE_BEAMCYLINDER
write_coord(origin[0]); // start X
write_coord(origin[1]); // start Y
write_coord(origin[2]); // start Z
write_coord(origin[0]); // something X
write_coord(origin[1]); // something Y
write_coord(origin[2] + 385); // something Z
write_short(exploSpr); // sprite
write_byte(0); // startframe
write_byte(0); // framerate
write_byte(4); // life
write_byte(60); // width
write_byte(0); // noise
write_byte(FROST_R); // red
write_byte(FROST_G); // green
write_byte(FROST_B); // blue
write_byte(100); // brightness
write_byte(0); // speed
message_end();
// medium ring
message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
write_byte(21); // TE_BEAMCYLINDER
write_coord(origin[0]); // start X
write_coord(origin[1]); // start Y
write_coord(origin[2]); // start Z
write_coord(origin[0]); // something X
write_coord(origin[1]); // something Y
write_coord(origin[2] + 470); // something Z
write_short(exploSpr); // sprite
write_byte(0); // startframe
write_byte(0); // framerate
write_byte(4); // life
write_byte(60); // width
write_byte(0); // noise
write_byte(FROST_R); // red
write_byte(FROST_G); // green
write_byte(FROST_B); // blue
write_byte(100); // brightness
write_byte(0); // speed
message_end();
// largest ring
message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
write_byte(21); // TE_BEAMCYLINDER
write_coord(origin[0]); // start X
write_coord(origin[1]); // start Y
write_coord(origin[2]); // start Z
write_coord(origin[0]); // something X
write_coord(origin[1]); // something Y
write_coord(origin[2] + 555); // something Z
write_short(exploSpr); // sprite
write_byte(0); // startframe
write_byte(0); // framerate
write_byte(4); // life
write_byte(60); // width
write_byte(0); // noise
write_byte(FROST_R); // red
write_byte(FROST_G); // green
write_byte(FROST_B); // blue
write_byte(100); // brightness
write_byte(0); // speed
message_end();
// light effect
message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
write_byte(27); // TE_DLIGHT
write_coord(origin[0]); // x
write_coord(origin[1]); // y
write_coord(origin[2]); // z
write_byte(floatround(FROST_RADIUS/5.0)); // radius
write_byte(FROST_R); // r
write_byte(FROST_G); // g
write_byte(FROST_B); // b
write_byte(8); // life
write_byte(60); // decay rate
message_end();
}
check_map() {
new got_line, line_num, len
new cfgdir[MAX_TEXT_LENGTH]
new cfgpath[MAX_TEXT_LENGTH]
new mapname[MAX_NAME_LENGTH]
new txt[MAX_TEXT_LENGTH]
get_configsdir(cfgdir, MAX_TEXT_LENGTH-1)
get_mapname(mapname, MAX_NAME_LENGTH-1)
format(cfgpath, MAX_TEXT_LENGTH, "%s/market_maps.cfg", cfgdir)
if (file_exists(cfgpath)) {
got_line = read_file(cfgpath, line_num, txt, MAX_TEXT_LENGTH-1, len)
while (got_line>0) {
if (equali(txt, mapname)) return 1
line_num++
got_line = read_file(cfgpath, line_num, txt, MAX_TEXT_LENGTH-1, len)
}
}
return 0
}
Код за потвърждение: Избери целия код
LANG
MARKET_GRAV_1_1 = \r1.\d Gravity - %d $^n
MARKET_GRAV_1_2 = \r1. \yГGravity - \r%d $^n
MARKET_SPEED_1_1 = \r2.\d Speed - %d $^n
MARKET_SPEED_1_2 = \r2. \ySpeed - \r%d $^n
MARKET_HP_1_1 = \r3.\d 100 HP - %d $^n
MARKET_HP_1_2 = \r3. \y100 HP - \r%d $^n
MARKET_HE_1_1 = \r4.\d Fragment grenade - %d $^n
MARKET_HE_1_2 = \r4. \yFragment grenade - \r%d $^n
MARKET_ICE_1_1 = \r5.\d Freezing grenade - %d $^n
MARKET_ICE_1_2 = \r5. \yFreezing grenade - \r%d $^n
MARKET_DE_1_1 = \r6.\d Deagle(7 cartridge) - %d $^n
MARKET_DE_1_2 = \r6. \yDeagle(7 cartridge) - \r%d $^n
MARKET_INVIS_1_1 = \r7.\d Invisibility 15sec - %d $^n
MARKET_INVIS_1_2 = \r7. \yInvisibility 15sec - \r%d $^n
MARKET_HAMELION_1_1 = \r8.\d Chameleon [Clothes of the enemy] - %d $^n
MARKET_HAMELION_1_2 = \r8. \yChameleon \ w [\ Clothes of the enemy\w]- \r%d $^n
/*Уведомления*/
/*Цвет - \y - стандартный, \g - зеленый, \t - цвет команды*/
MARKET_NOMONEY = \y[\gSupermarket\y] \g%s\y у you do not have enough money to buy.
MARKET_GRAV_MSG = \y[\gSupermarket\y] Player \g%s\y bought gravity.
MARKET_SPEED_MSG = \y[\gSupermarket\y] Player \g%s\y bought speed.
MARKET_HP_MSG = \y[\gSupermarket\y] Player \g%s\y bought 100hp.
MARKET_HE_MSG = \y[\gSupermarket\y] Player \g%s\y bought a fragmentation grenade.
MARKET_ICE_MSG = \y[\gСSupermarket\y] Player \g%s\y bought a freezing grenade.
MARKET_DEAGLE_MSG = \y[\gSupermarket\y] Player \g%s\y bought a digl.
MARKET_INVIS_MSG = \y[\gSupermarket\y] Player \g%s\y became invisible for 15 seconds.
MARKET_INVIS_MSG_OFF = \y[\gSupermarket\y] \g%s\y ваша невидимость закончилась!
MARKET_HAMELION_MSG = \y[\gSupermarket\y] One of the players became a chameleon! Be careful.
MARKET_HAMELION_MSG_CT = \y[\gSupermarket\y] You put on clothes \ gTerrorist\y.
MARKET_HAMELION_MSG_T = \y[\gSupermarket\y] You put on clothes \ g Spetsnaz\y.
MARKET_RESPAWN = \y[\gSupermarket\y] Player \g%s\y reborn.
MARKET_RESPAWN_NO = \y[\gSupermarket\y] You refused to purchase.