Обратите внимание, если вы хотите заключить сделку с этим пользователем, он заблокирован
- Ошибка
-
ниже
- Компилятор
- Локальный
- Amx Mod X
- 1.10.0
- Исходный код
-
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <reapi>
#define m_Material 36
#define PDATA_VALID 2
#define is_entity(%0) (pev_valid(%0) == PDATA_VALID)
#define is_user(%0) (1 <= %0 <= MaxClients)
#define subtraction(%0) (- %0)
#define MSGID_BARTIME 108
#define MAT_COMPUTER 6
#define set_laser_team(%0,%1) set_pev(%0, pev_iuser1, %1)
#define get_laser_team(%0) pev(%0, pev_iuser1)
#define set_laser_user_id(%0,%1) set_pev(%0, pev_euser1, %1)
#define get_laser_user_id(%0) pev(%0, pev_euser1)
#define set_laser_user_level_id(%0,%1) set_pev(%0, pev_euser2, %1)
#define get_laser_user_level_id(%0) pev(%0, pev_euser2)
#define set_laser_beam(%0,%1) set_pev(%0, pev_iuser2, %1)
#define get_laser_beam(%0) pev(%0, pev_iuser2)
#define set_laser_timetask(%0,%1) set_pev(%0, pev_fuser1, %1)
#define get_laser_timetask(%0,%1) pev(%0, pev_fuser1, %1)
#define LASER_TIME_DATA 0.1 // Время обновления информации о мине
#define LASER_HEALTH 500.0 // Здоровье мины
#define LASER_HEALTH_LEVEL 300.0 // Добавление HP на 2 уровне
#define LASER_REWARD 1200 // Награда за убийства мины
#define LASER_MAX 3 // Максимальное количество мин у игрока
#define LASER_DISTANCE_INFO 500.0 // Дистанция показа информации лазера
#define LASER_PRICE 1500 // Цена мины
#define LASER_PRICE_LEVEL 1000 // Цена на улучшения до 2 уровня
#define LASER_MODEL "models/406/lasermine.mdl" // Модель мины
#define LASER_EXPLOS "sprites/zerogxplode.spr" // Спрайт взрыва
#define LASER_REWARD_ATTACKER 150 // Награда за убийство миной
#define LASER_REWARD_ATTACKER_LEVEL 150 // Награда игроку за мину 2 уровня
#define LASER_DAMAGE 10.0 // Урон мины 1 уровня
#define LASER_DAMAGE_LEVEL 20.0 // Урон мины 2 уровня
new const Float:g_Damage[2] = {LASER_DAMAGE, LASER_DAMAGE_LEVEL}
new const g_Color[2][3] = {{255, 0, 0}, {0, 0, 255}}
new g_Ancient[33], g_Count[33], g_Explos
#define SOUND 5
new const g_Sound[SOUND][] =
{
"weapons/mine_deploy.wav",
"weapons/mine_charge.wav",
"weapons/mine_activate.wav",
"items/suitchargeok1.wav",
"ambience/techamb1.wav"
}
#define SPRITE 2
new const g_Sprite[SPRITE][] =
{
"sprites/406/lasermine_t.spr",
"sprites/406/lasermine_ct.spr"
}
remove_lasermines(player)
{
g_Count[player] = 0
new entity = MaxClients
while((entity = engfunc(EngFunc_FindEntityByString, entity, "classname", "lasermine")))
{
if(get_laser_user_id(entity) != player) continue
engfunc(EngFunc_EmitSound, entity, CHAN_VOICE, g_Sound[4], VOL_NORM, ATTN_NORM, SND_STOP, PITCH_NORM)
set_pev(get_laser_beam(entity), pev_flags, FL_KILLME)
set_pev(entity, pev_flags, FL_KILLME)
}
}
GunPlayerPositionTraceLine(player, const Float:distance, const traceResult = 0)
{
new Float:vOrigin[3], Float:vAngle[3]
ExecuteHam(Ham_Player_GetGunPosition, player, vOrigin)
pev(player, pev_v_angle, vAngle)
angle_vector(vAngle, ANGLEVECTOR_FORWARD, vAngle)
for(new i; i < 3; i++) vAngle[i] = vAngle[i] * distance + vOrigin[i]
engfunc(EngFunc_TraceLine, vOrigin, vAngle, DONT_IGNORE_MONSTERS, player, traceResult)
}
public plugin_precache()
{
for(new i; i < SPRITE; i++) engfunc(EngFunc_PrecacheModel, g_Sprite[i])
for(new i; i < SOUND; i++) engfunc(EngFunc_PrecacheSound, g_Sound[i])
g_Explos = engfunc(EngFunc_PrecacheModel, LASER_EXPLOS)
engfunc(EngFunc_PrecacheModel, LASER_MODEL)
}
public plugin_init()
{
register_plugin("Laser Mine", "4.02.2018", "406")
register_clcmd("+setlaser", "clcmd_SetLaser")
register_clcmd("-setlaser", "clcmd_UnSetLaser")
RegisterHam(Ham_TakeDamage, "func_breakable", "fw_TakeDamagePre")
RegisterHam(Ham_Think, "func_breakable", "fw_ThinkPre")
RegisterHam(Ham_Touch, "func_breakable", "fw_TouchPre")
RegisterHookChain(RG_CBasePlayer_Killed, "rg_KilledPost", 1)
RegisterHookChain(RG_CSGameRules_RestartRound, "rg_RestartRoundPre")
RegisterHookChain(RG_CBasePlayer_ResetMaxSpeed, "rg_ResetMaxSpeedPost", 1)
new entity = rg_create_entity("func_breakable")
set_pev(entity, pev_classname, "datalaser")
set_pev(entity, pev_nextthink, get_gametime() + LASER_TIME_DATA)
}
public clcmd_SetLaser(player)
{
if(!is_user_alive(player)) return PLUGIN_HANDLED
if(is_entity(g_Ancient[player]))
{
if(pev(g_Ancient[player], pev_solid) == SOLID_TRIGGER)
return PLUGIN_HANDLED
}
if(g_Count[player] >= LASER_MAX)
{
client_print_color(player, player, "^4[Лазер] ^1Установлено максимум лазеров!")
return PLUGIN_HANDLED
}
if(get_member(player, m_iAccount) < LASER_PRICE)
{
client_print_color(player, player, "^4[Лазер] ^1Недостаточно денег, нужно: ^3%d$", LASER_PRICE)
return PLUGIN_HANDLED
}
new entity = g_Ancient[player] = rg_create_entity("func_breakable")
engfunc(EngFunc_SetModel, entity, LASER_MODEL)
set_pev(entity, pev_solid, SOLID_TRIGGER)
set_pev(entity, pev_movetype, MOVETYPE_FLY)
set_pev(entity, pev_classname, "lasermine")
engfunc(EngFunc_SetSize, entity, Float:{-7.26, -3.05, -0.06}, Float:{7.23, 3.52, 7.04})
set_pev(entity, pev_rendermode, 5)
set_pev(entity, pev_health, LASER_HEALTH)
set_pev(entity, pev_renderamt, 200.0)
set_laser_timetask(entity, get_gametime() + 1.0)
set_pev(entity, pev_sequence, 7)
set_pev(entity, pev_takedamage, DAMAGE_NO)
set_pdata_int(entity, m_Material, MAT_COMPUTER, 4)
set_laser_team(entity, get_member(player, m_iTeam))
set_laser_user_id(entity, player)
if(!fw_ThinkPre(entity)) return PLUGIN_HANDLED
message_begin(MSG_ONE, MSGID_BARTIME, _, player)
write_short(1); message_end()
set_pev(player, pev_maxspeed, 1.0)
return PLUGIN_HANDLED
}
public clcmd_UnSetLaser(player)
{
if(is_entity(g_Ancient[player]) && pev(g_Ancient[player], pev_rendermode) == 5)
{
engfunc(EngFunc_EmitSound, g_Ancient[player], CHAN_VOICE, g_Sound[4], VOL_NORM, ATTN_NORM, SND_STOP, PITCH_NORM)
set_pev(g_Ancient[player], pev_flags, FL_KILLME)
set_pev(g_Ancient[player], pev_rendermode, 0)
rg_reset_maxspeed(player)
message_begin(MSG_ONE, MSGID_BARTIME, _, player)
write_short(0); message_end()
}
}
public rg_ResetMaxSpeedPost(player) if(is_entity(g_Ancient[player]) && pev(g_Ancient[player], pev_rendermode) == 5) set_pev(player, pev_maxspeed, 1.0)
public client_disconnected(player) if(g_Count[player]) remove_lasermines(player)
public rg_RestartRoundPre()
{
for(new player = 1; player <= MaxClients; player++)
{
if(!g_Count[player]) continue
remove_lasermines(player)
}
}
public rg_KilledPost(victim, attacker)
{
if(g_Count[victim]) remove_lasermines(victim)
if(is_user(attacker)) rg_add_account(attacker, LASER_REWARD_ATTACKER)
new entity = pev(victim, pev_dmg_inflictor)
if(!FClassnameIs(entity, "lasermine")) return HC_CONTINUE
new player = get_laser_user_level_id(entity)
if(is_user(player)) rg_add_account(player, LASER_REWARD_ATTACKER_LEVEL)
return HC_CONTINUE
}
public fw_TouchPre(victim, inflictor)
{
if(!is_user_alive(inflictor) || !FClassnameIs(victim, "lasermine")) return HAM_IGNORED
if(pev(victim, pev_takedamage) == DAMAGE_NO || get_laser_user_id(victim) == inflictor || get_laser_user_level_id(victim) || get_member(inflictor, m_iTeam) != get_laser_team(victim)) return HAM_IGNORED
if(get_member(inflictor, m_iAccount) < LASER_PRICE_LEVEL)
{
client_print_color(inflictor, inflictor, "^4[Лазер] ^1Недостаточно денег, нужно: ^3%d$", LASER_PRICE_LEVEL)
return HAM_IGNORED
}
engfunc(EngFunc_EmitSound, victim, CHAN_VOICE, g_Sound[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
set_pev(victim, pev_health, pev(victim, pev_health) + LASER_HEALTH_LEVEL)
rg_add_account(inflictor, subtraction(LASER_PRICE_LEVEL))
set_laser_user_level_id(victim, inflictor)
set_pev(victim, pev_body, 1)
return HAM_IGNORED
}
public fw_ThinkPre(entity)
{
new player, victim, szClass[10], Float:FTime = get_gametime()
pev(entity, pev_classname, szClass, charsmax(szClass))
if(szClass[0] == 'd' && szClass[4] == 'l' && szClass[8] == 'r')
{
set_pev(entity, pev_nextthink, FTime + LASER_TIME_DATA)
for(player = 1; player <= MaxClients; player++)
{
if(!is_user_alive(player)) continue
GunPlayerPositionTraceLine(player, LASER_DISTANCE_INFO)
victim = get_tr2(0, TR_pHit)
if(!is_entity(victim) || !FClassnameIs(victim, "lasermine")) continue
new szName[32], i = get_laser_team(victim) - 1
get_user_name(get_laser_user_id(victim), szName, charsmax(szName))
set_hudmessage(g_Color[i][0], g_Color[i][1], g_Color[i][2], -1.0, 0.4, 0, _, LASER_TIME_DATA, _, 0.01, -1)
show_hudmessage(player, "[%s]^n[Уровень: %d]^n[HP: %i]", szName, is_user(get_laser_user_level_id(victim)) ? 2 : 1, pev(victim, pev_health))
}
return HAM_IGNORED
}
if(szClass[0] != 'l' && szClass[5] != 'm' && szClass[8] != 'e') return HAM_IGNORED
new Float:vOrigin[3], Float:vAngle[3]
if(pev(entity, pev_rendermode) == 5)
{
player = get_laser_user_id(entity)
get_laser_timetask(entity, vOrigin[0])
set_pev(entity, pev_nextthink, FTime + 0.001)
if(vOrigin[0] <= FTime)
{
engfunc(EngFunc_EmitSound, entity, CHAN_VOICE, g_Sound[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
engfunc(EngFunc_EmitSound, entity, CHAN_BODY, g_Sound[1], 0.2, ATTN_NORM, 0, PITCH_NORM)
set_pev(entity, pev_rendermode, 0)
set_pev(entity, pev_renderamt, 16.0)
set_pev(entity, pev_nextthink, FTime + 1.0)
rg_add_account(player, subtraction(LASER_PRICE))
rg_reset_maxspeed(player)
g_Count[player]++
return HAM_IGNORED
}
else
{
GunPlayerPositionTraceLine(player, 100.0)
get_tr2(0, TR_flFraction, vOrigin[0])
if(vOrigin[0] >= 1.0)
{
set_pev(entity, pev_rendermode, 0)
rg_reset_maxspeed(player)
set_pev(entity, pev_flags, FL_KILLME)
message_begin(MSG_ONE, MSGID_BARTIME, _, player)
write_short(0); message_end()
return PLUGIN_CONTINUE
}
get_tr2(0, TR_vecPlaneNormal, vAngle)
get_tr2(0, TR_vecEndPos, vOrigin)
victim = MaxClients
while((victim = engfunc(EngFunc_FindEntityInSphere, victim, vOrigin, 15.0)) != 0)
if(victim != entity && is_entity(victim) && FClassnameIs(victim, "lasermine")) return PLUGIN_CONTINUE
victim = get_tr2(0, TR_pHit)
if(is_entity(victim))
{
if(pev(victim, pev_health)) return PLUGIN_CONTINUE
pev(victim, pev_classname, szClass, charsmax(szClass))
if(szClass[5] == 'd' && szClass[6] == 'o' && szClass[7] == 'o' && szClass[8] == 'r') return PLUGIN_CONTINUE
}
engfunc(EngFunc_SetOrigin, entity, vOrigin)
vector_to_angle(vAngle, vOrigin)
set_pev(entity, pev_angles, vOrigin)
for(new i; i < 3; i++) vAngle[i] *= 8192.0
set_pev(entity, pev_vuser1, vAngle)
return HAM_IGNORED
}
}
pev(entity, pev_origin, vOrigin)
if(pev(entity, pev_takedamage) == DAMAGE_NO)
{
victim = FM_NULLENT
while((victim = engfunc(EngFunc_FindEntityInSphere, victim, vOrigin, 5.0)) <= MaxClients && victim)
{
if(!is_user_alive(victim)) continue
set_pev(entity, pev_nextthink, FTime + 0.3)
return HAM_IGNORED
}
engfunc(EngFunc_EmitSound, entity, CHAN_VOICE, g_Sound[2], 0.5, ATTN_NORM, 1, 75)
set_pev(entity, pev_solid, SOLID_SLIDEBOX)
set_pev(entity, pev_takedamage, DAMAGE_YES)
set_pev(entity, pev_nextthink, FTime + 0.1)
return HAM_IGNORED
}
pev(entity, pev_vuser1, vAngle)
for(new i; i < 3; i++) vAngle[i] += vOrigin[i]
victim = entity
while(is_entity(victim))
{
engfunc(EngFunc_TraceLine, vOrigin, vAngle, DONT_IGNORE_MONSTERS, victim, 0)
get_tr2(0, TR_vecEndPos, vOrigin)
victim = get_tr2(0, TR_pHit)
if(is_user_alive(victim) && get_member(victim, m_iTeam) != get_laser_team(entity) && pev(victim, pev_takedamage) != DAMAGE_NO && pev(victim, pev_solid) != SOLID_NOT)
{
engfunc(EngFunc_EmitSound, victim, CHAN_WEAPON, g_Sound[3], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
ExecuteHamB(Ham_TakeDamage, victim, entity, get_laser_user_id(entity), g_Damage[is_user(get_laser_user_level_id(entity))], DMG_ENERGYBEAM)
}
}
if(!get_laser_beam(entity))
{
victim = rg_create_entity("beam")
engfunc(EngFunc_SetModel, victim, g_Sprite[get_laser_team(entity) - 1])
engfunc(EngFunc_SetSize, victim, Float:{-8192.0, -8192.0, -8192.0}, Float:{8192.0, 8192.0, 8192.0})
set_pev(victim, pev_rendercolor, Float:{255.0, 255.0, 255.0})
set_pev(victim, pev_rendermode, 17)
set_pev(victim, pev_origin, vOrigin)
set_pev(victim, pev_skin, entity)
set_pev(victim, pev_aiment, entity)
set_pev(victim, pev_flags, FL_CUSTOMENTITY)
set_pev(victim, pev_renderamt, 255.0)
set_pev(victim, pev_scale, 15.0)
set_laser_beam(entity, victim)
}
set_pev(entity, pev_nextthink, FTime + 0.1)
get_laser_timetask(entity, vOrigin[0])
if(vOrigin[0] > FTime) return HAM_IGNORED
engfunc(EngFunc_EmitSound, entity, CHAN_VOICE, g_Sound[4], 0.2, 3.0, 0, PITCH_NORM)
set_laser_timetask(entity, FTime + 0.5)
return HAM_IGNORED
}
public fw_TakeDamagePre(victim, inflictor, attacker, Float:damage, damagebits)
{
if(!FClassnameIs(victim, "lasermine")) return HAM_IGNORED
if(!is_user(attacker)) return HAM_IGNORED
new player = get_laser_user_id(victim)
if(attacker != player && get_member(attacker, m_iTeam) == get_laser_team(victim)) return HAM_SUPERCEDE
if(pev(victim, pev_health) > damage) return HAM_IGNORED
new szName[32]
get_user_name(attacker, szName, charsmax(szName))
if(player == attacker) client_print_color(attacker, attacker, "^4[Лазер] ^1Вы разрушили свой лазер.")
else
{
client_print_color(attacker, attacker, "^4[Лазер] ^1Лазер разрушен, награда: ^3%d$", LASER_REWARD)
client_print_color(player, player, "^4[Лазер] ^3%s ^1разрушил(а) ваш лазер.", szName)
rg_add_account(attacker, LASER_REWARD)
}
engfunc(EngFunc_EmitSound, victim, CHAN_VOICE, g_Sound[4], VOL_NORM, ATTN_NORM, SND_STOP, PITCH_NORM)
set_pev(get_laser_beam(victim), pev_flags, FL_KILLME)
set_pev(victim, pev_flags, FL_KILLME)
g_Count[player]--
new Float:vOrigin[3]
pev(victim, pev_origin, vOrigin)
engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, vOrigin, 0)
write_byte(TE_EXPLOSION)
for(new i; i < 3; i++) engfunc(EngFunc_WriteCoord, vOrigin[i])
write_short(g_Explos)
write_byte(15)
write_byte(15)
write_byte(0)
message_end()
return HAM_IGNORED
}
В этой теме было размещено решение! Перейти к решению.