Русское сообщество по скриптингу

Скачал скрипт он не работает сидел Плиз

Все вопросы по скриптингу для SourceMod, помощь в редактировании плагинов.
Правила форума
1. Запрещено материться и оскорблять других участников форума.
2. Запрещен флуд, оффтоп, дабл постинг во всех разделах форума, кроме раздела "Болтовня".
3. Запрещено взламывать сайт/форум или наносить любой вред проекту.
4. Запрещено рекламировать другие ресурсы.
5. Запрещено создавать темы без информативного названия. Название темы должно отображать ее смысл.

В данном разделе форума разрешено создавать темы, касающие только скриптингу для SourceMod.

Правила при создании новой темы:
1. При вставке кода плагина необходимо использовать тег [pawn], в противном случае, если тег [pawn] не отображает ваш код, можно использовать тег [code].
2. Любые изображения должны быть загружены, как вложения к вашему сообщению.
3. При описании проблемы или запросе на помощь в редактировании плагина обязательно выкладывайте исходник sp плагина.

Скачал скрипт он не работает сидел Плиз

Сообщение Phubaxz » 07 дек 2016, 11:30

Код: Выделить всё
#include <amxmodx>
#include <engine>
#include <fun>
#include <cstrike>
#include <fakemeta>
#include <hamsandwich>
#include <xs>

#if AMXX_VERSION_NUM < 183
    #define message_begin_f(%0,%1,%2,%3)    engfunc(EngFunc_MessageBegin,%0,%1,%2,%3)
    #define write_coord_f(%0)        engfunc(EngFunc_WriteCoord,%0)
    
    #include <dhudmessage>
#endif


native sh_set_hero id )
native give_shield_grenade id )


#define is_valid_player(%1) ( 1 <= %1 <= g_iMaxPlayers )
#define is_valid_team(%1) ( 0 < %1 < 3 )

#define is_entity_on_ground(%1) ( entity_get_int ( %1, EV_INT_flags ) & FL_ONGROUND )

// сколько пушек у игрока уже построено
#define GetSentryCount(%1) g_iPlayerSentries[%1]

#define MAXUPGRADERANGE        75.0
#define SENTRYEXPLODERADIUS        250.0            // радиус отброса при взрыве
#define SENTRYTILTRADIUS            830.0            // likely you won't need to touch this. it's how accurate the cannon will aim at the target vertically (up/down, just for looks, aim is calculated differently)

#define SENTRYMINDISTANCE    256.0

#define MAXSENTRIES                32 * 3

#define TASK_GODMODE 114455

#define SENTRY_INT_PEOPLE        EV_INT_iuser2 // max 5 users using 6 bits!
#define SENTRY_INT_UGPRADERS        EV_INT_iuser3
#define SENTRY_PEOPLE_BITS        6
#define OWNER                    0
#define UPGRADER_1                1
#define UPGRADER_2                2
#define TARGET                    3
#define UPGRADER_3                4
#define MASK_OWNER                0xFFFFFFC0 // 11111111111111111111111111000000
#define MASK_UPGRADER_1            0xFFFFF03F // 11111111111111111111000000111111
#define MASK_UPGRADER_2            0xFFFC0FFF // 11111111111111000000111111111111
#define MASK_TARGET                0xFF03FFFF // 11111111000000111111111111111111
#define MASK_UPGRADER_3                0xC0FFFFFF // 11000000111111111111111111111111
new const MASKS_PEOPLE[5] = {MASK_OWNERMASK_UPGRADER_1MASK_UPGRADER_2MASK_TARGETMASK_UPGRADER_3}

GetSentryPeople(const SENTRY, const WHO) {
    new 
data entity_get_int(SENTRYSENTRY_INT_PEOPLE)
    
data |= MASKS_PEOPLE[WHO]
    
data ^= MASKS_PEOPLE[WHO]
    
data = (data>>(WHO*SENTRY_PEOPLE_BITS))
    return 
data
}
SetSentryPeople(const SENTRY, const WHO, const IS) {
    new 
data entity_get_int(SENTRYSENTRY_INT_PEOPLE)
    
data &= MASKS_PEOPLE[WHO// nullify the setting
    
data |= (IS<<(WHO*SENTRY_PEOPLE_BITS)) // set the setting
    
entity_set_int(SENTRYSENTRY_INT_PEOPLEdata// store
}

#define SENTRY_INT_SETTINGS        EV_INT_iuser1
#define SENTRY_ROCKET_TIME        EV_FL_teleport_time
#define SENTRY_SETTINGS_BITS    2
#define SENTRY_SETTING_FIREMODE    0
#define SENTRY_SETTING_TEAM        1
#define SENTRY_SETTING_LEVEL    2
#define SENTRY_SETTING_PENDDIR    3
#define MASK_FIREMODE            0xFFFFFFFC // 11111111111111111111111111111100 = FFFFFFFC
#define MASK_TEAM                0xFFFFFFF3 // 11111111111111111111111111110011 = FFFFFFF3
#define MASK_LEVEL                0xFFFFFFCF // 11111111111111111111111111001111 = FFFFFFCF
#define MASK_PENDDIR            0xFFFFFF3F // 11111111111111111111111100111111 = FFFFFF3F
new const MASKS_SETTINGS[4] = {MASK_FIREMODEMASK_TEAMMASK_LEVELMASK_PENDDIR}

GetSentrySettings(const SENTRY, const SETTING) {
    new 
data entity_get_int(SENTRYSENTRY_INT_SETTINGS)
    
data |= MASKS_SETTINGS[SETTING]
    
data ^= MASKS_SETTINGS[SETTING]
    
//data = (data>>(SETTING*SENTRY_SETTINGS_BITS))
    
return (data>>(SETTING*SENTRY_SETTINGS_BITS))
}
SetSentrySettings(const SENTRY, const SETTING, const VALUE) {
    new 
data entity_get_int(SENTRYSENTRY_INT_SETTINGS)
    
data &= MASKS_SETTINGS[SETTING// nullify the setting
    //data |= (VALUE<<(SETTING*SENTRY_SETTINGS_BITS)) // set the setting
    
entity_set_int(SENTRYSENTRY_INT_SETTINGSdata | (VALUE<<(SETTING*SENTRY_SETTINGS_BITS))) // store
}

GetSentryFiremode(const SENTRY) {
    return 
GetSentrySettings(SENTRYSENTRY_SETTING_FIREMODE)
}
SetSentryFiremode(const SENTRY, const MODE) {
    
SetSentrySettings(SENTRYSENTRY_SETTING_FIREMODEMODE)
}
CsTeams:GetSentryTeam(const SENTRY) {
    return 
CsTeams:GetSentrySettings(SENTRYSENTRY_SETTING_TEAM)
}
SetSentryTeam(const SENTRY, const CsTeams:TEAM) {
    
SetSentrySettings(SENTRYSENTRY_SETTING_TEAMint:TEAM)
}
GetSentryLevel(const SENTRY) {
    return 
GetSentrySettings(SENTRYSENTRY_SETTING_LEVEL)
}
SetSentryLevel(const SENTRY, const LEVEL) {
    
SetSentrySettings(SENTRYSENTRY_SETTING_LEVELLEVEL)
}
GetSentryPenddir(const SENTRY) {
    return 
GetSentrySettings(SENTRYSENTRY_SETTING_PENDDIR)
}
SetSentryPenddir(const SENTRY, const PENDDIR) {
    
SetSentrySettings(SENTRYSENTRY_SETTING_PENDDIRPENDDIR)
}

#define SENTRY_ENT_BASE            EV_ENT_euser1

#define SENTRY_FL_ANGLE            EV_FL_fuser1
#define SENTRY_FL_SPINSPEED        EV_FL_fuser2
#define SENTRY_FL_MAXSPIN        EV_FL_fuser3
#define SENTRY_FL_LASTTHINK        EV_FL_fuser4

#define SENTRY_DIR_CANNON        0

#define BASE_ENT_SENTRY            EV_ENT_euser1
#define BASE_INT_TEAM            EV_INT_iuser1

#define SENTRY_LEVEL_1            0
#define SENTRY_LEVEL_2            1
#define SENTRY_LEVEL_3            2
#define SENTRY_LEVEL_4            3
#define SENTRY_FIREMODE_NO        0
#define SENTRY_FIREMODE_YES        1
#define SENTRY_FIREMODE_NUTS    2
#define TARGETUPMODIFIER            18.0 // if player ducks on ground, traces don't hit...
#define DMG_BULLET                (1<<1)    //выстрел
#define DMG_BLAST                (1<<6)    // explosive blast damage
#define TE_EXPLFLAG_NONE        0
#define TE_EXPLOSION                3
#define TE_TRACER                6
#define TE_BREAKMODEL            108
#define PENDULUM_MAX            45.0 // how far sentry turret turns in each direction when idle, before turning back
#define PENDULUM_INCREMENT        10.0 // speed of turret turning...
#define SENTRYSHOCKPOWER        3.0 // multiplier, increase to make exploding sentries throw stuff further away
#define CANNONHEIGHTFROMFEET    20.0 // tweakable to make tracer originate from the same height as the sentry's cannon. Also traces rely on this Y-wise offset.
#define PLAYERORIGINHEIGHT        36.0 // this is the distance from a player's EV_VEC_origin to ground, if standing up
#define HEIGHTDIFFERENCEALLOWED    20.0 // increase value to allow building in slopes with higher angles. You can set to 0.0 and you will only be able to build on exact flat ground. note: mostly applies to downhill building, uphill is still likely to "collide" with ground...

#define PLACE_RANGE 45.0

#define SENTRY_RADAR            20 // use as high as possible but should still be working (ie be able to see sentries plotted on radar while in menu, too high values doesn't seem to work)
#define SENTRY_RADAR_TEAMBUILT    21 // same as above

#define RPG_RADIUS    250.0
#define RPG_DAMAGE    150.0
#define RPG_DISTANCE    400.0

new const szModels[][] =
{
    
"models/dmsentries/base.mdl",
    
"models/dmsentries/sentry1_t.mdl",
    
"models/dmsentries/sentry2_t.mdl",
    
"models/dmsentries/sentry3_t.mdl",
    
"models/dmsentries/sentry1_ct.mdl",
    
"models/dmsentries/sentry2_ct.mdl",
    
"models/dmsentries/sentry3_ct.mdl",
    
"models/rpgrocket.mdl",
    
"models/computergibs.mdl"
}

new const 
szSounds[][] =
{
    
"debris/bustmetal1.wav",
    
"debris/bustmetal2.wav",
    
"debris/metal1.wav",
    
"debris/metal3.wav",
    
"dmsentries/turridle.wav",
    
"dmsentries/turrset.wav",
    
"dmsentries/turrspot.wav",
    
"dmsentries/building.wav",
    
"dmsentries/fire.wav",
    
"weapons/rocket1.wav"
}

new 
expDecal

#define SENTRYOWNERAWARD    300
#define SENTRYASSISTAWARD    150

new const g_DMG[4] = {5101515}                                // количество урона от пушки в зависимости от ее уровня
new const Float:g_THINKFREQUENCIES[4] = {2.01.00.50.5}        // через сколько захватывается цель
new const Float:g_HITRATIOS[4] = {0.60.750.850.85}            // разброс
new const Float:g_HEALTHS[4] = {3000.06000.09000.010000.0}    // сколько хп у пушки в зависимости от ее уровня (верхняя часть)
new const g_COST[4] = {300060060016000}                        // стоимость установки/улучшения пушек
new const g_SENTRYCOST[3] = {300035004000}                            // стоимость установки/улучшения пушек
#define g_sentriesNum (g_teamsentriesNum[0]+g_teamsentriesNum[1])
new g_teamsentriesNum[2]    
new 
g_sentries[MAXSENTRIES]
new 
g_iPlayerSentries[33]
new 
g_iPlayerSentriesEdicts[33][3]
new 
g_sModelIndexFireball
new g_msgDamage
new g_msgDeathMsg
new g_msgScoreInfo
new g_msgHostagePos
new g_msgHostageK
new g_iMaxPlayers
new Float:g_ONEEIGHTYTHROUGHPI
new Float:g_sentryOrigins[32][3]
new 
bool:g_inBuilding[33]
new 
sentries_num[33]
new 
gMsgID
new g_iTimer[33]
new 
m_iTrail

public plugin_init() {

    
register_plugin("Sentry guns""1.1""JGHG & miRror")

    
register_event "Spectator""ev_Spectation""a" )

    
register_clcmd("sentry_build""cmd_CreateSentry"0"- build a sentry gun where you are")
    
register_clcmd("say /sgstats""sgstats"0"- stats sentry")
    
register_clcmd("say /forcesh""givesgr")
    
    
RegisterHam Ham_Spawn"player""fw_PlayerSpawn_Post")

    
register_forward FM_TraceLine"fw_TraceLine_Post")

    
RegisterHam Ham_TakeDamage"func_breakable""fw_TakeDamage" )
    
    
register_touch "sentry""player""fw_TouchSentry" )
    
register_touch("rpg_rocket","*","fw_RpgTouch")
    
    
register_message 23"msg_TempEntity" )
    
register_think("sentrybase""think_sentrybase")
    
register_think "sentry""fw_ThinkSentry" )

    
g_msgDamage get_user_msgid("Damage")
    
g_msgDeathMsg get_user_msgid("DeathMsg")
    
g_msgScoreInfo get_user_msgid("ScoreInfo")
    
g_msgHostagePos get_user_msgid("HostagePos")
    
g_msgHostageK get_user_msgid("HostageK")
    
gMsgID get_user_msgid("StatusIcon")
    
    
g_iMaxPlayers get_global_int(GL_maxClients)
    
g_ONEEIGHTYTHROUGHPI 180.0 3.141592654
    
    expDecal 
get_decal_index("{scorch1")

    
set_task 120.0"checkhero", .flags "b" )
}

public 
plugin_precache() {
    for(new 
i=0;i<sizeof(szModels);i++)
        
precache_model(szModels[i])
    for(new 
i=0;i<sizeof(szSounds);i++)
        
precache_sound(szSounds[i])
    
g_sModelIndexFireball precache_model("sprites/zerogxplode.spr")
    
m_iTrail precache_model("sprites/smoke.spr")
}

public 
plugin_natives ()
{
    
register_native "get_sentry_people""native_get_sentry_people")
    
register_native "get_sentry_team""native_get_sentry_team")
}

public 
native_get_sentry_people sentrywho )
{
    return 
GetSentryPeople sentrywho )
}

public 
CsTeams:native_get_sentry_team sentry )
{
    return 
GetSentryTeam sentry )
}

public 
sgstats(id)
{
    
ChatColor id"^1Пушек у КТ: [ ^4%d ^1], ТТ: [ ^4%d ^1], у всех: [ ^4%d ^1]"g_teamsentriesNum[1],g_teamsentriesNum[0],g_sentriesNum)
}
public 
givesgr(id)
{
    if(
is_user_alive(id))
        
give_shield_grenade id )
        
    return 
PLUGIN_HANDLED
}

public 
checkhero()
{
    new 
iPlayers get_playersnum ()
    if(
iPlayers 15 && g_sentriesNum >= 14)
    {
        new 
players[32],  numplidbestfrags 0bool:heroenabled
        
new iData[2]; iData[0] = 5
        
if(g_teamsentriesNum[1] <= (g_sentriesNum 0.3))
        {
            
iData[1] = 1
            TimerStart 
iData )
            
get_players(playersnum"ache""CT")
            
heroenabled true
        
} else if(g_teamsentriesNum[0] <= (g_sentriesNum 0.3)) {
            
iData[1] = 0
            get_players
(playersnum"ache""TERRORIST")    
            
heroenabled true
        
}
        
        if(
heroenabled && num 1)
        {
            new 
iNum numiHero
            
for(--numnum>=0num--) 
            { 
                if(
get_user_frags(players[num]) >= bestfrags)
                {
                    
plid players[iHero num]
                    
bestfrags get_user_frags(plid)
                }
            }
            if ( 
sh_set_hero plid ) )
            {
                while (
GetSentryCount(plid) > 0)
                    
sentry_detonate_by_owner(plid)

                for ( new 
iHeroiNumi++ )
                    
players[i] = players[i+1]

                
iNum--
            }
            
/*if ( iNum > 0 )
            {
                new iParam[33]
                for ( new i; i < iNum; i++ )
                    iParam[i] = players[i]
                iParam[32] = iNum
                set_task ( 5.0, "GiveShieldGrenades", 0, iParam, 33 )
            }*/
        
}
    }
}

public 
TimerStart data[2] )
{
    if ( !
data[0] ) return

    
data[0]--

    
set_dhudmessage 255255255, -1.00.3500.01.00.00.0 )
    
show_dhudmessage 0"Выдача гранаты-ауры %s начнется через %d секунд"data[1] ? "контрам" "террам"data[0] )

    
set_task 1.0"TimerStart"0data)
}

public 
GiveShieldGrenades param[33] )
{
    new 
players[32], num param[32]
    for ( new 
inumi++ )
        
players[i] = param[i]

    new 
iPlayers[3], iNum clamp num1)

    for ( new 
ibiRandomiPlayeriNumi++ )
    {
        
iPlayer iPlayers[i] = players[iRandom random_num 0num-)]

        
//give_shield_grenade ( iPlayer )
        
g_iTimer[iPlayer] = 10
        set_user_godmode 
iPlayer)
        
TimerGodMode iPlayer )

        for ( 
iRandomnumb++ )
            
players[b] = players[b+1]
    }
    
set_dhudmessage 255255255, -1.00.3500.01.00.00.0 )
    
show_dhudmessage 0"Аура выдана %i игрокам"iNum )
}

public 
TimerGodMode id )
{
    if ( 
id g_iMaxPlayers )
        
id -= TASK_GODMODE

    
if ( !is_user_connected id ) || !is_user_alive id ) )
        return

    
set_dhudmessage 255255255, -1.00.3500.01.00.00.0 )

    if ( --
g_iTimer[id] > )
    {
        
show_dhudmessage id"У вас еще есть %i секунд бессмертия^nГраната аура - это дымовая граната"g_iTimer[id] )
        
set_task 1.0"SetGodMode"id+TASK_GODMODE )
    }
    else
    {
        
show_dhudmessage id"Режим бессмертия отключен" )
        
set_user_godmode id)
    }
}

public 
ev_Spectation ()
{
    new 
id read_data )

    if ( 
is_user_connected id ) && cs_get_user_team id ) == CS_TEAM_SPECTATOR )
        while ( 
GetSentryCount id ) > )
            
sentry_detonate_by_owner id )
}

public 
fw_TakeDamage entidinflictoridattackerFloat:damagedamagebits )
{
    if ( !
pev_valid ent ) )
        return 
HAM_IGNORED
    
    
new sClassname[11]
    
pev entpev_classnamesClassnamecharsmax sClassname ) )
    
    if ( 
equal sClassname"sentry" ) || equal sClassname"sentrybase" ) )
    {
        if ( 
sClassname[6] == 'b' )
            
ent entity_get_edict(entBASE_ENT_SENTRY)
        
        if ( 
pev_valid ent ) )
        {
            new 
iOwner GetSentryPeople entOWNER )
            
            if ( !
is_user_connected iOwner ) || !is_valid_player iOwner ) || !is_user_connected idattacker ) || !is_valid_player idattacker ) )
                return 
HAM_SUPERCEDE
        
            
if ( cs_get_user_team iOwner ) == cs_get_user_team idattacker ) && idattacker != iOwner )
                return 
HAM_SUPERCEDE
        
}
    }
    return 
HAM_IGNORED    
}

public 
cmd_CreateSentry id )
{
    new 
iSentry AimingAtSentry id )

    if ( 
iSentry && entity_range iSentryid ) <= MAXUPGRADERANGE )
        
SentryUpgrade idiSentry )
    else
        
SentryBuild id )

    return 
PLUGIN_HANDLED
}

public 
SentryBuild id )
{
    if ( !
is_user_alive id ) )
    {
        
ChatColor id"^3[^4Информация^3]^1 Мертвым нельзя ставить пушку!" )
        return
    }
    new 
iSentryCount GetSentryCount id )
    if ( 
iSentryCount == )
    {
        
ChatColor id"^3[^4Информация^3]^1 Нельзя установить более 3 пушек!" )
        return
    }
    if ( 
g_inBuilding[id] )
    {
        
ChatColor id"^3[^4Информация^3]^1 Эй, не так быстро..." )
        return
    }
    if ( !
is_entity_on_ground id ) )
    {
        
ChatColor id"^3[^4Информация^3]^1 Встань на землю, чтобы установить пушку!" )
        return
    }
    
    new 
Float:origin[3],classname[32],e
    entity_get_vector
(id,EV_VEC_origin,origin)
    
    
    
    while((
find_ent_in_sphere(e,origin,SENTRYMINDISTANCE))){
        
entity_get_string(e,EV_SZ_classname,classname,charsmax(classname))
        
        if(
strcmp(classname,"sentrybase") == && entity_get_int(eBASE_INT_TEAM) == get_user_team(id) && entity_get_edict(e,EV_ENT_owner) != id){
            
ChatColor(id,"^3[^4Информация^3]^1 Защита от подсосов")
            return
        }
    }
    
    if ( 
cs_get_user_money id ) < g_SENTRYCOST[iSentryCount] )
    {
        
ChatColor id"^3[^4Информация^3]^1 У тебя не хватает денег! (нужно %d$)"g_SENTRYCOST[iSentryCount] )
        return
    }

    new 
Float:fPlayerOrigin[3], Float:fOrigin[3], Float:fAngle[3]
    
pev idpev_originfPlayerOrigin )
    
pev idpev_anglesfAngle )
    
fOrigin fPlayerOrigin

    fOrigin
[0] += floatcos fAngle[1], degrees ) * PLACE_RANGE
    fOrigin
[1] += floatsin fAngle[1], degrees ) * PLACE_RANGE
    fOrigin
[0] += floatcos fAngle[0], degrees) * PLACE_RANGE
    fOrigin
[1] += floatcos fAngle[1], degrees )
    
fOrigin[0] -= floatsin fAngle[1], degrees )
    
fOrigin[1] += floatcos fAngle[2], degrees )
    
fOrigin[1] -= floatsin fAngle[2], degrees ) * PLACE_RANGE
    fOrigin
[0] -= floatsin fAngle[0], degrees ) * PLACE_RANGE
    fOrigin
[0] -= PLACE_RANGE

    
if ( pev idpev_flags ) & FL_DUCKING )
        
fOrigin[2] += 18.0fPlayerOrigin[2] += 18.0

    
new tr 0Float:fFraction
    engfunc 
EngFunc_TraceLinefPlayerOriginfOrigin0idtr )
    
get_tr2 trTR_flFractionfFraction )

    if ( 
fFraction != 1.0 )
    {
        
ChatColor id"^3[^4Информация^3]^1 Здесь не получается установить пушку!" )
        return
    }

    if ( 
CreateSentryBase fOriginid ) )
    {
        
cs_set_user_money idcs_get_user_money id ) - g_SENTRYCOST[iSentryCount] )
        
ammo_hud id)
        
sentries_num[id] += 1
        ammo_hud 
id)
    }
    else
        
ChatColor id"^3[^4Информация^3]^1 Здесь не получается установить пушку!" )
}

IncreaseSentryCount idsentry )
{
    
g_iPlayerSentriesEdicts[id][g_iPlayerSentries[id]] = sentry
    g_iPlayerSentries
[id]++
    new 
Float:fSentryOrigin[3], iSentryOrigin[3], iPlayerOrigin[3]
    
entity_get_vector sentryEV_VEC_originfSentryOrigin )
    
FVecIVec fSentryOriginiSentryOrigin )

    new 
sName[32]
    
get_user_name idsNamecharsmax sName ) )
    new 
CsTeams:iTeam cs_get_user_team id )

    for ( new 
1<= g_iMaxPlayersi++ )
    {
        if ( !
is_user_connected ) || !is_user_alive ) || cs_get_user_team ) != iTeam || id == )
            continue

        
get_user_origin iiPlayerOrigin )

        
client_print iprint_center"%s установил пушку в %d юнитах от вас"sNameget_distance iPlayerOriginiSentryOrigin ) )

        
message_begin MSG_ONE_UNRELIABLEg_msgHostagePos, .player )
        
write_byte )
        
write_byte SENTRY_RADAR_TEAMBUILT )
        
write_coord iSentryOrigin[0] )
        
write_coord iSentryOrigin[1] )
        
write_coord iSentryOrigin[2] )
        
message_end ()

        
message_begin MSG_ONE_UNRELIABLEg_msgHostageK, .player )
        
write_byte SENTRY_RADAR_TEAMBUILT )
        
message_end ()
    }
}
 
DecreaseSentryCount idsentry )
{
    for ( new 
ig_iPlayerSentries[id]; i++ )
    {
        if ( 
g_iPlayerSentriesEdicts[id][i] == sentry )
        {
            
g_iPlayerSentriesEdicts[id][i] = g_iPlayerSentriesEdicts[id][g_iPlayerSentries[id] - 1]
            
g_iPlayerSentriesEdicts[id][g_iPlayerSentries[id] - 1] = 0
            
break
        }
    }
    
g_iPlayerSentries[id]--
}

stock bool:CreateSentryBase Float:origin[3], creatorlevel SENTRY_LEVEL_1 )
{
    if ( !
CheckLocation origin ) )
        return 
false

    
new Float:hitPoint[3], Float:originDown[3]
    
originDown origin
    originDown
[2] = -5000.0 // dunno the lowest possible height...
    
trace_line(0originoriginDownhitPoint)
    new 
Float:baDistanceFromGround vector_distance(originhitPoint)

    new 
Float:difference PLAYERORIGINHEIGHT baDistanceFromGround
    
if (difference < -HEIGHTDIFFERENCEALLOWED || difference HEIGHTDIFFERENCEALLOWED) return false

    
new entbase create_entity("func_breakable"// func_wall
    
if (!entbase)
        return 
false

    
#define SIZE 16.0

    
new Float:fTraceEnds[5][3], Float:fTraceHit[3], iTypetr create_tr2 ()
    
fTraceEnds[0][0] = origin[0] - SIZE
    fTraceEnds
[0][1] = origin[1] - SIZE
    fTraceEnds
[0][2] = origin[2] + SIZE SIZE
    fTraceEnds
[1][0] = origin[0] + SIZE
    fTraceEnds
[1][1] = origin[1] - SIZE
    fTraceEnds
[1][2] = origin[2] + SIZE SIZE
    fTraceEnds
[2][0] = origin[0] - SIZE
    fTraceEnds
[2][1] = origin[1] + SIZE
    fTraceEnds
[2][2] = origin[2] + SIZE SIZE
    fTraceEnds
[3][0] = origin[0] + SIZE
    fTraceEnds
[3][1] = origin[1] + SIZE
    fTraceEnds
[3][2] = origin[2] + SIZE SIZE
    fTraceEnds
[4][0] = origin[0]
    
fTraceEnds[4][1] = origin[1]
    
fTraceEnds[4][2] = origin[2] + SIZE SIZE

    
for ( new i5i++ )
    {
        
fTraceHit fTraceEnds[i]
        
fTraceHit[2] += 40.0

        engfunc 
EngFunc_TraceLinefTraceEnds[i], fTraceHit00tr )
        
get_tr2 trTR_vecEndPosfTraceHit )

        if ( 
fTraceHit[2] - fTraceEnds[i][2] != 40.0 )
        {
            
iType 1
            
break
        }
    }

    if ( 
iType )
    {
        
fTraceEnds[0][0] = origin[0] - SIZE
        fTraceEnds
[0][1] = origin[1] - SIZE
        fTraceEnds
[0][2] = origin[2] - SIZE SIZE
        fTraceEnds
[1][0] = origin[0] + SIZE
        fTraceEnds
[1][1] = origin[1] - SIZE
        fTraceEnds
[1][2] = origin[2] - SIZE SIZE
        fTraceEnds
[2][0] = origin[0] - SIZE
        fTraceEnds
[2][1] = origin[1] + SIZE
        fTraceEnds
[2][2] = origin[2] - SIZE SIZE
        fTraceEnds
[3][0] = origin[0] + SIZE
        fTraceEnds
[3][1] = origin[1] + SIZE
        fTraceEnds
[3][2] = origin[2] - SIZE SIZE
        fTraceEnds
[4][0] = origin[0]
        
fTraceEnds[4][1] = origin[1]
        
fTraceEnds[4][2] = origin[2] - SIZE SIZE
        
new Float:fMinDistanceFloat:fDistance
        
for ( new i5i++ )
        {
            
fTraceHit[0] = fTraceEnds[i][0]
            
fTraceHit[1] = fTraceEnds[i][1]
            
fTraceHit[2] = -8192.0
    
            engfunc 
EngFunc_TraceLinefTraceEnds[i], fTraceHitIGNORE_MONSTERS0tr )
            
get_tr2 trTR_vecEndPosfTraceHit )
    
            
fDistance vector_distance fTraceEnds[i], fTraceHit )
    
            if ( 
fDistance fMinDistance || fMinDistance <= 0.0 )
            {
                
fMinDistance fDistance
                origin
[2] = fTraceHit[2]
            }
        }
    }
    
free_tr2 tr )

    new 
healthstring[16]
    
num_to_str(floatround(g_HEALTHS[0]), healthstring15)
    
DispatchKeyValue(entbase"health"healthstring)
    
DispatchKeyValue(entbase"material""6")

    
DispatchSpawn(entbase)
    
entity_set_string(entbaseEV_SZ_classname"sentrybase")
    
entity_set_model(entbase"models/dmsentries/base.mdl"// later set according to level
    
entity_set_edict(entbase,EV_ENT_owner,creator)
    
    new 
Float:mins[3], Float:maxs[3]
    
mins[0] = -16.0
    mins
[1] = -16.0
    mins
[2] = 0.0
    maxs
[0] = 16.0
    maxs
[1] = 16.0
    maxs
[2] = 1000.0 // Set to 16.0 later.
    
entity_set_size(entbaseminsmaxs)
    
entity_set_origin(entbaseorigin)
    
    
entity_set_int(entbaseEV_INT_solidSOLID_SLIDEBOX)
    
entity_set_int(entbaseEV_INT_movetypeiType MOVETYPE_FLY MOVETYPE_TOSS// head flies base falls
    
entity_set_int(entbaseBASE_INT_TEAM_:cs_get_user_team(creator))

    new 
parms[4]
    
parms[0] = entbase
    parms
[1] = creator
    parms
[2] = level
    parms
[3] = iType

    
if ( iType origin[2] += 16.0

    g_sentryOrigins
[creator 1] = origin

    emit_sound
(creatorCHAN_AUTO"dmsentries/building.wav"1.0ATTN_NORM0PITCH_NORM)

    
set_task(2.0"createsentryhead"0parms4)
    
g_inBuilding[creator] = true

    
return true
}

public 
createsentryhead(parms[4])
{
    new 
entbase parms[0]
    new 
level parms[2]
    new 
creator parms[1]
    new 
iType parms[3]

    if ( !
is_user_connected creator ) || !g_inBuilding[creator] )
    {
        if (
is_valid_ent(entbase))
            
remove_entity(entbase)

        return
    }

    if ( !
is_valid_team _:cs_get_user_team creator ) ) )
    {
        if (
is_valid_ent(entbase))
            
remove_entity(entbase)

        
sentries_num[creator]--
        return
    }

    new 
Float:origin[3]
    
origin g_sentryOrigins[creator 1]

    new 
ent create_entity("func_breakable")
    if (!
ent)
    {
        if (
is_valid_ent(entbase))
        {
            
remove_entity(entbase)
        }
        return
    }

    new 
Float:mins[3], Float:maxs[3]
    if (
is_valid_ent(entbase)) {
        
mins[0] = -16.0
        mins
[1] = -16.0
        mins
[2] = 0.0
        
        maxs
[0] = 16.0
        maxs
[1] = 16.0
        maxs
[2] = 16.0
        entity_set_size
(entbaseminsmaxs)

        
entity_set_edict(entSENTRY_ENT_BASEentbase)
        
entity_set_edict(entbaseBASE_ENT_SENTRYent)
    }

    
g_sentries[g_sentriesNum] = ent

    
new healthstring[16]
    
num_to_str(floatround(g_HEALTHS[0]), healthstring15)
    
DispatchKeyValue(ent"health"healthstring)
    
DispatchKeyValue(ent"material""6")

    
DispatchSpawn(ent)
    
entity_set_string(entEV_SZ_classname"sentry")
    switch(
_:cs_get_user_team(creator))
    {
        case 
1:
        {
            switch(
level)
            {
                case 
SENTRY_LEVEL_1entity_set_model(ent"models/dmsentries/sentry1_t.mdl")
                case 
SENTRY_LEVEL_2entity_set_model(ent"models/dmsentries/sentry2_t.mdl")
                case 
SENTRY_LEVEL_3entity_set_model(ent"models/dmsentries/sentry3_t.mdl")
            }
        }
        case 
2:
        {
            switch(
level)
            {
                case 
SENTRY_LEVEL_1entity_set_model(ent"models/dmsentries/sentry1_ct.mdl")
                case 
SENTRY_LEVEL_2entity_set_model(ent"models/dmsentries/sentry2_ct.mdl")
                case 
SENTRY_LEVEL_3entity_set_model(ent"models/dmsentries/sentry3_ct.mdl")
            }
        }
    }
    
    
    
mins[0] = -16.0
    mins
[1] = -16.0
    mins
[2] = 0.0
    maxs
[0] = 16.0
    maxs
[1] = 16.0
    maxs
[2] = 48.0
    entity_set_size
(entminsmaxs)
    
entity_set_origin(entorigin)
    
entity_get_vector(creatorEV_VEC_anglesorigin)
    
origin[0] = 0.0
    origin
[1] += 180.0
    entity_set_float
(entSENTRY_FL_ANGLEorigin[1])
    
origin[2] = 0.0
    entity_set_vector
(entEV_VEC_anglesorigin)
    
entity_set_int(entEV_INT_solidSOLID_SLIDEBOX// SOLID_SLIDEBOX
    
entity_set_int(entEV_INT_movetypeiType MOVETYPE_FLY MOVETYPE_TOSS// head flies, base doesn't

    
SetSentryPeople(entOWNERcreator)
    
    new 
CsTeams:crteam cs_get_user_team(creator)
    
SetSentryTeam entcrteam )
    
SetSentryLevel entlevel )

    
g_teamsentriesNum[_:crteam-1]++
    
    
emit_sound(entCHAN_AUTO"dmsentries/turrset.wav"1.0ATTN_NORM0PITCH_NORM)

    
IncreaseSentryCount(creatorent)

    new 
directions = (random_num(01)<<SENTRY_DIR_CANNON)
    
SetSentryPenddir entdirections )

    
g_inBuilding[creator] = false

    
if (!is_valid_ent(entbase))
        
SetSentryFiremode entSENTRY_FIREMODE_NUTS )

    
entity_set_float entSENTRY_FL_LASTTHINKget_gametime () + g_THINKFREQUENCIES[0] )
    
entity_set_float entEV_FL_nextthinkget_gametime () + 0.01 )

    
/*static bool:bHamRegistred

    if ( !bHamRegistred )
    {
        RegisterHamFromEntity ( Ham_Think, ent, "fw_ThinkSentry", 1 )
        bHamRegistred = true
    }*/
}

stock bool:CheckLocation ( const Float:origin[3] )
{
    if ( 
engfunc EngFunc_PointContentsorigin ) != CONTENTS_EMPTY )
        return 
false

    
new tr create_tr2 ()

    
engfunc EngFunc_TraceHulloriginorigin0HULL_HEAD/*HUMAN*/0tr )
    if ( !
get_tr2 trTR_InOpen ) || get_tr2 trTR_StartSolid ) || get_tr2 trTR_AllSolid ) )
    {
        
free_tr2 tr )
        return 
false
    
}

    
#define SIZE 16.0

    
new Float:fTraceEnds[9][3], Float:fTraceHit[3], iHitEnt
    fTraceEnds
[0][0] = origin[0]
    
fTraceEnds[0][1] = origin[1]
    
fTraceEnds[0][2] = origin[2] - SIZE SIZE
    fTraceEnds
[1][0] = origin[0] - SIZE
    fTraceEnds
[1][1] = origin[1] - SIZE
    fTraceEnds
[1][2] = origin[2] - SIZE SIZE
    fTraceEnds
[2][0] = origin[0] + SIZE
    fTraceEnds
[2][1] = origin[1] - SIZE
    fTraceEnds
[2][2] = origin[2] - SIZE SIZE
    fTraceEnds
[3][0] = origin[0] - SIZE
    fTraceEnds
[3][1] = origin[1] + SIZE
    fTraceEnds
[3][2] = origin[2] - SIZE SIZE
    fTraceEnds
[4][0] = origin[0] + SIZE
    fTraceEnds
[4][1] = origin[1] + SIZE
    fTraceEnds
[4][2] = origin[2] - SIZE SIZE
    fTraceEnds
[5][0] = origin[0] - SIZE
    fTraceEnds
[5][1] = origin[1] - SIZE
    fTraceEnds
[5][2] = origin[2] + SIZE SIZE
    fTraceEnds
[6][0] = origin[0] + SIZE
    fTraceEnds
[6][1] = origin[1] - SIZE
    fTraceEnds
[6][2] = origin[2] + SIZE SIZE
    fTraceEnds
[7][0] = origin[0] - SIZE
    fTraceEnds
[7][1] = origin[1] + SIZE
    fTraceEnds
[7][2] = origin[2] + SIZE SIZE
    fTraceEnds
[8][0] = origin[0] + SIZE
    fTraceEnds
[8][1] = origin[1] + SIZE
    fTraceEnds
[8][2] = origin[2] + SIZE SIZE

    
for (new 009i++)
    {
        if ( 
engfunc EngFunc_PointContentsfTraceEnds[i] ) != CONTENTS_EMPTY )
        {
            
free_tr2 tr )
            return 
false
        
}

        
engfunc EngFunc_TraceLineoriginfTraceEnds[i], 00tr )
        
iHitEnt get_tr2 trTR_pHit )

        if ( 
iHitEnt != -)
        {
            
free_tr2 tr )
            return 
false
        
}

        
get_tr2 trTR_vecEndPosfTraceHit )

        for ( 
03b++ )
        {
            if ( 
fTraceEnds[i][b] != fTraceHit[b] )
            {
                
free_tr2 tr )
                return 
false
            
}
        }
        if ( 
)
        {
            
fTraceHit[0] = fTraceEnds[i][0]
            
fTraceHit[1] = fTraceEnds[i][1]
            
fTraceHit[2] = -8192.0

            engfunc 
EngFunc_TraceLinefTraceEnds[i], fTraceHit00tr )
            
//get_tr2 ( tr, TR_vecEndPos, fTraceHit )
            
iHitEnt get_tr2 trTR_pHit )

            if ( 
pev_valid iHitEnt ) )
            {
                new 
sClassname[7]
                
pev iHitEntpev_classnamesClassnamecharsmax sClassname ) )
                if ( 
equal sClassname"sentry" ) )
                {
                    
free_tr2 tr )
                    return 
false
                
}
            }
        }
    }
    
free_tr2 tr )
    return 
true
}

bool:sentry_pendulum sentry )
{
    switch ( 
GetSentryFiremode sentry ) )
    {
        case 
SENTRY_FIREMODE_NO:
        {
            new 
Float:fAngles[3]
            
entity_get_vector sentryEV_VEC_anglesfAngles )
            new 
Float:fBaseAngle entity_get_float sentrySENTRY_FL_ANGLE )
            new 
iDirections GetSentryPenddir sentry )
            
            if ( 
iDirections & (1<<SENTRY_DIR_CANNON) )
            {
                
fAngles[1] -= ( PENDULUM_INCREMENT 0.01 )
                if ( 
fAngles[1] < fBaseAngle PENDULUM_MAX )
                {
                    
fAngles[1] = fBaseAngle PENDULUM_MAX
                    iDirections 
&= ~(1<<SENTRY_DIR_CANNON)
                    
SetSentryPenddir sentryiDirections )
                }
            }
            else 
            {
                
fAngles[1] += ( PENDULUM_INCREMENT 0.01 )
                if ( 
fAngles[1] > fBaseAngle PENDULUM_MAX 
                {
                    
fAngles[1] = fBaseAngle PENDULUM_MAX
                    iDirections 
|= (1<<SENTRY_DIR_CANNON)
                    
SetSentryPenddir sentryiDirections )
                }
            }

            
entity_set_vector sentryEV_VEC_anglesfAngles )
            return 
true
        
}
        case 
SENTRY_FIREMODE_NUTS:
        {
            new 
Float:fAngles[3]
            
entity_get_vector sentryEV_VEC_anglesfAngles )

            new 
Float:fSpinSpeed entity_get_float sentrySENTRY_FL_SPINSPEED )
            if ( 
GetSentryPenddir sentry ) & (1<<SENTRY_DIR_CANNON) )
            {
                
fAngles[1] -= ( fSpinSpeed 0.01 )
                if ( 
fAngles[1] < 0.0 )
                    
fAngles[1] = 360.0 fAngles[1]
            }
            else
            {
                
fAngles[1] += ( fSpinSpeed 0.01 )
                if ( 
fAngles[1] > 360.0 )
                    
fAngles[1] = fAngles[1] - 360.0
            
}
            
entity_set_float sentrySENTRY_FL_SPINSPEED, ( fSpinSpeed += random_float 1.02.0 ) ) )

            new 
Float:fMaxSpin entity_get_float sentrySENTRY_FL_MAXSPIN )
            if ( 
fMaxSpin == 0.0 )
            {
                
entity_set_float sentrySENTRY_FL_LASTTHINK0.5 )
                
entity_set_float sentrySENTRY_FL_MAXSPINfMaxSpin random_float 500.0750.0 ) )
            }
            else if ( 
fSpinSpeed >= fMaxSpin )
            {
                
sentry_detonate sentryfalsefalse )
                return 
false
            
}
            
entity_set_vector sentryEV_VEC_anglesfAngles )
            return 
true
        
}
    }
    return 
true
}

//#define    TE_TRACER            6        // tracer effect from point to point
tracer(Float:start[3], Float:end[3]) {
    new 
start_[3], end_[3]
    
FVecIVec(startstart_)
    
FVecIVec(endend_)
    
message_begin(MSG_BROADCASTSVC_TEMPENTITY//  MSG_PAS MSG_BROADCAST
    
write_byte(TE_TRACER)
    
write_coord(start_[0])
    
write_coord(start_[1])
    
write_coord(start_[2])
    
write_coord(end_[0])
    
write_coord(end_[1])
    
write_coord(end_[2])
    
message_end()
}
stock create_explosion(Float:origin_[3]) {
    new 
origin[3]
    
FVecIVec(origin_origin)

    
message_begin(MSG_BROADCASTSVC_TEMPENTITYorigin// MSG_PAS not really good here
    
write_byte(TE_EXPLOSION)
    
write_coord(origin[0])
    
write_coord(origin[1])
    
write_coord(origin[2])
    
write_short(g_sModelIndexFireball)
    
write_byte(random_num(020) + 50// scale * 10 // random_num(0, 20) + 20
    
write_byte(12// framerate
    
write_byte(TE_EXPLFLAG_NONE)
    
message_end()

    
KnockBack origin_ )

    new 
Float:playerOrigin[3], Float:distanceFloat:flDmgToDoFloat:dmgbase 90.0newHealth
    
for (new 1<= g_iMaxPlayersi++) {
        if (!
is_user_alive(i) || get_user_godmode(i))
            continue

        
entity_get_vector(iEV_VEC_originplayerOrigin)
        
distance vector_distance(playerOriginorigin_)
        if (
distance <= SENTRYEXPLODERADIUS) {
            
flDmgToDo dmgbase - (dmgbase * (distance SENTRYEXPLODERADIUS))
            
newHealth get_user_health(i) - floatround(flDmgToDo)
            if (
newHealth <= 0) {
                
set_task(0.0"TicketToHell"i)
                continue
            }

            
set_user_health(inewHealth)

            
message_begin(MSG_ONE_UNRELIABLEg_msgDamage, {0,0,0}, i)
            
write_byte(floatround(flDmgToDo))
            
write_byte(floatround(flDmgToDo))
            
write_long(DMG_BLAST)
            
write_coord(origin[0])
            
write_coord(origin[1])
            
write_coord(origin[2])
            
message_end()
        }
    }
}

public 
TicketToHell(player) {
    if (!
is_user_connected(player))
        return
    new 
frags get_user_frags(player)
    
user_kill(player1// don't decrease frags
    
new parms[4]
    
parms[0] = player
    parms
[1] = frags
    parms
[2] = cs_get_user_deaths(player)
    
parms[3] = int:cs_get_user_team(player)
    
set_task(0.0"DelayedScoreInfoUpdate"0parms4)
}

public 
DelayedScoreInfoUpdate(parms[4]) {
    
scoreinfo_update(parms[0], parms[1], parms[2], parms[3])
}

KnockBack Float:origin[3] )
{
    new 
iEntList[32]
    new 
iEntsFound find_sphere_class 0"player"SENTRYEXPLODERADIUSiEntListg_iMaxPlayersorigin )

    if ( !
iEntsFound )
        return

    new 
Float:fOriginEnt[3]
    new 
Float:fVelocity[3]
    new 
Float:fOriginEnd[3]
    new 
Float:fDistance
    
new iPlayer

    
for ( new iiEntsFoundi++ )
    {
        
iPlayer iEntList[i]

        if ( !
is_user_alive iPlayer ) )
            continue

        
entity_get_vector iPlayerEV_VEC_originfOriginEnt )

        
fDistance vector_distance fOriginEntorigin )

        if ( 
is_entity_on_ground iPlayer ) && fOriginEnt[2] < origin[2] )
            
fOriginEnt[2] = origin[2] + fDistance

        entity_get_vector 
iPlayerEV_VEC_velocityfVelocity )

        
fOriginEnd[0] = ( fOriginEnt[0] - origin[0] ) * SENTRYEXPLODERADIUS fDistance origin[0]
        
fOriginEnd[1] = ( fOriginEnt[1] - origin[1] ) * SENTRYEXPLODERADIUS fDistance origin[1]
        
fOriginEnd[2] = ( fOriginEnt[2] - origin[2] ) * SENTRYEXPLODERADIUS fDistance origin[2]

        
fVelocity[0] += ( fOriginEnd[0] - fOriginEnt[0] ) * SENTRYSHOCKPOWER
        fVelocity
[1] += ( fOriginEnd[1] - fOriginEnt[1] ) * SENTRYSHOCKPOWER
        fVelocity
[2] += ( fOriginEnd[2] - fOriginEnt[2] ) * SENTRYSHOCKPOWER

        entity_set_vector 
iPlayerEV_VEC_velocityfVelocity )
    }
}

public 
msg_TempEntity ()
{
    if ( 
get_msg_args () != 15 && get_msg_arg_int ) != TE_BREAKMODEL )
        return 
PLUGIN_CONTINUE

    
for ( new ig_sentriesNumi++ )
    {
        if ( 
entity_get_float g_sentries[i], EV_FL_health ) <= 0.0 )
        {
            
sentry_detonate ifalsetrue )
            
i--
        }
    }
    return 
PLUGIN_CONTINUE
}

public 
fw_ThinkSentry ent )
{
    if ( !
is_valid_ent ent ) )
        return

    static 
iOwneriOwner GetSentryPeople entOWNER )

    if ( !
is_user_connected iOwner ) )
        return

    if ( 
cs_get_user_team iOwner ) == CS_TEAM_SPECTATOR )
    {
        
sentry_detonate enttruefalse )
        return
    }
    
    if ( !
sentry_pendulum ent ) )
        return

    static 
Float:fGameTimefGameTime get_gametime ()
    if ( 
entity_get_float entSENTRY_FL_LASTTHINK ) <= fGameTime )
    {
        new 
Float:fOriginSentry[3], Float:fOriginHit[3], iHitEnt
        entity_get_vector 
entEV_VEC_originfOriginSentry )
        
fOriginSentry[2] += CANNONHEIGHTFROMFEET // Move up some, this should be the Y origin of the cannon
    
        
new firemode GetSentryFiremode ent )
        new 
target GetSentryPeople entTARGET )
        if ( 
firemode == SENTRY_FIREMODE_YES && is_valid_ent target ) && is_user_alive target ) && cs_get_user_team target ) != GetSentryTeam ent ) && !IsInSphere target ))
        {
            new 
sentryLevel GetSentryLevel ent )
    
            new 
Float:fOriginTarget[3]
            
entity_get_vector targetEV_VEC_originfOriginTarget )
    
            if ( 
entity_get_int targetEV_INT_flags ) & FL_DUCKING )
                
fOriginTarget[2] += TARGETUPMODIFIER
    
            iHitEnt 
trace_line entfOriginSentryfOriginTargetfOriginHit )
            if ( 
iHitEnt == entity_get_edict entSENTRY_ENT_BASE ) )
                
iHitEnt trace_line iHitEntfOriginHitfOriginTargetfOriginHit )
    
            if ( 
iHitEnt != target && is_user_alive iHitEnt ) && GetSentryTeam ent ) != cs_get_user_team iHitEnt ) && !IsInSphere iHitEnt ))
            {
                
target iHitEnt
                SetSentryPeople
(entTARGETiHitEnt)
            }
            if ( 
iHitEnt == target )
            {
                
SentryTurnToTarget entfOriginSentryfOriginTarget )
                
emit_sound entCHAN_WEAPON"dmsentries/fire.wav"1.0ATTN_NORM0PITCH_NORM )
    
                new 
Float:fHitRatio random_float 0.01.0 ) - g_HITRATIOS[sentryLevel// ie 0.5 - 0.7 = -0.2, a hit and 0.8 - 0.7 = a miss by 0.1
    
                
if(GetSentryLevel(ent) == SENTRY_LEVEL_4){
                    if(
get_gametime() > entity_get_float(ent,SENTRY_ROCKET_TIME)){
                        if(
entity_range(ent,target) >= RPG_DISTANCE){
                            new 
data[2]
                            
data[0] = ent
                            
                            ShootRockets
(data)
                        }
                        
                        
entity_set_float(ent,SENTRY_ROCKET_TIME,get_gametime() +  2.0)
                    }
                }
    
                if ( !
get_user_godmode target ) && fHitRatio <= 0.0 )
                    
sentry_damagetoplayer entsentryLevelfOriginSentrytarget )
                else
                {
                    new 
Float:fSentryAngle[3] = {0.00.00.0}
    
                    new 
Float:fOriginHit[0] - fOriginSentry[0]
                    new 
Float:fOriginHit[1] - fOriginSentry[1]
                    new 
Float:radians floatatan z/xradian )
                    
fSentryAngle[1] = radians g_ONEEIGHTYTHROUGHPI
                    
if ( fOriginHit[0] < fOriginSentry[0] )
                        
fSentryAngle[1] -= 180.0
    
                    
new Float:fOriginHit[2] - fOriginSentry[2]
                    new 
Float:vector_distance fOriginSentryfOriginHit )
                    
radians floatatan h/bradian )
                    
fSentryAngle[0] = radians g_ONEEIGHTYTHROUGHPI
    
                    fSentryAngle
[0] += random_float ( -10.0 fHitRatio10.0 fHitRatio // aim is a little off here :-)
                    
fSentryAngle[1] += random_float ( -10.0 fHitRatio10.0 fHitRatio // aim is a little off here :-)
                    
engfunc EngFunc_MakeVectorsfSentryAngle )
                    new 
Float:vector[3]
                    
get_global_vector GL_v_forwardvector )
                    for ( new 
03i++ )
                        
vector[i] *= 1000
    
                    
new Float:traceEnd[3]
                    for ( new 
03i++ )
                        
traceEnd[i] = vector[i] + fOriginSentry[i]
    
                    new 
iHitEnt2 ent
                    
static lolcheck 0
                    
while ( ( iHitEnt2 trace_line iHitEnt2fOriginHittraceEndfOriginHit ) ) )
                        if ( 
lolcheck++ > 700 ) break
    
                }
                
tracer fOriginSentryfOriginHit )

                
entity_set_float entSENTRY_FL_LASTTHINKfGameTime 0.1 )
                
entity_set_float entEV_FL_nextthinkfGameTime 0.01 )
                return
            }
            else
                
SetSentryFiremode entSENTRY_FIREMODE_NO )
        }
        else if ( 
firemode == SENTRY_FIREMODE_NUTS )
        {
            new 
iHitEnt2 EntViewHitPoint entfOriginSentryfOriginHit )
            
emit_sound(entCHAN_WEAPON"dmsentries/fire.wav"1.0ATTN_NORM0PITCH_NORM)
            
tracer(fOriginSentryfOriginHit)
    
            if (
is_user_connected(iHitEnt2) && is_user_alive(iHitEnt2) && !get_user_godmode(iHitEnt2))
            {
                
sentry_damagetoplayer(entGetSentryLevel ent ), fOriginSentryiHitEnt2)
            }
            
entity_set_float entSENTRY_FL_LASTTHINKfGameTime 0.1 )
            
entity_set_float entEV_FL_nextthinkfGameTime 0.01 )
            return
        }
    
        if ( 
random_num 099 ) < 10 )
            
emit_sound entCHAN_AUTO"dmsentries/turridle.wav"1.0ATTN_NORM0PITCH_NORM )

        new 
closestTarget 0Float:closestDistanceFloat:distanceFloat:closestOrigin[3], Float:playerOrigin[3], CsTeams:sentryTeam GetSentryTeam ent )
        for ( new 
1<= g_iMaxPlayersi++ )
        {
            if ( !
is_user_connected ) || !is_user_alive ) || cs_get_user_team ) == sentryTeam || IsInSphere ) )
                continue
    
            
entity_get_vector iEV_VEC_originplayerOrigin )
    
            if ( 
entity_get_int iEV_INT_flags ) & FL_DUCKING )
                
playerOrigin[2] += TARGETUPMODIFIER
    
            iHitEnt 
trace_line entfOriginSentryplayerOriginfOriginHit )
            if ( 
iHitEnt == entity_get_edict entSENTRY_ENT_BASE ) )
                
iHitEnt trace_line(iHitEntfOriginHitplayerOriginfOriginHit)
    
            if ( 
iHitEnt == )
            {
                
distance vector_distance fOriginSentryplayerOrigin )
                
closestOrigin playerOrigin
    
                
if ( distance closestDistance || closestTarget == )
                {
                    
closestTarget i
                    closestDistance 
distance
                
}
            }
        }
    
        if ( 
closestTarget )
        {
            
emit_sound entCHAN_AUTO"dmsentries/turrspot.wav"1.0ATTN_NORM0PITCH_NORM )
            
SentryTurnToTarget entfOriginSentryclosestOrigin )
    
            
SetSentryFiremode entSENTRY_FIREMODE_YES )
            
SetSentryPeople entTARGETclosestTarget )
        }
        else
            
SetSentryFiremode entSENTRY_FIREMODE_NO )

        
entity_set_float entSENTRY_FL_LASTTHINKfGameTime g_THINKFREQUENCIES[GetSentryLevel ent )] )
    }
    
entity_set_float entEV_FL_nextthinkfGameTime 0.01 )
}

public 
think_sentrybase(sentrybase) {
    
sentrybase_broke(sentrybase)
    return 
PLUGIN_CONTINUE
}

sentrybase_broke(sentrybase) {
    new 
sentry entity_get_edict(sentrybaseBASE_ENT_SENTRY)
    if (
is_valid_ent(sentrybase))
        
remove_entity(sentrybase)

    if (
sentry == 0)
        return

    
SetSentryFiremode sentrySENTRY_FIREMODE_NUTS )
}

sentry_detonate(sentrybool:quietbool:isIndex) {
    new 
i
    
if (isIndex)
    {
        
sentry
        sentry 
g_sentries[sentry]
        if (!
is_valid_ent(sentry))
            return
    }
    else
    {
        if (!
is_valid_ent(sentry))
            return

        for (new 
0g_sentriesNumj++) {
            if (
g_sentries[j] == sentry) {
                
j
                
break
            }
        }
    }
    
entity_set_float sentryEV_FL_nextthink0.0 )

    new 
owner GetSentryPeople(sentryOWNER)

    if (!
quiet) {
        new 
Float:origin[3]
        
entity_get_vector(sentryEV_VEC_originorigin)
        
create_explosion(origin)
        
ChatColor owner"^3[^4Действие^3]^1 Твоя пушка взорвана!")
        
ammo_hud(owner0)
        
sentries_num[owner] -= 1
        ammo_hud
(owner1)        
    }
    
DecreaseSentryCount(ownersentry)

    
// Remove base first
    
if (GetSentryFiremode sentry ) != SENTRY_FIREMODE_NUTS)
        
set_task 0.1"DelayRemoveEntity"entity_get_edict sentrySENTRY_ENT_BASE ) )
        
//remove_entity(entity_get_edict(sentry, SENTRY_ENT_BASE))

    
new CsTeams:iSentryTeam GetSentryTeam sentry )

    
set_task 0.1"DelayRemoveEntity"sentry )
    
//remove_entity(sentry)
    // Put the last sentry in the deleted entity's place
    
if(> (g_sentriesNum 1) > MAXSENTRIES) return
    
g_sentries[i] = g_sentries[g_sentriesNum 1]
    
    
g_teamsentriesNum[_:iSentryTeam-1]--
}

public 
DelayRemoveEntity ent )
{
    if ( 
pev_valid ent ) )
        
remove_entity ent )
}

sentry_detonate_by_owner(ownerbool:quiet false) {
    for(new 
0g_sentriesNumi++) {
        if (
GetSentryPeople(g_sentries[i], OWNER) == owner) {
            
sentry_detonate(iquiettrue)
            break
        }
    }
}

public 
client_disconnect(id) {
    while (
GetSentryCount(id) > 0)
        
sentry_detonate_by_owner(id)
}

// урон игроку
stock sentry_damagetoplayer(sentrysentryLevelFloat:sentryOrigin[3], target) {
    new 
newHealth get_user_health(target) - g_DMG[sentryLevel]

    if (
newHealth <= 0) {
        new 
targetFrags get_user_frags(target) + 1
        
new owner GetSentryPeople(sentryOWNER)
        
        if(!
is_user_connected(owner))
            return
        
        new 
ownerFrags get_user_frags(owner) + 1
        set_user_frags
(targettargetFrags// otherwise frags are subtracted from victim for dying (!!)
        
set_user_frags(ownerownerFrags)
        
        new 
contributors[4]
        
contributors[0] = owner
        contributors
[1] = GetSentryPeople(sentryUPGRADER_1)
        
contributors[2] = GetSentryPeople(sentryUPGRADER_2)
        
contributors[3] = GetSentryPeople(sentryUPGRADER_3)
        
        for(new 
sizeof contributors i++){
            if(!
contributors[i])
                continue
                
            if(!
is_user_connected(contributors[i]) || get_user_team(contributors[i]) != get_user_team(contributors[0])){
                switch(
i){ // yao face
                    
case 1SetSentryPeople(sentry,UPGRADER_1,0)
                    case 
2SetSentryPeople(sentry,UPGRADER_2,0)
                    case 
3SetSentryPeople(sentry,UPGRADER_3,0)
                }
                
                continue
            }
            
            
// izvini 4yvak, no menya nakrilo
            
cs_set_user_money(contributors[i],
                
clamp(
                    
cs_get_user_money(contributors[i]) + (== SENTRYOWNERAWARD SENTRYASSISTAWARD),
                    
0,
                    
16000
                
)
            )
        }

        
// ny ebatb kakoy frag
        
message_begin(MSG_ALLg_msgDeathMsg, {000} ,0)
        
write_byte(owner)
        
write_byte(target)
        
write_byte(0)
        
write_string("sentry gun")
        
message_end()

        
scoreinfo_update(ownerownerFragscs_get_user_deaths(owner), int:cs_get_user_team(owner))
        
set_msg_block(g_msgDeathMsgBLOCK_ONCE)
    }

    
set_user_health(targetnewHealth)

    
message_begin(MSG_ONE_UNRELIABLEg_msgDamage, {0,0,0}, target)
    
write_byte(g_DMG[sentryLevel])
    
write_byte(g_DMG[sentryLevel])
    
write_long(DMG_BULLET)
    
write_coord(floatround(sentryOrigin[0]))
    
write_coord(floatround(sentryOrigin[1]))
    
write_coord(floatround(sentryOrigin[2]))
    
message_end()
}

scoreinfo_update(idfragsdeathsteam) {
    
message_begin(MSG_ALLg_msgScoreInfo)
    
write_byte(id)
    
write_short(frags)
    
write_short(deaths)
    
write_short(0)
    
write_short(team)
    
message_end()
}

SentryTurnToTarget entFloat:sentry_origin[3], Float:closest_origin[3] )
{
    new 
Float:fAngle[3]
    
entity_get_vector entEV_VEC_anglesfAngle )
    new 
Float:closest_origin[0] - sentry_origin[0]
    new 
Float:closest_origin[1] - sentry_origin[1]

    new 
Float:fRadians floatatan z/xradian )
    
fAngle[1] = fRadians g_ONEEIGHTYTHROUGHPI
    
if ( closest_origin[0] < sentry_origin[0] )
        
fAngle[1] -= 180.0

    entity_set_float 
entSENTRY_FL_ANGLEfAngle[1] )
    
entity_set_vector entEV_VEC_anglesfAngle )
}

AimingAtSentry id )
{
    if ( !
is_user_alive id ) )
        return 
0

    
new hitEntbodyPart
    
if (get_user_aiming(idhitEntbodyPart) == 0.0)
        return 
0

    
if ( is_valid_ent hitEnt ) )
    {
        new 
classname[32], l_sentry
        entity_get_string
(hitEntEV_SZ_classnameclassname31)
        if (
equal(classname"sentry_base"))
            
l_sentry entity_get_edict(hitEntBASE_ENT_SENTRY)
        else if (
equal(classname"sentry"))
            
l_sentry hitEnt
        
else
            
l_sentry 0

        
return l_sentry
    
}
    return 
0
}

// улучшение уровня пушки
bool:SentryUpgrade idsentry )
{
    
    if ( 
GetSentryFiremode sentry ) == SENTRY_FIREMODE_NUTS )
        return 
false
    
    
new iLevel GetSentryLevel sentry )

    if ( 
iLevel == SENTRY_LEVEL_4 )
        return 
false
    
    
if ( GetSentryPeople sentryOWNER ) == id )
        return 
false
    
    
if ( cs_get_user_team id ) != GetSentryTeam sentry ) )
    {
        return 
false
    
}

    if ( 
cs_get_user_team GetSentryPeople sentryOWNER ) ) == CS_TEAM_SPECTATOR )
        return 
false
        
    
// e ron don don
    
if(GetSentryPeople(sentry,UPGRADER_1) == id ||
        
GetSentryPeople(sentry,UPGRADER_2) == id ||
        
GetSentryPeople(sentry,UPGRADER_3) == id
    
)
        return 
false
    
    iLevel
++

    if ( 
cs_get_user_money id ) - g_COST[iLevel] < )
    {
        
ChatColor id"^3[^4Информация^3]^1 У тебя не хватает денег (нужно %d$)"g_COST[iLevel] )
        return 
false
    
}

    
cs_set_user_money idcs_get_user_money id ) - g_COST[iLevel] )

    new 
iTeam _:cs_get_user_team id ), iUpgraderField
    
switch ( iLevel )
    {
        
// this kod is very zaebisb
        
case SENTRY_LEVEL_2:
        {
            switch ( 
iTeam )
            {
                case 
1:entity_set_model sentry"models/dmsentries/sentry2_t.mdl" )
                case 
2:entity_set_model sentry"models/dmsentries/sentry2_ct.mdl" )
            }
            
iUpgraderField UPGRADER_1
        
}
        case 
SENTRY_LEVEL_3:
        {
            switch ( 
iTeam )
            {
                case 
1:entity_set_model sentry"models/dmsentries/sentry3_t.mdl" )
                case 
2:entity_set_model sentry"models/dmsentries/sentry3_ct.mdl" )
            }
            
iUpgraderField UPGRADER_2
        
}
        case 
SENTRY_LEVEL_4:{
            switch(
iTeam){
                case 
1:entity_set_model sentry"models/dmsentries/sentry3_t.mdl" )
                case 
2:entity_set_model sentry"models/dmsentries/sentry3_ct.mdl" )
            }
            
            
entity_set_byte(sentry,EV_BYTE_controller2,120)
            
entity_set_byte(sentry,EV_BYTE_controller3,120)
            
            
iUpgraderField UPGRADER_3
        
}
    }

    new 
Float:fMins[3], Float:fMaxs[3]
    
fMins[0] = -16.0
    fMins
[1] = -16.0
    fMins
[2] = 0.0
    fMaxs
[0] = 16.0
    fMaxs
[1] = 16.0
    fMaxs
[2] = 48.0 // 4.0
    
entity_set_size sentryfMinsfMaxs )
    
emit_sound sentryCHAN_AUTO"dmsentries/turrset.wav"1.0ATTN_NORM0PITCH_NORM )
    
SetSentryLevel sentryiLevel )
    
entity_set_float sentryEV_FL_healthg_HEALTHS[iLevel] )
    
entity_set_float entity_get_edict sentrySENTRY_ENT_BASE ), EV_FL_healthg_HEALTHS[0] )
    
SetSentryPeople sentryiUpgraderFieldid )
    
    new 
sName[32]
    
get_user_name idsNamecharsmax sName ) )
    
client_print GetSentryPeople sentryOWNER ), print_center"%s прокачал твою пушку до уровня %d"sNameiLevel )
    return 
true
}

stock EntViewHitPoint indexFloat:origin[3], Float:hitorigin[3] )
{
    if ( !
is_valid_ent index ) )
        return 
0

    
new Float:angle[3], Float:vec[3], Float:f_dest[3]

    
entity_get_vector(indexEV_VEC_anglesangle)

    
engfunc(EngFunc_AngleVectorsanglevec00)

    
f_dest[0] = origin[0] + vec[0] * 9999
    f_dest
[1] = origin[1] + vec[1] * 9999
    f_dest
[2] = origin[2] + vec[2] * 9999

    
return trace_line(indexoriginf_desthitorigin)
}

public 
fw_PlayerSpawn_Post id )
{
    if ( !
is_user_alive id ) )
        return

    
g_inBuilding[id] = false

    
while ( GetSentryCount id ) > )
        
sentry_detonate_by_owner idtrue )

    
ammo_hud id)
    
sentries_num[id] = 0
}

public 
fw_TraceLine_Post Float:start[3], Float:end[3], noMonstersid )
{
    if ( !
is_valid_player id ) || !is_user_alive id ) )
        return 
FMRES_IGNORED

    
new iHitEnt get_tr TR_pHit )

    if ( 
iHitEnt <= g_iMaxPlayers )
        return 
FMRES_IGNORED

    
new sClassName[11], sentrybase

    pev 
iHitEntpev_classnamesClassNamecharsmax sClassName ) )

    if ( 
equal sClassName"sentrybase" ) )
    {
        
base iHitEnt
        sentry 
entity_get_edict iHitEntBASE_ENT_SENTRY )
    }
    else if ( 
equal sClassName"sentry" ) )
    {
        
sentry iHitEnt
        base 
entity_get_edict sentrySENTRY_ENT_BASE )
    }

    if ( !
pev_valid sentry ) || !base )
        return 
FMRES_IGNORED
        
    
if ( GetSentryFiremode sentry ) == SENTRY_FIREMODE_NUTS )
             return 
FMRES_IGNORED
         
    
new Float:health entity_get_float sentryEV_FL_health )

    if ( 
health <= )
        return 
FMRES_IGNORED

    
new Float:basehealth entity_get_float baseEV_FL_health )

    if ( 
basehealth <= )
        return 
FMRES_IGNORED

    
new CsTeams:team GetSentryTeam sentry )

    if ( 
team != cs_get_user_team id ) )
        return 
FMRES_IGNORED

    
new level GetSentryLevel sentry )

    static 
tempStatusBuffer[192], tempStatusBuffer2[192]

    new 
OwnName[33]
    
get_user_name GetSentryPeople sentryOWNER ), OwnName32 )
    
    
formatex tempStatusBuffercharsmax tempStatusBuffer ), "Установил: %s^nЗдоровье: %d/%d"OwnNamefloatround(health), floatround(g_HEALTHS[level]) )
    
formatex tempStatusBuffer2charsmax tempStatusBuffer2 ), "^n^nЗдоровье основания: %d/%d^nУровень: %d"floatround(basehealth), floatround(g_HEALTHS[0]), level )

    
set_dhudmessage _:team == 150 00_:team == 150 0, -1.00.3500.00.60.00.0 )
    
show_dhudmessage(idtempStatusBuffer)
    
show_dhudmessage(idtempStatusBuffer2)

    return 
FMRES_IGNORED
}

// прикосновение к пушке игрока
public fw_TouchSentry sentryplayer ) { SentryUpgrade playersentry ); }

ammo_hud(idsw)
{
    if(
is_user_bot(id)||!is_user_alive(id)||!is_user_connected(id)) 
            return

    new 
s_sprite[33]
    
format(s_sprite32"number_%d"sentries_num[id])
    if(
sw)
    {
        
message_beginMSG_ONEgMsgID, {0,0,0}, id )
        
write_byte// status
        
write_strings_sprite // sprite name
        
write_byte250 // red
        
write_byte250 // green
        
write_byte250 // blue
        
message_end()
    }
    else 
    {
        
message_beginMSG_ONEgMsgID, {0,0,0}, id )
        
write_byte// status
        
write_strings_sprite // sprite name
        
write_byte250 // red
        
write_byte250 // green
        
write_byte250 // blue
        
message_end()
    }
    if(
sentries_num[id] <= 0)
    {
        
message_beginMSG_ONEgMsgID, {0,0,0}, id )
        
write_byte// status
        
write_strings_sprite // sprite name
        
write_byte250 // red
        
write_byte250 // green
        
write_byte250 // blue
        
message_end()
    }    
}

stock ChatColor(const id, const input[], any:...)
{
        new 
count 1players[32]
        static 
msg[191]
        
vformat(msg190input3)
       
        
replace_all(msg190"!g""^4"// Green Color
        
replace_all(msg190"!y""^1"// Default Color
        
replace_all(msg190"!team""^3"// Team Color
        
replace_all(msg190"!team2""^0"// Team2 Color
       
        
if (idplayers[0] = id; else get_players(playerscount"ch")
        {
                for (new 
0counti++)
                {
                        if (
is_user_connected(players[i]))
                        {
                                
message_begin(MSG_ONE_UNRELIABLEget_user_msgid("SayText"), _players[i])
                                
write_byte(players[i]);
                                
write_string(msg);
                                
message_end();
                        }
                }
        }
}

bool:IsInSphere id )
{
    if ( !
is_user_alive id ) )
        return 
false

    
new ent = -
    
while ( ( ent engfunc EngFunc_FindEntityByStringent"classname""campo_grenade_forze" ) ) > )
    {
        new 
iOwner pev entpev_owner )

        if ( 
cs_get_user_team id ) != cs_get_user_team iOwner ) )
            continue

        new 
Float:fOrigin[3]
        
pev entpev_originfOrigin )
        new 
iPlayer = -1
        
while ( ( iPlayer engfunc EngFunc_FindEntityInSphereiPlayerfOrigin68.0 ) ) != )
        {
            if ( 
iPlayer == id )
                return 
true
        
}
    }
    return 
false
}

//
// Launch rocket from 4lvl sentry
//    data[2]
//        0 - sentry id
//        1 - side    // 0 - right, 1 - left
//
public ShootRockets(data[2]){
    new 
sentry data[0]
    new 
side data[1]
    
    new 
Float:rocketOrigin[3],Float:rocketAngles[3]
    
    
entity_get_vector(sentry,EV_VEC_angles,rocketAngles)
    
engfunc(EngFunc_MakeVectors,rocketAngles)
    
    new 
Float:vecForward[3],Float:vecRight[3],Float:vecUp[3]
    
    
get_global_vector(GL_v_forward,vecForward)
    
xs_vec_mul_scalar(vecForward,20.0,vecForward)
    
    
get_global_vector(GL_v_right,vecRight)
    
xs_vec_mul_scalar(vecRight,side 8.0 : -8.0,vecRight// right or left rocket
    
    
get_global_vector(GL_v_up,vecUp)
    
xs_vec_mul_scalar(vecUp,30.0,vecUp)
    
    
entity_get_vector(sentry,EV_VEC_origin,rocketOrigin)
    
xs_vec_add(rocketOrigin,vecForward,rocketOrigin)
    
xs_vec_add(rocketOrigin,vecRight,rocketOrigin)
    
xs_vec_add(rocketOrigin,vecUp,rocketOrigin)
    
    
// shot rocket
    
CreateRocket(sentry,rocketOrigin,rocketAngles,GetSentryPeople(sentry,TARGET))
    
    
data[1] = 1
    
    
if(!side// shot left rocket
        
set_task(0.2,"ShootRockets",_,data,sizeof data)
}

//
// Launch RPG rocket
//    sentry - sentry id
//    origin - rocket origin
//    angles - sentry angles
//    traget - rocket target id
//
CreateRocket(sentry,Float:origin[3],Float:angles[3],target){
    new 
rocket create_entity("info_target")
    
    
entity_set_string(rocket,EV_SZ_classname,"rpg_rocket")
    
    
entity_set_int(rocket,EV_INT_movetype,MOVETYPE_FLY)
    
entity_set_int(rocket,EV_INT_solid,SOLID_BBOX)
    
    
entity_set_edict(rocket,EV_ENT_owner,sentry)
    
entity_set_edict(rocket,EV_ENT_euser4,GetSentryPeople(sentry,OWNER))
    
    
entity_set_size(rocket,Float:{-2.0,-2.0,-2.0},Float:{2.0,2.0,2.0})
    
entity_set_origin(rocket,origin)
    
    new 
Float:targetOrigin[3]
    
entity_get_vector(target,EV_VEC_origin,targetOrigin)
    
angles[0] = -GetAngleOrigins(origin,targetOrigin)
    
entity_set_model(rocket,"models/rpgrocket.mdl")
    
entity_set_vector(rocket,EV_VEC_angles,angles)
    
    
engfunc(EngFunc_MakeVectors,angles)
    
    new 
Float:vecVelocity[3]
    
get_global_vector(GL_v_forward,vecVelocity)
    
xs_vec_mul_scalar(vecVelocity,1000.0,vecVelocity)
    
entity_set_vector(rocket,EV_VEC_velocity,vecVelocity)
    
    
entity_set_int(rocket,EV_INT_effects,entity_get_int(rocket,EV_INT_effects) | EF_LIGHT)
    
    
// rocket trail
    
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
    
write_byte(TE_BEAMFOLLOW)
    
write_short(rocket)
    
write_short(m_iTrail)
    
write_byte(10)
    
write_byte(5)
    
write_byte(224)
    
write_byte(224)
    
write_byte(255)
    
write_byte(255)
    
message_end()
    
    
emit_sound(rocket,CHAN_VOICE,"weapons/rocket1.wav",1.0,0.5,0,PITCH_NORM)
}

public 
fw_RpgTouch(rocket,ent){
    new 
Float:origin[3],Float:angles[3],Float:vecPlaneNormal[3]
    
entity_get_vector(rocket,EV_VEC_origin,origin)
    
entity_get_vector(rocket,EV_VEC_angles,angles)
    
    
engfunc(EngFunc_MakeVectors,angles)
    
get_global_vector(GL_v_forward,angles)
    
xs_vec_mul_scalar(angles,9999.0,angles)
    
xs_vec_add(origin,angles,angles)
    
engfunc(EngFunc_TraceLine,origin,angles,0,rocket,0)
    
    
get_tr2(0,TR_vecEndPos,origin)
    
    
message_begin_f(MSG_BROADCAST,SVC_TEMPENTITY,origin,0)
    
write_byte(TE_WORLDDECAL)
    
write_coord_f(origin[0])
    
write_coord_f(origin[1])
    
write_coord_f(origin[2])
    
write_byte(expDecal)
    
message_end()
    
    
get_tr2(0,TR_vecPlaneNormal,vecPlaneNormal)
    
    
xs_vec_mul_scalar(vecPlaneNormal,8.0,vecPlaneNormal)
    
xs_vec_add(origin,vecPlaneNormal,origin)
    
    
message_begin_f(MSG_PVS,SVC_TEMPENTITY,origin,0)
    
write_byte(TE_EXPLOSION)
    
write_coord_f(origin[0])
    
write_coord_f(origin[1])
    
write_coord_f(origin[2])
    
write_short(g_sModelIndexFireball)
    
write_byte(20)
    
write_byte(15)
    
write_byte(0)
    
message_end()
    
    
shit_radiusdamage(rocket,origin)
    
    
emit_sound(rocket,CHAN_VOICE,"weapons/rocket1.wav",0.0,ATTN_NORM,SND_STOP,0)
    
    
remove_entity(rocket)
}

// this very bad method
stock shit_radiusdamage(rocket,Float:origin_[3]) {
    new 
origin[3]
    
FVecIVec(origin_origin)
    
    new 
attacker entity_get_edict(rocket,EV_ENT_euser4)
    
    if(!
is_user_connected(attacker))
        return


    new 
Float:playerOrigin[3], Float:distanceFloat:flDmgToDoFloat:dmgbase RPG_DAMAGE
    
for (new 1<= g_iMaxPlayersi++) {
        if (!
is_user_alive(i) || get_user_godmode(i) || get_user_team(i) == get_user_team(attacker)) 
            continue

        
entity_get_vector(iEV_VEC_originplayerOrigin)
        
distance vector_distance(playerOriginorigin_)
        if (
distance <= RPG_RADIUS) {
            
flDmgToDo dmgbase - (dmgbase * (distance RPG_RADIUS))
            
            
// zemletryasenie!!111
            
Util_ScreenShake(i,0.5,16.0,16.0)
            
rocket_damagetoplayer(rocket,origin_,i,flDmgToDo)
        }
    }
}
// ScreenShake
stock Util_ScreenShake(idFloat:durationFloat:frequencyFloat:amplitude)
{
    static 
ScreenShake 0;
    if( !
ScreenShake )
    {
        
ScreenShake get_user_msgid("ScreenShake");
    }
    
message_beginid MSG_ONE_UNRELIABLE MSG_BROADCASTScreenShake_id);
    
write_shortFixedUnsigned16amplitude1<<12 ) ); // shake amount
    
write_shortFixedUnsigned16duration1<<12 ) ); // shake lasts this long
    
write_shortFixedUnsigned16frequency1<<) ); // shake noise frequency
    
message_end();
}

// урон игроку
stock rocket_damagetoplayer(rocketFloat:sentryOrigin[3], targetFloat:dmg) {
    new 
sentry entity_get_edict(rocket,EV_ENT_owner)
    new 
sentryLevel GetSentryLevel(sentry)
    
    new 
newHealth get_user_health(target) - floatround(dmg)

    if (
newHealth <= 0) {
        new 
targetFrags get_user_frags(target) + 1
        
new owner GetSentryPeople(sentryOWNER)
        
        if(!
is_user_connected(owner))
            return
        
        new 
ownerFrags get_user_frags(owner) + 1
        set_user_frags
(targettargetFrags// otherwise frags are subtracted from victim for dying (!!)
        
set_user_frags(ownerownerFrags)
        
        new 
contributors[4]
        
contributors[0] = owner
        contributors
[1] = GetSentryPeople(sentryUPGRADER_1)
        
contributors[2] = GetSentryPeople(sentryUPGRADER_2)
        
contributors[3] = GetSentryPeople(sentryUPGRADER_3)
        
        for(new 
sizeof contributors i++){
            if(!
contributors[i])
                continue
                
            if(!
is_user_connected(contributors[i]) || get_user_team(contributors[i]) != get_user_team(contributors[0])){
                switch(
i){ // yao face
                    
case 1SetSentryPeople(sentry,UPGRADER_1,0)
                    case 
2SetSentryPeople(sentry,UPGRADER_2,0)
                    case 
3SetSentryPeople(sentry,UPGRADER_3,0)
                }
                
                continue
            }
            
            
// izvini 4yvak, no menya nakrilo
            
cs_set_user_money(contributors[i],
                
clamp(
                    
cs_get_user_money(contributors[i]) + (== SENTRYOWNERAWARD SENTRYASSISTAWARD),
                    
0,
                    
16000
                
)
            )
        }

        
// ny ebatb kakoy frag
        
message_begin(MSG_ALLg_msgDeathMsg, {000} ,0)
        
write_byte(owner)
        
write_byte(target)
        
write_byte(0)
        
write_string("sentry gun")
        
message_end()

        
scoreinfo_update(ownerownerFragscs_get_user_deaths(owner), int:cs_get_user_team(owner))
        
set_msg_block(g_msgDeathMsgBLOCK_ONCE)
    }

    
set_user_health(targetnewHealth)

    
message_begin(MSG_ONE_UNRELIABLEg_msgDamage, {0,0,0}, target)
    
write_byte(g_DMG[sentryLevel])
    
write_byte(g_DMG[sentryLevel])
    
write_long(DMG_BLAST)
    
write_coord(floatround(sentryOrigin[0]))
    
write_coord(floatround(sentryOrigin[1]))
    
write_coord(floatround(sentryOrigin[2]))
    
message_end()
}

stock FixedUnsigned16Float:valuescale )
{
    new 
output;

    
output floatround(value scale);
    if ( 
output )
        
output 0;
    if ( 
output 0xFFFF )
        
output 0xFFFF;

    return 
output;
}

FloatGetAngleOrigins(Float:fOrigin1[3], Float:fOrigin2[3] )
{
    new 
Float:fVector[3];
    new 
Float:fAngle[3];
    new 
Float:fLineAngle;
    
    
xs_vec_sub(fOrigin2fOrigin1fVector);
    
vector_to_angle(fVectorfAngle);
    
    if( 
fAngle[0] > 90.0 )
        
fLineAngle = -(360.0 fAngle[0]);
    else
        
fLineAngle fAngle[0]; 

Неинформативное название, неверный раздел. Закрыто // Subb98
Аватара пользователя
Phubaxz
 
Сообщения: 14
Зарегистрирован: 07 дек 2016, 11:14
Предупреждения: 5
Благодарил (а): 6 раз.
Поблагодарили: 1 раз.
Языки программирования: Pawn
SourcePawn
C++
Php
Ruby
Python
C#

Скачал скрипт он не работает Помогите Плиз

Сообщение Phubaxz » 07 дек 2016, 11:34

Код: Выделить всё
#include <amxmodx>
#include <engine>
#include <fun>
#include <cstrike>
#include <fakemeta>
#include <hamsandwich>
#include <xs>

#if AMXX_VERSION_NUM < 183
    #define message_begin_f(%0,%1,%2,%3)    engfunc(EngFunc_MessageBegin,%0,%1,%2,%3)
    #define write_coord_f(%0)        engfunc(EngFunc_WriteCoord,%0)
    
    #include <dhudmessage>
#endif


native sh_set_hero id )
native give_shield_grenade id )


#define is_valid_player(%1) ( 1 <= %1 <= g_iMaxPlayers )
#define is_valid_team(%1) ( 0 < %1 < 3 )

#define is_entity_on_ground(%1) ( entity_get_int ( %1, EV_INT_flags ) & FL_ONGROUND )

// сколько пушек у игрока уже построено
#define GetSentryCount(%1) g_iPlayerSentries[%1]

#define MAXUPGRADERANGE        75.0
#define SENTRYEXPLODERADIUS        250.0            // радиус отброса при взрыве
#define SENTRYTILTRADIUS            830.0            // likely you won't need to touch this. it's how accurate the cannon will aim at the target vertically (up/down, just for looks, aim is calculated differently)

#define SENTRYMINDISTANCE    256.0

#define MAXSENTRIES                32 * 3

#define TASK_GODMODE 114455

#define SENTRY_INT_PEOPLE        EV_INT_iuser2 // max 5 users using 6 bits!
#define SENTRY_INT_UGPRADERS        EV_INT_iuser3
#define SENTRY_PEOPLE_BITS        6
#define OWNER                    0
#define UPGRADER_1                1
#define UPGRADER_2                2
#define TARGET                    3
#define UPGRADER_3                4
#define MASK_OWNER                0xFFFFFFC0 // 11111111111111111111111111000000
#define MASK_UPGRADER_1            0xFFFFF03F // 11111111111111111111000000111111
#define MASK_UPGRADER_2            0xFFFC0FFF // 11111111111111000000111111111111
#define MASK_TARGET                0xFF03FFFF // 11111111000000111111111111111111
#define MASK_UPGRADER_3                0xC0FFFFFF // 11000000111111111111111111111111
new const MASKS_PEOPLE[5] = {MASK_OWNERMASK_UPGRADER_1MASK_UPGRADER_2MASK_TARGETMASK_UPGRADER_3}

GetSentryPeople(const SENTRY, const WHO) {
    new 
data entity_get_int(SENTRYSENTRY_INT_PEOPLE)
    
data |= MASKS_PEOPLE[WHO]
    
data ^= MASKS_PEOPLE[WHO]
    
data = (data>>(WHO*SENTRY_PEOPLE_BITS))
    return 
data
}
SetSentryPeople(const SENTRY, const WHO, const IS) {
    new 
data entity_get_int(SENTRYSENTRY_INT_PEOPLE)
    
data &= MASKS_PEOPLE[WHO// nullify the setting
    
data |= (IS<<(WHO*SENTRY_PEOPLE_BITS)) // set the setting
    
entity_set_int(SENTRYSENTRY_INT_PEOPLEdata// store
}

#define SENTRY_INT_SETTINGS        EV_INT_iuser1
#define SENTRY_ROCKET_TIME        EV_FL_teleport_time
#define SENTRY_SETTINGS_BITS    2
#define SENTRY_SETTING_FIREMODE    0
#define SENTRY_SETTING_TEAM        1
#define SENTRY_SETTING_LEVEL    2
#define SENTRY_SETTING_PENDDIR    3
#define MASK_FIREMODE            0xFFFFFFFC // 11111111111111111111111111111100 = FFFFFFFC
#define MASK_TEAM                0xFFFFFFF3 // 11111111111111111111111111110011 = FFFFFFF3
#define MASK_LEVEL                0xFFFFFFCF // 11111111111111111111111111001111 = FFFFFFCF
#define MASK_PENDDIR            0xFFFFFF3F // 11111111111111111111111100111111 = FFFFFF3F
new const MASKS_SETTINGS[4] = {MASK_FIREMODEMASK_TEAMMASK_LEVELMASK_PENDDIR}

GetSentrySettings(const SENTRY, const SETTING) {
    new 
data entity_get_int(SENTRYSENTRY_INT_SETTINGS)
    
data |= MASKS_SETTINGS[SETTING]
    
data ^= MASKS_SETTINGS[SETTING]
    
//data = (data>>(SETTING*SENTRY_SETTINGS_BITS))
    
return (data>>(SETTING*SENTRY_SETTINGS_BITS))
}
SetSentrySettings(const SENTRY, const SETTING, const VALUE) {
    new 
data entity_get_int(SENTRYSENTRY_INT_SETTINGS)
    
data &= MASKS_SETTINGS[SETTING// nullify the setting
    //data |= (VALUE<<(SETTING*SENTRY_SETTINGS_BITS)) // set the setting
    
entity_set_int(SENTRYSENTRY_INT_SETTINGSdata | (VALUE<<(SETTING*SENTRY_SETTINGS_BITS))) // store
}

GetSentryFiremode(const SENTRY) {
    return 
GetSentrySettings(SENTRYSENTRY_SETTING_FIREMODE)
}
SetSentryFiremode(const SENTRY, const MODE) {
    
SetSentrySettings(SENTRYSENTRY_SETTING_FIREMODEMODE)
}
CsTeams:GetSentryTeam(const SENTRY) {
    return 
CsTeams:GetSentrySettings(SENTRYSENTRY_SETTING_TEAM)
}
SetSentryTeam(const SENTRY, const CsTeams:TEAM) {
    
SetSentrySettings(SENTRYSENTRY_SETTING_TEAMint:TEAM)
}
GetSentryLevel(const SENTRY) {
    return 
GetSentrySettings(SENTRYSENTRY_SETTING_LEVEL)
}
SetSentryLevel(const SENTRY, const LEVEL) {
    
SetSentrySettings(SENTRYSENTRY_SETTING_LEVELLEVEL)
}
GetSentryPenddir(const SENTRY) {
    return 
GetSentrySettings(SENTRYSENTRY_SETTING_PENDDIR)
}
SetSentryPenddir(const SENTRY, const PENDDIR) {
    
SetSentrySettings(SENTRYSENTRY_SETTING_PENDDIRPENDDIR)
}

#define SENTRY_ENT_BASE            EV_ENT_euser1

#define SENTRY_FL_ANGLE            EV_FL_fuser1
#define SENTRY_FL_SPINSPEED        EV_FL_fuser2
#define SENTRY_FL_MAXSPIN        EV_FL_fuser3
#define SENTRY_FL_LASTTHINK        EV_FL_fuser4

#define SENTRY_DIR_CANNON        0

#define BASE_ENT_SENTRY            EV_ENT_euser1
#define BASE_INT_TEAM            EV_INT_iuser1

#define SENTRY_LEVEL_1            0
#define SENTRY_LEVEL_2            1
#define SENTRY_LEVEL_3            2
#define SENTRY_LEVEL_4            3
#define SENTRY_FIREMODE_NO        0
#define SENTRY_FIREMODE_YES        1
#define SENTRY_FIREMODE_NUTS    2
#define TARGETUPMODIFIER            18.0 // if player ducks on ground, traces don't hit...
#define DMG_BULLET                (1<<1)    //выстрел
#define DMG_BLAST                (1<<6)    // explosive blast damage
#define TE_EXPLFLAG_NONE        0
#define TE_EXPLOSION                3
#define TE_TRACER                6
#define TE_BREAKMODEL            108
#define PENDULUM_MAX            45.0 // how far sentry turret turns in each direction when idle, before turning back
#define PENDULUM_INCREMENT        10.0 // speed of turret turning...
#define SENTRYSHOCKPOWER        3.0 // multiplier, increase to make exploding sentries throw stuff further away
#define CANNONHEIGHTFROMFEET    20.0 // tweakable to make tracer originate from the same height as the sentry's cannon. Also traces rely on this Y-wise offset.
#define PLAYERORIGINHEIGHT        36.0 // this is the distance from a player's EV_VEC_origin to ground, if standing up
#define HEIGHTDIFFERENCEALLOWED    20.0 // increase value to allow building in slopes with higher angles. You can set to 0.0 and you will only be able to build on exact flat ground. note: mostly applies to downhill building, uphill is still likely to "collide" with ground...

#define PLACE_RANGE 45.0

#define SENTRY_RADAR            20 // use as high as possible but should still be working (ie be able to see sentries plotted on radar while in menu, too high values doesn't seem to work)
#define SENTRY_RADAR_TEAMBUILT    21 // same as above

#define RPG_RADIUS    250.0
#define RPG_DAMAGE    150.0
#define RPG_DISTANCE    400.0

new const szModels[][] =
{
    
"models/dmsentries/base.mdl",
    
"models/dmsentries/sentry1_t.mdl",
    
"models/dmsentries/sentry2_t.mdl",
    
"models/dmsentries/sentry3_t.mdl",
    
"models/dmsentries/sentry1_ct.mdl",
    
"models/dmsentries/sentry2_ct.mdl",
    
"models/dmsentries/sentry3_ct.mdl",
    
"models/rpgrocket.mdl",
    
"models/computergibs.mdl"
}

new const 
szSounds[][] =
{
    
"debris/bustmetal1.wav",
    
"debris/bustmetal2.wav",
    
"debris/metal1.wav",
    
"debris/metal3.wav",
    
"dmsentries/turridle.wav",
    
"dmsentries/turrset.wav",
    
"dmsentries/turrspot.wav",
    
"dmsentries/building.wav",
    
"dmsentries/fire.wav",
    
"weapons/rocket1.wav"
}

new 
expDecal

#define SENTRYOWNERAWARD    300
#define SENTRYASSISTAWARD    150

new const g_DMG[4] = {5101515}                                // количество урона от пушки в зависимости от ее уровня
new const Float:g_THINKFREQUENCIES[4] = {2.01.00.50.5}        // через сколько захватывается цель
new const Float:g_HITRATIOS[4] = {0.60.750.850.85}            // разброс
new const Float:g_HEALTHS[4] = {3000.06000.09000.010000.0}    // сколько хп у пушки в зависимости от ее уровня (верхняя часть)
new const g_COST[4] = {300060060016000}                        // стоимость установки/улучшения пушек
new const g_SENTRYCOST[3] = {300035004000}                            // стоимость установки/улучшения пушек
#define g_sentriesNum (g_teamsentriesNum[0]+g_teamsentriesNum[1])
new g_teamsentriesNum[2]    
new 
g_sentries[MAXSENTRIES]
new 
g_iPlayerSentries[33]
new 
g_iPlayerSentriesEdicts[33][3]
new 
g_sModelIndexFireball
new g_msgDamage
new g_msgDeathMsg
new g_msgScoreInfo
new g_msgHostagePos
new g_msgHostageK
new g_iMaxPlayers
new Float:g_ONEEIGHTYTHROUGHPI
new Float:g_sentryOrigins[32][3]
new 
bool:g_inBuilding[33]
new 
sentries_num[33]
new 
gMsgID
new g_iTimer[33]
new 
m_iTrail

public plugin_init() {

    
register_plugin("Sentry guns""1.1""JGHG & miRror")

    
register_event "Spectator""ev_Spectation""a" )

    
register_clcmd("sentry_build""cmd_CreateSentry"0"- build a sentry gun where you are")
    
register_clcmd("say /sgstats""sgstats"0"- stats sentry")
    
register_clcmd("say /forcesh""givesgr")
    
    
RegisterHam Ham_Spawn"player""fw_PlayerSpawn_Post")

    
register_forward FM_TraceLine"fw_TraceLine_Post")

    
RegisterHam Ham_TakeDamage"func_breakable""fw_TakeDamage" )
    
    
register_touch "sentry""player""fw_TouchSentry" )
    
register_touch("rpg_rocket","*","fw_RpgTouch")
    
    
register_message 23"msg_TempEntity" )
    
register_think("sentrybase""think_sentrybase")
    
register_think "sentry""fw_ThinkSentry" )

    
g_msgDamage get_user_msgid("Damage")
    
g_msgDeathMsg get_user_msgid("DeathMsg")
    
g_msgScoreInfo get_user_msgid("ScoreInfo")
    
g_msgHostagePos get_user_msgid("HostagePos")
    
g_msgHostageK get_user_msgid("HostageK")
    
gMsgID get_user_msgid("StatusIcon")
    
    
g_iMaxPlayers get_global_int(GL_maxClients)
    
g_ONEEIGHTYTHROUGHPI 180.0 3.141592654
    
    expDecal 
get_decal_index("{scorch1")

    
set_task 120.0"checkhero", .flags "b" )
}

public 
plugin_precache() {
    for(new 
i=0;i<sizeof(szModels);i++)
        
precache_model(szModels[i])
    for(new 
i=0;i<sizeof(szSounds);i++)
        
precache_sound(szSounds[i])
    
g_sModelIndexFireball precache_model("sprites/zerogxplode.spr")
    
m_iTrail precache_model("sprites/smoke.spr")
}

public 
plugin_natives ()
{
    
register_native "get_sentry_people""native_get_sentry_people")
    
register_native "get_sentry_team""native_get_sentry_team")
}

public 
native_get_sentry_people sentrywho )
{
    return 
GetSentryPeople sentrywho )
}

public 
CsTeams:native_get_sentry_team sentry )
{
    return 
GetSentryTeam sentry )
}

public 
sgstats(id)
{
    
ChatColor id"^1Пушек у КТ: [ ^4%d ^1], ТТ: [ ^4%d ^1], у всех: [ ^4%d ^1]"g_teamsentriesNum[1],g_teamsentriesNum[0],g_sentriesNum)
}
public 
givesgr(id)
{
    if(
is_user_alive(id))
        
give_shield_grenade id )
        
    return 
PLUGIN_HANDLED
}

public 
checkhero()
{
    new 
iPlayers get_playersnum ()
    if(
iPlayers 15 && g_sentriesNum >= 14)
    {
        new 
players[32],  numplidbestfrags 0bool:heroenabled
        
new iData[2]; iData[0] = 5
        
if(g_teamsentriesNum[1] <= (g_sentriesNum 0.3))
        {
            
iData[1] = 1
            TimerStart 
iData )
            
get_players(playersnum"ache""CT")
            
heroenabled true
        
} else if(g_teamsentriesNum[0] <= (g_sentriesNum 0.3)) {
            
iData[1] = 0
            get_players
(playersnum"ache""TERRORIST")    
            
heroenabled true
        
}
        
        if(
heroenabled && num 1)
        {
            new 
iNum numiHero
            
for(--numnum>=0num--) 
            { 
                if(
get_user_frags(players[num]) >= bestfrags)
                {
                    
plid players[iHero num]
                    
bestfrags get_user_frags(plid)
                }
            }
            if ( 
sh_set_hero plid ) )
            {
                while (
GetSentryCount(plid) > 0)
                    
sentry_detonate_by_owner(plid)

                for ( new 
iHeroiNumi++ )
                    
players[i] = players[i+1]

                
iNum--
            }
            
/*if ( iNum > 0 )
            {
                new iParam[33]
                for ( new i; i < iNum; i++ )
                    iParam[i] = players[i]
                iParam[32] = iNum
                set_task ( 5.0, "GiveShieldGrenades", 0, iParam, 33 )
            }*/
        
}
    }
}

public 
TimerStart data[2] )
{
    if ( !
data[0] ) return

    
data[0]--

    
set_dhudmessage 255255255, -1.00.3500.01.00.00.0 )
    
show_dhudmessage 0"Выдача гранаты-ауры %s начнется через %d секунд"data[1] ? "контрам" "террам"data[0] )

    
set_task 1.0"TimerStart"0data)
}

public 
GiveShieldGrenades param[33] )
{
    new 
players[32], num param[32]
    for ( new 
inumi++ )
        
players[i] = param[i]

    new 
iPlayers[3], iNum clamp num1)

    for ( new 
ibiRandomiPlayeriNumi++ )
    {
        
iPlayer iPlayers[i] = players[iRandom random_num 0num-)]

        
//give_shield_grenade ( iPlayer )
        
g_iTimer[iPlayer] = 10
        set_user_godmode 
iPlayer)
        
TimerGodMode iPlayer )

        for ( 
iRandomnumb++ )
            
players[b] = players[b+1]
    }
    
set_dhudmessage 255255255, -1.00.3500.01.00.00.0 )
    
show_dhudmessage 0"Аура выдана %i игрокам"iNum )
}

public 
TimerGodMode id )
{
    if ( 
id g_iMaxPlayers )
        
id -= TASK_GODMODE

    
if ( !is_user_connected id ) || !is_user_alive id ) )
        return

    
set_dhudmessage 255255255, -1.00.3500.01.00.00.0 )

    if ( --
g_iTimer[id] > )
    {
        
show_dhudmessage id"У вас еще есть %i секунд бессмертия^nГраната аура - это дымовая граната"g_iTimer[id] )
        
set_task 1.0"SetGodMode"id+TASK_GODMODE )
    }
    else
    {
        
show_dhudmessage id"Режим бессмертия отключен" )
        
set_user_godmode id)
    }
}

public 
ev_Spectation ()
{
    new 
id read_data )

    if ( 
is_user_connected id ) && cs_get_user_team id ) == CS_TEAM_SPECTATOR )
        while ( 
GetSentryCount id ) > )
            
sentry_detonate_by_owner id )
}

public 
fw_TakeDamage entidinflictoridattackerFloat:damagedamagebits )
{
    if ( !
pev_valid ent ) )
        return 
HAM_IGNORED
    
    
new sClassname[11]
    
pev entpev_classnamesClassnamecharsmax sClassname ) )
    
    if ( 
equal sClassname"sentry" ) || equal sClassname"sentrybase" ) )
    {
        if ( 
sClassname[6] == 'b' )
            
ent entity_get_edict(entBASE_ENT_SENTRY)
        
        if ( 
pev_valid ent ) )
        {
            new 
iOwner GetSentryPeople entOWNER )
            
            if ( !
is_user_connected iOwner ) || !is_valid_player iOwner ) || !is_user_connected idattacker ) || !is_valid_player idattacker ) )
                return 
HAM_SUPERCEDE
        
            
if ( cs_get_user_team iOwner ) == cs_get_user_team idattacker ) && idattacker != iOwner )
                return 
HAM_SUPERCEDE
        
}
    }
    return 
HAM_IGNORED    
}

public 
cmd_CreateSentry id )
{
    new 
iSentry AimingAtSentry id )

    if ( 
iSentry && entity_range iSentryid ) <= MAXUPGRADERANGE )
        
SentryUpgrade idiSentry )
    else
        
SentryBuild id )

    return 
PLUGIN_HANDLED
}

public 
SentryBuild id )
{
    if ( !
is_user_alive id ) )
    {
        
ChatColor id"^3[^4Информация^3]^1 Мертвым нельзя ставить пушку!" )
        return
    }
    new 
iSentryCount GetSentryCount id )
    if ( 
iSentryCount == )
    {
        
ChatColor id"^3[^4Информация^3]^1 Нельзя установить более 3 пушек!" )
        return
    }
    if ( 
g_inBuilding[id] )
    {
        
ChatColor id"^3[^4Информация^3]^1 Эй, не так быстро..." )
        return
    }
    if ( !
is_entity_on_ground id ) )
    {
        
ChatColor id"^3[^4Информация^3]^1 Встань на землю, чтобы установить пушку!" )
        return
    }
    
    new 
Float:origin[3],classname[32],e
    entity_get_vector
(id,EV_VEC_origin,origin)
    
    
    
    while((
find_ent_in_sphere(e,origin,SENTRYMINDISTANCE))){
        
entity_get_string(e,EV_SZ_classname,classname,charsmax(classname))
        
        if(
strcmp(classname,"sentrybase") == && entity_get_int(eBASE_INT_TEAM) == get_user_team(id) && entity_get_edict(e,EV_ENT_owner) != id){
            
ChatColor(id,"^3[^4Информация^3]^1 Защита от подсосов")
            return
        }
    }
    
    if ( 
cs_get_user_money id ) < g_SENTRYCOST[iSentryCount] )
    {
        
ChatColor id"^3[^4Информация^3]^1 У тебя не хватает денег! (нужно %d$)"g_SENTRYCOST[iSentryCount] )
        return
    }

    new 
Float:fPlayerOrigin[3], Float:fOrigin[3], Float:fAngle[3]
    
pev idpev_originfPlayerOrigin )
    
pev idpev_anglesfAngle )
    
fOrigin fPlayerOrigin

    fOrigin
[0] += floatcos fAngle[1], degrees ) * PLACE_RANGE
    fOrigin
[1] += floatsin fAngle[1], degrees ) * PLACE_RANGE
    fOrigin
[0] += floatcos fAngle[0], degrees) * PLACE_RANGE
    fOrigin
[1] += floatcos fAngle[1], degrees )
    
fOrigin[0] -= floatsin fAngle[1], degrees )
    
fOrigin[1] += floatcos fAngle[2], degrees )
    
fOrigin[1] -= floatsin fAngle[2], degrees ) * PLACE_RANGE
    fOrigin
[0] -= floatsin fAngle[0], degrees ) * PLACE_RANGE
    fOrigin
[0] -= PLACE_RANGE

    
if ( pev idpev_flags ) & FL_DUCKING )
        
fOrigin[2] += 18.0fPlayerOrigin[2] += 18.0

    
new tr 0Float:fFraction
    engfunc 
EngFunc_TraceLinefPlayerOriginfOrigin0idtr )
    
get_tr2 trTR_flFractionfFraction )

    if ( 
fFraction != 1.0 )
    {
        
ChatColor id"^3[^4Информация^3]^1 Здесь не получается установить пушку!" )
        return
    }

    if ( 
CreateSentryBase fOriginid ) )
    {
        
cs_set_user_money idcs_get_user_money id ) - g_SENTRYCOST[iSentryCount] )
        
ammo_hud id)
        
sentries_num[id] += 1
        ammo_hud 
id)
    }
    else
        
ChatColor id"^3[^4Информация^3]^1 Здесь не получается установить пушку!" )
}

IncreaseSentryCount idsentry )
{
    
g_iPlayerSentriesEdicts[id][g_iPlayerSentries[id]] = sentry
    g_iPlayerSentries
[id]++
    new 
Float:fSentryOrigin[3], iSentryOrigin[3], iPlayerOrigin[3]
    
entity_get_vector sentryEV_VEC_originfSentryOrigin )
    
FVecIVec fSentryOriginiSentryOrigin )

    new 
sName[32]
    
get_user_name idsNamecharsmax sName ) )
    new 
CsTeams:iTeam cs_get_user_team id )

    for ( new 
1<= g_iMaxPlayersi++ )
    {
        if ( !
is_user_connected ) || !is_user_alive ) || cs_get_user_team ) != iTeam || id == )
            continue

        
get_user_origin iiPlayerOrigin )

        
client_print iprint_center"%s установил пушку в %d юнитах от вас"sNameget_distance iPlayerOriginiSentryOrigin ) )

        
message_begin MSG_ONE_UNRELIABLEg_msgHostagePos, .player )
        
write_byte )
        
write_byte SENTRY_RADAR_TEAMBUILT )
        
write_coord iSentryOrigin[0] )
        
write_coord iSentryOrigin[1] )
        
write_coord iSentryOrigin[2] )
        
message_end ()

        
message_begin MSG_ONE_UNRELIABLEg_msgHostageK, .player )
        
write_byte SENTRY_RADAR_TEAMBUILT )
        
message_end ()
    }
}
 
DecreaseSentryCount idsentry )
{
    for ( new 
ig_iPlayerSentries[id]; i++ )
    {
        if ( 
g_iPlayerSentriesEdicts[id][i] == sentry )
        {
            
g_iPlayerSentriesEdicts[id][i] = g_iPlayerSentriesEdicts[id][g_iPlayerSentries[id] - 1]
            
g_iPlayerSentriesEdicts[id][g_iPlayerSentries[id] - 1] = 0
            
break
        }
    }
    
g_iPlayerSentries[id]--
}

stock bool:CreateSentryBase Float:origin[3], creatorlevel SENTRY_LEVEL_1 )
{
    if ( !
CheckLocation origin ) )
        return 
false

    
new Float:hitPoint[3], Float:originDown[3]
    
originDown origin
    originDown
[2] = -5000.0 // dunno the lowest possible height...
    
trace_line(0originoriginDownhitPoint)
    new 
Float:baDistanceFromGround vector_distance(originhitPoint)

    new 
Float:difference PLAYERORIGINHEIGHT baDistanceFromGround
    
if (difference < -HEIGHTDIFFERENCEALLOWED || difference HEIGHTDIFFERENCEALLOWED) return false

    
new entbase create_entity("func_breakable"// func_wall
    
if (!entbase)
        return 
false

    
#define SIZE 16.0

    
new Float:fTraceEnds[5][3], Float:fTraceHit[3], iTypetr create_tr2 ()
    
fTraceEnds[0][0] = origin[0] - SIZE
    fTraceEnds
[0][1] = origin[1] - SIZE
    fTraceEnds
[0][2] = origin[2] + SIZE SIZE
    fTraceEnds
[1][0] = origin[0] + SIZE
    fTraceEnds
[1][1] = origin[1] - SIZE
    fTraceEnds
[1][2] = origin[2] + SIZE SIZE
    fTraceEnds
[2][0] = origin[0] - SIZE
    fTraceEnds
[2][1] = origin[1] + SIZE
    fTraceEnds
[2][2] = origin[2] + SIZE SIZE
    fTraceEnds
[3][0] = origin[0] + SIZE
    fTraceEnds
[3][1] = origin[1] + SIZE
    fTraceEnds
[3][2] = origin[2] + SIZE SIZE
    fTraceEnds
[4][0] = origin[0]
    
fTraceEnds[4][1] = origin[1]
    
fTraceEnds[4][2] = origin[2] + SIZE SIZE

    
for ( new i5i++ )
    {
        
fTraceHit fTraceEnds[i]
        
fTraceHit[2] += 40.0

        engfunc 
EngFunc_TraceLinefTraceEnds[i], fTraceHit00tr )
        
get_tr2 trTR_vecEndPosfTraceHit )

        if ( 
fTraceHit[2] - fTraceEnds[i][2] != 40.0 )
        {
            
iType 1
            
break
        }
    }

    if ( 
iType )
    {
        
fTraceEnds[0][0] = origin[0] - SIZE
        fTraceEnds
[0][1] = origin[1] - SIZE
        fTraceEnds
[0][2] = origin[2] - SIZE SIZE
        fTraceEnds
[1][0] = origin[0] + SIZE
        fTraceEnds
[1][1] = origin[1] - SIZE
        fTraceEnds
[1][2] = origin[2] - SIZE SIZE
        fTraceEnds
[2][0] = origin[0] - SIZE
        fTraceEnds
[2][1] = origin[1] + SIZE
        fTraceEnds
[2][2] = origin[2] - SIZE SIZE
        fTraceEnds
[3][0] = origin[0] + SIZE
        fTraceEnds
[3][1] = origin[1] + SIZE
        fTraceEnds
[3][2] = origin[2] - SIZE SIZE
        fTraceEnds
[4][0] = origin[0]
        
fTraceEnds[4][1] = origin[1]
        
fTraceEnds[4][2] = origin[2] - SIZE SIZE
        
new Float:fMinDistanceFloat:fDistance
        
for ( new i5i++ )
        {
            
fTraceHit[0] = fTraceEnds[i][0]
            
fTraceHit[1] = fTraceEnds[i][1]
            
fTraceHit[2] = -8192.0
    
            engfunc 
EngFunc_TraceLinefTraceEnds[i], fTraceHitIGNORE_MONSTERS0tr )
            
get_tr2 trTR_vecEndPosfTraceHit )
    
            
fDistance vector_distance fTraceEnds[i], fTraceHit )
    
            if ( 
fDistance fMinDistance || fMinDistance <= 0.0 )
            {
                
fMinDistance fDistance
                origin
[2] = fTraceHit[2]
            }
        }
    }
    
free_tr2 tr )

    new 
healthstring[16]
    
num_to_str(floatround(g_HEALTHS[0]), healthstring15)
    
DispatchKeyValue(entbase"health"healthstring)
    
DispatchKeyValue(entbase"material""6")

    
DispatchSpawn(entbase)
    
entity_set_string(entbaseEV_SZ_classname"sentrybase")
    
entity_set_model(entbase"models/dmsentries/base.mdl"// later set according to level
    
entity_set_edict(entbase,EV_ENT_owner,creator)
    
    new 
Float:mins[3], Float:maxs[3]
    
mins[0] = -16.0
    mins
[1] = -16.0
    mins
[2] = 0.0
    maxs
[0] = 16.0
    maxs
[1] = 16.0
    maxs
[2] = 1000.0 // Set to 16.0 later.
    
entity_set_size(entbaseminsmaxs)
    
entity_set_origin(entbaseorigin)
    
    
entity_set_int(entbaseEV_INT_solidSOLID_SLIDEBOX)
    
entity_set_int(entbaseEV_INT_movetypeiType MOVETYPE_FLY MOVETYPE_TOSS// head flies base falls
    
entity_set_int(entbaseBASE_INT_TEAM_:cs_get_user_team(creator))

    new 
parms[4]
    
parms[0] = entbase
    parms
[1] = creator
    parms
[2] = level
    parms
[3] = iType

    
if ( iType origin[2] += 16.0

    g_sentryOrigins
[creator 1] = origin

    emit_sound
(creatorCHAN_AUTO"dmsentries/building.wav"1.0ATTN_NORM0PITCH_NORM)

    
set_task(2.0"createsentryhead"0parms4)
    
g_inBuilding[creator] = true

    
return true
}

public 
createsentryhead(parms[4])
{
    new 
entbase parms[0]
    new 
level parms[2]
    new 
creator parms[1]
    new 
iType parms[3]

    if ( !
is_user_connected creator ) || !g_inBuilding[creator] )
    {
        if (
is_valid_ent(entbase))
            
remove_entity(entbase)

        return
    }

    if ( !
is_valid_team _:cs_get_user_team creator ) ) )
    {
        if (
is_valid_ent(entbase))
            
remove_entity(entbase)

        
sentries_num[creator]--
        return
    }

    new 
Float:origin[3]
    
origin g_sentryOrigins[creator 1]

    new 
ent create_entity("func_breakable")
    if (!
ent)
    {
        if (
is_valid_ent(entbase))
        {
            
remove_entity(entbase)
        }
        return
    }

    new 
Float:mins[3], Float:maxs[3]
    if (
is_valid_ent(entbase)) {
        
mins[0] = -16.0
        mins
[1] = -16.0
        mins
[2] = 0.0
        
        maxs
[0] = 16.0
        maxs
[1] = 16.0
        maxs
[2] = 16.0
        entity_set_size
(entbaseminsmaxs)

        
entity_set_edict(entSENTRY_ENT_BASEentbase)
        
entity_set_edict(entbaseBASE_ENT_SENTRYent)
    }

    
g_sentries[g_sentriesNum] = ent

    
new healthstring[16]
    
num_to_str(floatround(g_HEALTHS[0]), healthstring15)
    
DispatchKeyValue(ent"health"healthstring)
    
DispatchKeyValue(ent"material""6")

    
DispatchSpawn(ent)
    
entity_set_string(entEV_SZ_classname"sentry")
    switch(
_:cs_get_user_team(creator))
    {
        case 
1:
        {
            switch(
level)
            {
                case 
SENTRY_LEVEL_1entity_set_model(ent"models/dmsentries/sentry1_t.mdl")
                case 
SENTRY_LEVEL_2entity_set_model(ent"models/dmsentries/sentry2_t.mdl")
                case 
SENTRY_LEVEL_3entity_set_model(ent"models/dmsentries/sentry3_t.mdl")
            }
        }
        case 
2:
        {
            switch(
level)
            {
                case 
SENTRY_LEVEL_1entity_set_model(ent"models/dmsentries/sentry1_ct.mdl")
                case 
SENTRY_LEVEL_2entity_set_model(ent"models/dmsentries/sentry2_ct.mdl")
                case 
SENTRY_LEVEL_3entity_set_model(ent"models/dmsentries/sentry3_ct.mdl")
            }
        }
    }
    
    
    
mins[0] = -16.0
    mins
[1] = -16.0
    mins
[2] = 0.0
    maxs
[0] = 16.0
    maxs
[1] = 16.0
    maxs
[2] = 48.0
    entity_set_size
(entminsmaxs)
    
entity_set_origin(entorigin)
    
entity_get_vector(creatorEV_VEC_anglesorigin)
    
origin[0] = 0.0
    origin
[1] += 180.0
    entity_set_float
(entSENTRY_FL_ANGLEorigin[1])
    
origin[2] = 0.0
    entity_set_vector
(entEV_VEC_anglesorigin)
    
entity_set_int(entEV_INT_solidSOLID_SLIDEBOX// SOLID_SLIDEBOX
    
entity_set_int(entEV_INT_movetypeiType MOVETYPE_FLY MOVETYPE_TOSS// head flies, base doesn't

    
SetSentryPeople(entOWNERcreator)
    
    new 
CsTeams:crteam cs_get_user_team(creator)
    
SetSentryTeam entcrteam )
    
SetSentryLevel entlevel )

    
g_teamsentriesNum[_:crteam-1]++
    
    
emit_sound(entCHAN_AUTO"dmsentries/turrset.wav"1.0ATTN_NORM0PITCH_NORM)

    
IncreaseSentryCount(creatorent)

    new 
directions = (random_num(01)<<SENTRY_DIR_CANNON)
    
SetSentryPenddir entdirections )

    
g_inBuilding[creator] = false

    
if (!is_valid_ent(entbase))
        
SetSentryFiremode entSENTRY_FIREMODE_NUTS )

    
entity_set_float entSENTRY_FL_LASTTHINKget_gametime () + g_THINKFREQUENCIES[0] )
    
entity_set_float entEV_FL_nextthinkget_gametime () + 0.01 )

    
/*static bool:bHamRegistred

    if ( !bHamRegistred )
    {
        RegisterHamFromEntity ( Ham_Think, ent, "fw_ThinkSentry", 1 )
        bHamRegistred = true
    }*/
}

stock bool:CheckLocation ( const Float:origin[3] )
{
    if ( 
engfunc EngFunc_PointContentsorigin ) != CONTENTS_EMPTY )
        return 
false

    
new tr create_tr2 ()

    
engfunc EngFunc_TraceHulloriginorigin0HULL_HEAD/*HUMAN*/0tr )
    if ( !
get_tr2 trTR_InOpen ) || get_tr2 trTR_StartSolid ) || get_tr2 trTR_AllSolid ) )
    {
        
free_tr2 tr )
        return 
false
    
}

    
#define SIZE 16.0

    
new Float:fTraceEnds[9][3], Float:fTraceHit[3], iHitEnt
    fTraceEnds
[0][0] = origin[0]
    
fTraceEnds[0][1] = origin[1]
    
fTraceEnds[0][2] = origin[2] - SIZE SIZE
    fTraceEnds
[1][0] = origin[0] - SIZE
    fTraceEnds
[1][1] = origin[1] - SIZE
    fTraceEnds
[1][2] = origin[2] - SIZE SIZE
    fTraceEnds
[2][0] = origin[0] + SIZE
    fTraceEnds
[2][1] = origin[1] - SIZE
    fTraceEnds
[2][2] = origin[2] - SIZE SIZE
    fTraceEnds
[3][0] = origin[0] - SIZE
    fTraceEnds
[3][1] = origin[1] + SIZE
    fTraceEnds
[3][2] = origin[2] - SIZE SIZE
    fTraceEnds
[4][0] = origin[0] + SIZE
    fTraceEnds
[4][1] = origin[1] + SIZE
    fTraceEnds
[4][2] = origin[2] - SIZE SIZE
    fTraceEnds
[5][0] = origin[0] - SIZE
    fTraceEnds
[5][1] = origin[1] - SIZE
    fTraceEnds
[5][2] = origin[2] + SIZE SIZE
    fTraceEnds
[6][0] = origin[0] + SIZE
    fTraceEnds
[6][1] = origin[1] - SIZE
    fTraceEnds
[6][2] = origin[2] + SIZE SIZE
    fTraceEnds
[7][0] = origin[0] - SIZE
    fTraceEnds
[7][1] = origin[1] + SIZE
    fTraceEnds
[7][2] = origin[2] + SIZE SIZE
    fTraceEnds
[8][0] = origin[0] + SIZE
    fTraceEnds
[8][1] = origin[1] + SIZE
    fTraceEnds
[8][2] = origin[2] + SIZE SIZE

    
for (new 009i++)
    {
        if ( 
engfunc EngFunc_PointContentsfTraceEnds[i] ) != CONTENTS_EMPTY )
        {
            
free_tr2 tr )
            return 
false
        
}

        
engfunc EngFunc_TraceLineoriginfTraceEnds[i], 00tr )
        
iHitEnt get_tr2 trTR_pHit )

        if ( 
iHitEnt != -)
        {
            
free_tr2 tr )
            return 
false
        
}

        
get_tr2 trTR_vecEndPosfTraceHit )

        for ( 
03b++ )
        {
            if ( 
fTraceEnds[i][b] != fTraceHit[b] )
            {
                
free_tr2 tr )
                return 
false
            
}
        }
        if ( 
)
        {
            
fTraceHit[0] = fTraceEnds[i][0]
            
fTraceHit[1] = fTraceEnds[i][1]
            
fTraceHit[2] = -8192.0

            engfunc 
EngFunc_TraceLinefTraceEnds[i], fTraceHit00tr )
            
//get_tr2 ( tr, TR_vecEndPos, fTraceHit )
            
iHitEnt get_tr2 trTR_pHit )

            if ( 
pev_valid iHitEnt ) )
            {
                new 
sClassname[7]
                
pev iHitEntpev_classnamesClassnamecharsmax sClassname ) )
                if ( 
equal sClassname"sentry" ) )
                {
                    
free_tr2 tr )
                    return 
false
                
}
            }
        }
    }
    
free_tr2 tr )
    return 
true
}

bool:sentry_pendulum sentry )
{
    switch ( 
GetSentryFiremode sentry ) )
    {
        case 
SENTRY_FIREMODE_NO:
        {
            new 
Float:fAngles[3]
            
entity_get_vector sentryEV_VEC_anglesfAngles )
            new 
Float:fBaseAngle entity_get_float sentrySENTRY_FL_ANGLE )
            new 
iDirections GetSentryPenddir sentry )
            
            if ( 
iDirections & (1<<SENTRY_DIR_CANNON) )
            {
                
fAngles[1] -= ( PENDULUM_INCREMENT 0.01 )
                if ( 
fAngles[1] < fBaseAngle PENDULUM_MAX )
                {
                    
fAngles[1] = fBaseAngle PENDULUM_MAX
                    iDirections 
&= ~(1<<SENTRY_DIR_CANNON)
                    
SetSentryPenddir sentryiDirections )
                }
            }
            else 
            {
                
fAngles[1] += ( PENDULUM_INCREMENT 0.01 )
                if ( 
fAngles[1] > fBaseAngle PENDULUM_MAX 
                {
                    
fAngles[1] = fBaseAngle PENDULUM_MAX
                    iDirections 
|= (1<<SENTRY_DIR_CANNON)
                    
SetSentryPenddir sentryiDirections )
                }
            }

            
entity_set_vector sentryEV_VEC_anglesfAngles )
            return 
true
        
}
        case 
SENTRY_FIREMODE_NUTS:
        {
            new 
Float:fAngles[3]
            
entity_get_vector sentryEV_VEC_anglesfAngles )

            new 
Float:fSpinSpeed entity_get_float sentrySENTRY_FL_SPINSPEED )
            if ( 
GetSentryPenddir sentry ) & (1<<SENTRY_DIR_CANNON) )
            {
                
fAngles[1] -= ( fSpinSpeed 0.01 )
                if ( 
fAngles[1] < 0.0 )
                    
fAngles[1] = 360.0 fAngles[1]
            }
            else
            {
                
fAngles[1] += ( fSpinSpeed 0.01 )
                if ( 
fAngles[1] > 360.0 )
                    
fAngles[1] = fAngles[1] - 360.0
            
}
            
entity_set_float sentrySENTRY_FL_SPINSPEED, ( fSpinSpeed += random_float 1.02.0 ) ) )

            new 
Float:fMaxSpin entity_get_float sentrySENTRY_FL_MAXSPIN )
            if ( 
fMaxSpin == 0.0 )
            {
                
entity_set_float sentrySENTRY_FL_LASTTHINK0.5 )
                
entity_set_float sentrySENTRY_FL_MAXSPINfMaxSpin random_float 500.0750.0 ) )
            }
            else if ( 
fSpinSpeed >= fMaxSpin )
            {
                
sentry_detonate sentryfalsefalse )
                return 
false
            
}
            
entity_set_vector sentryEV_VEC_anglesfAngles )
            return 
true
        
}
    }
    return 
true
}

//#define    TE_TRACER            6        // tracer effect from point to point
tracer(Float:start[3], Float:end[3]) {
    new 
start_[3], end_[3]
    
FVecIVec(startstart_)
    
FVecIVec(endend_)
    
message_begin(MSG_BROADCASTSVC_TEMPENTITY//  MSG_PAS MSG_BROADCAST
    
write_byte(TE_TRACER)
    
write_coord(start_[0])
    
write_coord(start_[1])
    
write_coord(start_[2])
    
write_coord(end_[0])
    
write_coord(end_[1])
    
write_coord(end_[2])
    
message_end()
}
stock create_explosion(Float:origin_[3]) {
    new 
origin[3]
    
FVecIVec(origin_origin)

    
message_begin(MSG_BROADCASTSVC_TEMPENTITYorigin// MSG_PAS not really good here
    
write_byte(TE_EXPLOSION)
    
write_coord(origin[0])
    
write_coord(origin[1])
    
write_coord(origin[2])
    
write_short(g_sModelIndexFireball)
    
write_byte(random_num(020) + 50// scale * 10 // random_num(0, 20) + 20
    
write_byte(12// framerate
    
write_byte(TE_EXPLFLAG_NONE)
    
message_end()

    
KnockBack origin_ )

    new 
Float:playerOrigin[3], Float:distanceFloat:flDmgToDoFloat:dmgbase 90.0newHealth
    
for (new 1<= g_iMaxPlayersi++) {
        if (!
is_user_alive(i) || get_user_godmode(i))
            continue

        
entity_get_vector(iEV_VEC_originplayerOrigin)
        
distance vector_distance(playerOriginorigin_)
        if (
distance <= SENTRYEXPLODERADIUS) {
            
flDmgToDo dmgbase - (dmgbase * (distance SENTRYEXPLODERADIUS))
            
newHealth get_user_health(i) - floatround(flDmgToDo)
            if (
newHealth <= 0) {
                
set_task(0.0"TicketToHell"i)
                continue
            }

            
set_user_health(inewHealth)

            
message_begin(MSG_ONE_UNRELIABLEg_msgDamage, {0,0,0}, i)
            
write_byte(floatround(flDmgToDo))
            
write_byte(floatround(flDmgToDo))
            
write_long(DMG_BLAST)
            
write_coord(origin[0])
            
write_coord(origin[1])
            
write_coord(origin[2])
            
message_end()
        }
    }
}

public 
TicketToHell(player) {
    if (!
is_user_connected(player))
        return
    new 
frags get_user_frags(player)
    
user_kill(player1// don't decrease frags
    
new parms[4]
    
parms[0] = player
    parms
[1] = frags
    parms
[2] = cs_get_user_deaths(player)
    
parms[3] = int:cs_get_user_team(player)
    
set_task(0.0"DelayedScoreInfoUpdate"0parms4)
}

public 
DelayedScoreInfoUpdate(parms[4]) {
    
scoreinfo_update(parms[0], parms[1], parms[2], parms[3])
}

KnockBack Float:origin[3] )
{
    new 
iEntList[32]
    new 
iEntsFound find_sphere_class 0"player"SENTRYEXPLODERADIUSiEntListg_iMaxPlayersorigin )

    if ( !
iEntsFound )
        return

    new 
Float:fOriginEnt[3]
    new 
Float:fVelocity[3]
    new 
Float:fOriginEnd[3]
    new 
Float:fDistance
    
new iPlayer

    
for ( new iiEntsFoundi++ )
    {
        
iPlayer iEntList[i]

        if ( !
is_user_alive iPlayer ) )
            continue

        
entity_get_vector iPlayerEV_VEC_originfOriginEnt )

        
fDistance vector_distance fOriginEntorigin )

        if ( 
is_entity_on_ground iPlayer ) && fOriginEnt[2] < origin[2] )
            
fOriginEnt[2] = origin[2] + fDistance

        entity_get_vector 
iPlayerEV_VEC_velocityfVelocity )

        
fOriginEnd[0] = ( fOriginEnt[0] - origin[0] ) * SENTRYEXPLODERADIUS fDistance origin[0]
        
fOriginEnd[1] = ( fOriginEnt[1] - origin[1] ) * SENTRYEXPLODERADIUS fDistance origin[1]
        
fOriginEnd[2] = ( fOriginEnt[2] - origin[2] ) * SENTRYEXPLODERADIUS fDistance origin[2]

        
fVelocity[0] += ( fOriginEnd[0] - fOriginEnt[0] ) * SENTRYSHOCKPOWER
        fVelocity
[1] += ( fOriginEnd[1] - fOriginEnt[1] ) * SENTRYSHOCKPOWER
        fVelocity
[2] += ( fOriginEnd[2] - fOriginEnt[2] ) * SENTRYSHOCKPOWER

        entity_set_vector 
iPlayerEV_VEC_velocityfVelocity )
    }
}

public 
msg_TempEntity ()
{
    if ( 
get_msg_args () != 15 && get_msg_arg_int ) != TE_BREAKMODEL )
        return 
PLUGIN_CONTINUE

    
for ( new ig_sentriesNumi++ )
    {
        if ( 
entity_get_float g_sentries[i], EV_FL_health ) <= 0.0 )
        {
            
sentry_detonate ifalsetrue )
            
i--
        }
    }
    return 
PLUGIN_CONTINUE
}

public 
fw_ThinkSentry ent )
{
    if ( !
is_valid_ent ent ) )
        return

    static 
iOwneriOwner GetSentryPeople entOWNER )

    if ( !
is_user_connected iOwner ) )
        return

    if ( 
cs_get_user_team iOwner ) == CS_TEAM_SPECTATOR )
    {
        
sentry_detonate enttruefalse )
        return
    }
    
    if ( !
sentry_pendulum ent ) )
        return

    static 
Float:fGameTimefGameTime get_gametime ()
    if ( 
entity_get_float entSENTRY_FL_LASTTHINK ) <= fGameTime )
    {
        new 
Float:fOriginSentry[3], Float:fOriginHit[3], iHitEnt
        entity_get_vector 
entEV_VEC_originfOriginSentry )
        
fOriginSentry[2] += CANNONHEIGHTFROMFEET // Move up some, this should be the Y origin of the cannon
    
        
new firemode GetSentryFiremode ent )
        new 
target GetSentryPeople entTARGET )
        if ( 
firemode == SENTRY_FIREMODE_YES && is_valid_ent target ) && is_user_alive target ) && cs_get_user_team target ) != GetSentryTeam ent ) && !IsInSphere target ))
        {
            new 
sentryLevel GetSentryLevel ent )
    
            new 
Float:fOriginTarget[3]
            
entity_get_vector targetEV_VEC_originfOriginTarget )
    
            if ( 
entity_get_int targetEV_INT_flags ) & FL_DUCKING )
                
fOriginTarget[2] += TARGETUPMODIFIER
    
            iHitEnt 
trace_line entfOriginSentryfOriginTargetfOriginHit )
            if ( 
iHitEnt == entity_get_edict entSENTRY_ENT_BASE ) )
                
iHitEnt trace_line iHitEntfOriginHitfOriginTargetfOriginHit )
    
            if ( 
iHitEnt != target && is_user_alive iHitEnt ) && GetSentryTeam ent ) != cs_get_user_team iHitEnt ) && !IsInSphere iHitEnt ))
            {
                
target iHitEnt
                SetSentryPeople
(entTARGETiHitEnt)
            }
            if ( 
iHitEnt == target )
            {
                
SentryTurnToTarget entfOriginSentryfOriginTarget )
                
emit_sound entCHAN_WEAPON"dmsentries/fire.wav"1.0ATTN_NORM0PITCH_NORM )
    
                new 
Float:fHitRatio random_float 0.01.0 ) - g_HITRATIOS[sentryLevel// ie 0.5 - 0.7 = -0.2, a hit and 0.8 - 0.7 = a miss by 0.1
    
                
if(GetSentryLevel(ent) == SENTRY_LEVEL_4){
                    if(
get_gametime() > entity_get_float(ent,SENTRY_ROCKET_TIME)){
                        if(
entity_range(ent,target) >= RPG_DISTANCE){
                            new 
data[2]
                            
data[0] = ent
                            
                            ShootRockets
(data)
                        }
                        
                        
entity_set_float(ent,SENTRY_ROCKET_TIME,get_gametime() +  2.0)
                    }
                }
    
                if ( !
get_user_godmode target ) && fHitRatio <= 0.0 )
                    
sentry_damagetoplayer entsentryLevelfOriginSentrytarget )
                else
                {
                    new 
Float:fSentryAngle[3] = {0.00.00.0}
    
                    new 
Float:fOriginHit[0] - fOriginSentry[0]
                    new 
Float:fOriginHit[1] - fOriginSentry[1]
                    new 
Float:radians floatatan z/xradian )
                    
fSentryAngle[1] = radians g_ONEEIGHTYTHROUGHPI
                    
if ( fOriginHit[0] < fOriginSentry[0] )
                        
fSentryAngle[1] -= 180.0
    
                    
new Float:fOriginHit[2] - fOriginSentry[2]
                    new 
Float:vector_distance fOriginSentryfOriginHit )
                    
radians floatatan h/bradian )
                    
fSentryAngle[0] = radians g_ONEEIGHTYTHROUGHPI
    
                    fSentryAngle
[0] += random_float ( -10.0 fHitRatio10.0 fHitRatio // aim is a little off here :-)
                    
fSentryAngle[1] += random_float ( -10.0 fHitRatio10.0 fHitRatio // aim is a little off here :-)
                    
engfunc EngFunc_MakeVectorsfSentryAngle )
                    new 
Float:vector[3]
                    
get_global_vector GL_v_forwardvector )
                    for ( new 
03i++ )
                        
vector[i] *= 1000
    
                    
new Float:traceEnd[3]
                    for ( new 
03i++ )
                        
traceEnd[i] = vector[i] + fOriginSentry[i]
    
                    new 
iHitEnt2 ent
                    
static lolcheck 0
                    
while ( ( iHitEnt2 trace_line iHitEnt2fOriginHittraceEndfOriginHit ) ) )
                        if ( 
lolcheck++ > 700 ) break
    
                }
                
tracer fOriginSentryfOriginHit )

                
entity_set_float entSENTRY_FL_LASTTHINKfGameTime 0.1 )
                
entity_set_float entEV_FL_nextthinkfGameTime 0.01 )
                return
            }
            else
                
SetSentryFiremode entSENTRY_FIREMODE_NO )
        }
        else if ( 
firemode == SENTRY_FIREMODE_NUTS )
        {
            new 
iHitEnt2 EntViewHitPoint entfOriginSentryfOriginHit )
            
emit_sound(entCHAN_WEAPON"dmsentries/fire.wav"1.0ATTN_NORM0PITCH_NORM)
            
tracer(fOriginSentryfOriginHit)
    
            if (
is_user_connected(iHitEnt2) && is_user_alive(iHitEnt2) && !get_user_godmode(iHitEnt2))
            {
                
sentry_damagetoplayer(entGetSentryLevel ent ), fOriginSentryiHitEnt2)
            }
            
entity_set_float entSENTRY_FL_LASTTHINKfGameTime 0.1 )
            
entity_set_float entEV_FL_nextthinkfGameTime 0.01 )
            return
        }
    
        if ( 
random_num 099 ) < 10 )
            
emit_sound entCHAN_AUTO"dmsentries/turridle.wav"1.0ATTN_NORM0PITCH_NORM )

        new 
closestTarget 0Float:closestDistanceFloat:distanceFloat:closestOrigin[3], Float:playerOrigin[3], CsTeams:sentryTeam GetSentryTeam ent )
        for ( new 
1<= g_iMaxPlayersi++ )
        {
            if ( !
is_user_connected ) || !is_user_alive ) || cs_get_user_team ) == sentryTeam || IsInSphere ) )
                continue
    
            
entity_get_vector iEV_VEC_originplayerOrigin )
    
            if ( 
entity_get_int iEV_INT_flags ) & FL_DUCKING )
                
playerOrigin[2] += TARGETUPMODIFIER
    
            iHitEnt 
trace_line entfOriginSentryplayerOriginfOriginHit )
            if ( 
iHitEnt == entity_get_edict entSENTRY_ENT_BASE ) )
                
iHitEnt trace_line(iHitEntfOriginHitplayerOriginfOriginHit)
    
            if ( 
iHitEnt == )
            {
                
distance vector_distance fOriginSentryplayerOrigin )
                
closestOrigin playerOrigin
    
                
if ( distance closestDistance || closestTarget == )
                {
                    
closestTarget i
                    closestDistance 
distance
                
}
            }
        }
    
        if ( 
closestTarget )
        {
            
emit_sound entCHAN_AUTO"dmsentries/turrspot.wav"1.0ATTN_NORM0PITCH_NORM )
            
SentryTurnToTarget entfOriginSentryclosestOrigin )
    
            
SetSentryFiremode entSENTRY_FIREMODE_YES )
            
SetSentryPeople entTARGETclosestTarget )
        }
        else
            
SetSentryFiremode entSENTRY_FIREMODE_NO )

        
entity_set_float entSENTRY_FL_LASTTHINKfGameTime g_THINKFREQUENCIES[GetSentryLevel ent )] )
    }
    
entity_set_float entEV_FL_nextthinkfGameTime 0.01 )
}

public 
think_sentrybase(sentrybase) {
    
sentrybase_broke(sentrybase)
    return 
PLUGIN_CONTINUE
}

sentrybase_broke(sentrybase) {
    new 
sentry entity_get_edict(sentrybaseBASE_ENT_SENTRY)
    if (
is_valid_ent(sentrybase))
        
remove_entity(sentrybase)

    if (
sentry == 0)
        return

    
SetSentryFiremode sentrySENTRY_FIREMODE_NUTS )
}

sentry_detonate(sentrybool:quietbool:isIndex) {
    new 
i
    
if (isIndex)
    {
        
sentry
        sentry 
g_sentries[sentry]
        if (!
is_valid_ent(sentry))
            return
    }
    else
    {
        if (!
is_valid_ent(sentry))
            return

        for (new 
0g_sentriesNumj++) {
            if (
g_sentries[j] == sentry) {
                
j
                
break
            }
        }
    }
    
entity_set_float sentryEV_FL_nextthink0.0 )

    new 
owner GetSentryPeople(sentryOWNER)

    if (!
quiet) {
        new 
Float:origin[3]
        
entity_get_vector(sentryEV_VEC_originorigin)
        
create_explosion(origin)
        
ChatColor owner"^3[^4Действие^3]^1 Твоя пушка взорвана!")
        
ammo_hud(owner0)
        
sentries_num[owner] -= 1
        ammo_hud
(owner1)        
    }
    
DecreaseSentryCount(ownersentry)

    
// Remove base first
    
if (GetSentryFiremode sentry ) != SENTRY_FIREMODE_NUTS)
        
set_task 0.1"DelayRemoveEntity"entity_get_edict sentrySENTRY_ENT_BASE ) )
        
//remove_entity(entity_get_edict(sentry, SENTRY_ENT_BASE))

    
new CsTeams:iSentryTeam GetSentryTeam sentry )

    
set_task 0.1"DelayRemoveEntity"sentry )
    
//remove_entity(sentry)
    // Put the last sentry in the deleted entity's place
    
if(> (g_sentriesNum 1) > MAXSENTRIES) return
    
g_sentries[i] = g_sentries[g_sentriesNum 1]
    
    
g_teamsentriesNum[_:iSentryTeam-1]--
}

public 
DelayRemoveEntity ent )
{
    if ( 
pev_valid ent ) )
        
remove_entity ent )
}

sentry_detonate_by_owner(ownerbool:quiet false) {
    for(new 
0g_sentriesNumi++) {
        if (
GetSentryPeople(g_sentries[i], OWNER) == owner) {
            
sentry_detonate(iquiettrue)
            break
        }
    }
}

public 
client_disconnect(id) {
    while (
GetSentryCount(id) > 0)
        
sentry_detonate_by_owner(id)
}

// урон игроку
stock sentry_damagetoplayer(sentrysentryLevelFloat:sentryOrigin[3], target) {
    new 
newHealth get_user_health(target) - g_DMG[sentryLevel]

    if (
newHealth <= 0) {
        new 
targetFrags get_user_frags(target) + 1
        
new owner GetSentryPeople(sentryOWNER)
        
        if(!
is_user_connected(owner))
            return
        
        new 
ownerFrags get_user_frags(owner) + 1
        set_user_frags
(targettargetFrags// otherwise frags are subtracted from victim for dying (!!)
        
set_user_frags(ownerownerFrags)
        
        new 
contributors[4]
        
contributors[0] = owner
        contributors
[1] = GetSentryPeople(sentryUPGRADER_1)
        
contributors[2] = GetSentryPeople(sentryUPGRADER_2)
        
contributors[3] = GetSentryPeople(sentryUPGRADER_3)
        
        for(new 
sizeof contributors i++){
            if(!
contributors[i])
                continue
                
            if(!
is_user_connected(contributors[i]) || get_user_team(contributors[i]) != get_user_team(contributors[0])){
                switch(
i){ // yao face
                    
case 1SetSentryPeople(sentry,UPGRADER_1,0)
                    case 
2SetSentryPeople(sentry,UPGRADER_2,0)
                    case 
3SetSentryPeople(sentry,UPGRADER_3,0)
                }
                
                continue
            }
            
            
// izvini 4yvak, no menya nakrilo
            
cs_set_user_money(contributors[i],
                
clamp(
                    
cs_get_user_money(contributors[i]) + (== SENTRYOWNERAWARD SENTRYASSISTAWARD),
                    
0,
                    
16000
                
)
            )
        }

        
// ny ebatb kakoy frag
        
message_begin(MSG_ALLg_msgDeathMsg, {000} ,0)
        
write_byte(owner)
        
write_byte(target)
        
write_byte(0)
        
write_string("sentry gun")
        
message_end()

        
scoreinfo_update(ownerownerFragscs_get_user_deaths(owner), int:cs_get_user_team(owner))
        
set_msg_block(g_msgDeathMsgBLOCK_ONCE)
    }

    
set_user_health(targetnewHealth)

    
message_begin(MSG_ONE_UNRELIABLEg_msgDamage, {0,0,0}, target)
    
write_byte(g_DMG[sentryLevel])
    
write_byte(g_DMG[sentryLevel])
    
write_long(DMG_BULLET)
    
write_coord(floatround(sentryOrigin[0]))
    
write_coord(floatround(sentryOrigin[1]))
    
write_coord(floatround(sentryOrigin[2]))
    
message_end()
}

scoreinfo_update(idfragsdeathsteam) {
    
message_begin(MSG_ALLg_msgScoreInfo)
    
write_byte(id)
    
write_short(frags)
    
write_short(deaths)
    
write_short(0)
    
write_short(team)
    
message_end()
}

SentryTurnToTarget entFloat:sentry_origin[3], Float:closest_origin[3] )
{
    new 
Float:fAngle[3]
    
entity_get_vector entEV_VEC_anglesfAngle )
    new 
Float:closest_origin[0] - sentry_origin[0]
    new 
Float:closest_origin[1] - sentry_origin[1]

    new 
Float:fRadians floatatan z/xradian )
    
fAngle[1] = fRadians g_ONEEIGHTYTHROUGHPI
    
if ( closest_origin[0] < sentry_origin[0] )
        
fAngle[1] -= 180.0

    entity_set_float 
entSENTRY_FL_ANGLEfAngle[1] )
    
entity_set_vector entEV_VEC_anglesfAngle )
}

AimingAtSentry id )
{
    if ( !
is_user_alive id ) )
        return 
0

    
new hitEntbodyPart
    
if (get_user_aiming(idhitEntbodyPart) == 0.0)
        return 
0

    
if ( is_valid_ent hitEnt ) )
    {
        new 
classname[32], l_sentry
        entity_get_string
(hitEntEV_SZ_classnameclassname31)
        if (
equal(classname"sentry_base"))
            
l_sentry entity_get_edict(hitEntBASE_ENT_SENTRY)
        else if (
equal(classname"sentry"))
            
l_sentry hitEnt
        
else
            
l_sentry 0

        
return l_sentry
    
}
    return 
0
}

// улучшение уровня пушки
bool:SentryUpgrade idsentry )
{
    
    if ( 
GetSentryFiremode sentry ) == SENTRY_FIREMODE_NUTS )
        return 
false
    
    
new iLevel GetSentryLevel sentry )

    if ( 
iLevel == SENTRY_LEVEL_4 )
        return 
false
    
    
if ( GetSentryPeople sentryOWNER ) == id )
        return 
false
    
    
if ( cs_get_user_team id ) != GetSentryTeam sentry ) )
    {
        return 
false
    
}

    if ( 
cs_get_user_team GetSentryPeople sentryOWNER ) ) == CS_TEAM_SPECTATOR )
        return 
false
        
    
// e ron don don
    
if(GetSentryPeople(sentry,UPGRADER_1) == id ||
        
GetSentryPeople(sentry,UPGRADER_2) == id ||
        
GetSentryPeople(sentry,UPGRADER_3) == id
    
)
        return 
false
    
    iLevel
++

    if ( 
cs_get_user_money id ) - g_COST[iLevel] < )
    {
        
ChatColor id"^3[^4Информация^3]^1 У тебя не хватает денег (нужно %d$)"g_COST[iLevel] )
        return 
false
    
}

    
cs_set_user_money idcs_get_user_money id ) - g_COST[iLevel] )

    new 
iTeam _:cs_get_user_team id ), iUpgraderField
    
switch ( iLevel )
    {
        
// this kod is very zaebisb
        
case SENTRY_LEVEL_2:
        {
            switch ( 
iTeam )
            {
                case 
1:entity_set_model sentry"models/dmsentries/sentry2_t.mdl" )
                case 
2:entity_set_model sentry"models/dmsentries/sentry2_ct.mdl" )
            }
            
iUpgraderField UPGRADER_1
        
}
        case 
SENTRY_LEVEL_3:
        {
            switch ( 
iTeam )
            {
                case 
1:entity_set_model sentry"models/dmsentries/sentry3_t.mdl" )
                case 
2:entity_set_model sentry"models/dmsentries/sentry3_ct.mdl" )
            }
            
iUpgraderField UPGRADER_2
        
}
        case 
SENTRY_LEVEL_4:{
            switch(
iTeam){
                case 
1:entity_set_model sentry"models/dmsentries/sentry3_t.mdl" )
                case 
2:entity_set_model sentry"models/dmsentries/sentry3_ct.mdl" )
            }
            
            
entity_set_byte(sentry,EV_BYTE_controller2,120)
            
entity_set_byte(sentry,EV_BYTE_controller3,120)
            
            
iUpgraderField UPGRADER_3
        
}
    }

    new 
Float:fMins[3], Float:fMaxs[3]
    
fMins[0] = -16.0
    fMins
[1] = -16.0
    fMins
[2] = 0.0
    fMaxs
[0] = 16.0
    fMaxs
[1] = 16.0
    fMaxs
[2] = 48.0 // 4.0
    
entity_set_size sentryfMinsfMaxs )
    
emit_sound sentryCHAN_AUTO"dmsentries/turrset.wav"1.0ATTN_NORM0PITCH_NORM )
    
SetSentryLevel sentryiLevel )
    
entity_set_float sentryEV_FL_healthg_HEALTHS[iLevel] )
    
entity_set_float entity_get_edict sentrySENTRY_ENT_BASE ), EV_FL_healthg_HEALTHS[0] )
    
SetSentryPeople sentryiUpgraderFieldid )
    
    new 
sName[32]
    
get_user_name idsNamecharsmax sName ) )
    
client_print GetSentryPeople sentryOWNER ), print_center"%s прокачал твою пушку до уровня %d"sNameiLevel )
    return 
true
}

stock EntViewHitPoint indexFloat:origin[3], Float:hitorigin[3] )
{
    if ( !
is_valid_ent index ) )
        return 
0

    
new Float:angle[3], Float:vec[3], Float:f_dest[3]

    
entity_get_vector(indexEV_VEC_anglesangle)

    
engfunc(EngFunc_AngleVectorsanglevec00)

    
f_dest[0] = origin[0] + vec[0] * 9999
    f_dest
[1] = origin[1] + vec[1] * 9999
    f_dest
[2] = origin[2] + vec[2] * 9999

    
return trace_line(indexoriginf_desthitorigin)
}

public 
fw_PlayerSpawn_Post id )
{
    if ( !
is_user_alive id ) )
        return

    
g_inBuilding[id] = false

    
while ( GetSentryCount id ) > )
        
sentry_detonate_by_owner idtrue )

    
ammo_hud id)
    
sentries_num[id] = 0
}

public 
fw_TraceLine_Post Float:start[3], Float:end[3], noMonstersid )
{
    if ( !
is_valid_player id ) || !is_user_alive id ) )
        return 
FMRES_IGNORED

    
new iHitEnt get_tr TR_pHit )

    if ( 
iHitEnt <= g_iMaxPlayers )
        return 
FMRES_IGNORED

    
new sClassName[11], sentrybase

    pev 
iHitEntpev_classnamesClassNamecharsmax sClassName ) )

    if ( 
equal sClassName"sentrybase" ) )
    {
        
base iHitEnt
        sentry 
entity_get_edict iHitEntBASE_ENT_SENTRY )
    }
    else if ( 
equal sClassName"sentry" ) )
    {
        
sentry iHitEnt
        base 
entity_get_edict sentrySENTRY_ENT_BASE )
    }

    if ( !
pev_valid sentry ) || !base )
        return 
FMRES_IGNORED
        
    
if ( GetSentryFiremode sentry ) == SENTRY_FIREMODE_NUTS )
             return 
FMRES_IGNORED
         
    
new Float:health entity_get_float sentryEV_FL_health )

    if ( 
health <= )
        return 
FMRES_IGNORED

    
new Float:basehealth entity_get_float baseEV_FL_health )

    if ( 
basehealth <= )
        return 
FMRES_IGNORED

    
new CsTeams:team GetSentryTeam sentry )

    if ( 
team != cs_get_user_team id ) )
        return 
FMRES_IGNORED

    
new level GetSentryLevel sentry )

    static 
tempStatusBuffer[192], tempStatusBuffer2[192]

    new 
OwnName[33]
    
get_user_name GetSentryPeople sentryOWNER ), OwnName32 )
    
    
formatex tempStatusBuffercharsmax tempStatusBuffer ), "Установил: %s^nЗдоровье: %d/%d"OwnNamefloatround(health), floatround(g_HEALTHS[level]) )
    
formatex tempStatusBuffer2charsmax tempStatusBuffer2 ), "^n^nЗдоровье основания: %d/%d^nУровень: %d"floatround(basehealth), floatround(g_HEALTHS[0]), level )

    
set_dhudmessage _:team == 150 00_:team == 150 0, -1.00.3500.00.60.00.0 )
    
show_dhudmessage(idtempStatusBuffer)
    
show_dhudmessage(idtempStatusBuffer2)

    return 
FMRES_IGNORED
}

// прикосновение к пушке игрока
public fw_TouchSentry sentryplayer ) { SentryUpgrade playersentry ); }

ammo_hud(idsw)
{
    if(
is_user_bot(id)||!is_user_alive(id)||!is_user_connected(id)) 
            return

    new 
s_sprite[33]
    
format(s_sprite32"number_%d"sentries_num[id])
    if(
sw)
    {
        
message_beginMSG_ONEgMsgID, {0,0,0}, id )
        
write_byte// status
        
write_strings_sprite // sprite name
        
write_byte250 // red
        
write_byte250 // green
        
write_byte250 // blue
        
message_end()
    }
    else 
    {
        
message_beginMSG_ONEgMsgID, {0,0,0}, id )
        
write_byte// status
        
write_strings_sprite // sprite name
        
write_byte250 // red
        
write_byte250 // green
        
write_byte250 // blue
        
message_end()
    }
    if(
sentries_num[id] <= 0)
    {
        
message_beginMSG_ONEgMsgID, {0,0,0}, id )
        
write_byte// status
        
write_strings_sprite // sprite name
        
write_byte250 // red
        
write_byte250 // green
        
write_byte250 // blue
        
message_end()
    }    
}

stock ChatColor(const id, const input[], any:...)
{
        new 
count 1players[32]
        static 
msg[191]
        
vformat(msg190input3)
       
        
replace_all(msg190"!g""^4"// Green Color
        
replace_all(msg190"!y""^1"// Default Color
        
replace_all(msg190"!team""^3"// Team Color
        
replace_all(msg190"!team2""^0"// Team2 Color
       
        
if (idplayers[0] = id; else get_players(playerscount"ch")
        {
                for (new 
0counti++)
                {
                        if (
is_user_connected(players[i]))
                        {
                                
message_begin(MSG_ONE_UNRELIABLEget_user_msgid("SayText"), _players[i])
                                
write_byte(players[i]);
                                
write_string(msg);
                                
message_end();
                        }
                }
        }
}

bool:IsInSphere id )
{
    if ( !
is_user_alive id ) )
        return 
false

    
new ent = -
    
while ( ( ent engfunc EngFunc_FindEntityByStringent"classname""campo_grenade_forze" ) ) > )
    {
        new 
iOwner pev entpev_owner )

        if ( 
cs_get_user_team id ) != cs_get_user_team iOwner ) )
            continue

        new 
Float:fOrigin[3]
        
pev entpev_originfOrigin )
        new 
iPlayer = -1
        
while ( ( iPlayer engfunc EngFunc_FindEntityInSphereiPlayerfOrigin68.0 ) ) != )
        {
            if ( 
iPlayer == id )
                return 
true
        
}
    }
    return 
false
}

//
// Launch rocket from 4lvl sentry
//    data[2]
//        0 - sentry id
//        1 - side    // 0 - right, 1 - left
//
public ShootRockets(data[2]){
    new 
sentry data[0]
    new 
side data[1]
    
    new 
Float:rocketOrigin[3],Float:rocketAngles[3]
    
    
entity_get_vector(sentry,EV_VEC_angles,rocketAngles)
    
engfunc(EngFunc_MakeVectors,rocketAngles)
    
    new 
Float:vecForward[3],Float:vecRight[3],Float:vecUp[3]
    
    
get_global_vector(GL_v_forward,vecForward)
    
xs_vec_mul_scalar(vecForward,20.0,vecForward)
    
    
get_global_vector(GL_v_right,vecRight)
    
xs_vec_mul_scalar(vecRight,side 8.0 : -8.0,vecRight// right or left rocket
    
    
get_global_vector(GL_v_up,vecUp)
    
xs_vec_mul_scalar(vecUp,30.0,vecUp)
    
    
entity_get_vector(sentry,EV_VEC_origin,rocketOrigin)
    
xs_vec_add(rocketOrigin,vecForward,rocketOrigin)
    
xs_vec_add(rocketOrigin,vecRight,rocketOrigin)
    
xs_vec_add(rocketOrigin,vecUp,rocketOrigin)
    
    
// shot rocket
    
CreateRocket(sentry,rocketOrigin,rocketAngles,GetSentryPeople(sentry,TARGET))
    
    
data[1] = 1
    
    
if(!side// shot left rocket
        
set_task(0.2,"ShootRockets",_,data,sizeof data)
}

//
// Launch RPG rocket
//    sentry - sentry id
//    origin - rocket origin
//    angles - sentry angles
//    traget - rocket target id
//
CreateRocket(sentry,Float:origin[3],Float:angles[3],target){
    new 
rocket create_entity("info_target")
    
    
entity_set_string(rocket,EV_SZ_classname,"rpg_rocket")
    
    
entity_set_int(rocket,EV_INT_movetype,MOVETYPE_FLY)
    
entity_set_int(rocket,EV_INT_solid,SOLID_BBOX)
    
    
entity_set_edict(rocket,EV_ENT_owner,sentry)
    
entity_set_edict(rocket,EV_ENT_euser4,GetSentryPeople(sentry,OWNER))
    
    
entity_set_size(rocket,Float:{-2.0,-2.0,-2.0},Float:{2.0,2.0,2.0})
    
entity_set_origin(rocket,origin)
    
    new 
Float:targetOrigin[3]
    
entity_get_vector(target,EV_VEC_origin,targetOrigin)
    
angles[0] = -GetAngleOrigins(origin,targetOrigin)
    
entity_set_model(rocket,"models/rpgrocket.mdl")
    
entity_set_vector(rocket,EV_VEC_angles,angles)
    
    
engfunc(EngFunc_MakeVectors,angles)
    
    new 
Float:vecVelocity[3]
    
get_global_vector(GL_v_forward,vecVelocity)
    
xs_vec_mul_scalar(vecVelocity,1000.0,vecVelocity)
    
entity_set_vector(rocket,EV_VEC_velocity,vecVelocity)
    
    
entity_set_int(rocket,EV_INT_effects,entity_get_int(rocket,EV_INT_effects) | EF_LIGHT)
    
    
// rocket trail
    
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
    
write_byte(TE_BEAMFOLLOW)
    
write_short(rocket)
    
write_short(m_iTrail)
    
write_byte(10)
    
write_byte(5)
    
write_byte(224)
    
write_byte(224)
    
write_byte(255)
    
write_byte(255)
    
message_end()
    
    
emit_sound(rocket,CHAN_VOICE,"weapons/rocket1.wav",1.0,0.5,0,PITCH_NORM)
}

public 
fw_RpgTouch(rocket,ent){
    new 
Float:origin[3],Float:angles[3],Float:vecPlaneNormal[3]
    
entity_get_vector(rocket,EV_VEC_origin,origin)
    
entity_get_vector(rocket,EV_VEC_angles,angles)
    
    
engfunc(EngFunc_MakeVectors,angles)
    
get_global_vector(GL_v_forward,angles)
    
xs_vec_mul_scalar(angles,9999.0,angles)
    
xs_vec_add(origin,angles,angles)
    
engfunc(EngFunc_TraceLine,origin,angles,0,rocket,0)
    
    
get_tr2(0,TR_vecEndPos,origin)
    
    
message_begin_f(MSG_BROADCAST,SVC_TEMPENTITY,origin,0)
    
write_byte(TE_WORLDDECAL)
    
write_coord_f(origin[0])
    
write_coord_f(origin[1])
    
write_coord_f(origin[2])
    
write_byte(expDecal)
    
message_end()
    
    
get_tr2(0,TR_vecPlaneNormal,vecPlaneNormal)
    
    
xs_vec_mul_scalar(vecPlaneNormal,8.0,vecPlaneNormal)
    
xs_vec_add(origin,vecPlaneNormal,origin)
    
    
message_begin_f(MSG_PVS,SVC_TEMPENTITY,origin,0)
    
write_byte(TE_EXPLOSION)
    
write_coord_f(origin[0])
    
write_coord_f(origin[1])
    
write_coord_f(origin[2])
    
write_short(g_sModelIndexFireball)
    
write_byte(20)
    
write_byte(15)
    
write_byte(0)
    
message_end()
    
    
shit_radiusdamage(rocket,origin)
    
    
emit_sound(rocket,CHAN_VOICE,"weapons/rocket1.wav",0.0,ATTN_NORM,SND_STOP,0)
    
    
remove_entity(rocket)
}

// this very bad method
stock shit_radiusdamage(rocket,Float:origin_[3]) {
    new 
origin[3]
    
FVecIVec(origin_origin)
    
    new 
attacker entity_get_edict(rocket,EV_ENT_euser4)
    
    if(!
is_user_connected(attacker))
        return


    new 
Float:playerOrigin[3], Float:distanceFloat:flDmgToDoFloat:dmgbase RPG_DAMAGE
    
for (new 1<= g_iMaxPlayersi++) {
        if (!
is_user_alive(i) || get_user_godmode(i) || get_user_team(i) == get_user_team(attacker)) 
            continue

        
entity_get_vector(iEV_VEC_originplayerOrigin)
        
distance vector_distance(playerOriginorigin_)
        if (
distance <= RPG_RADIUS) {
            
flDmgToDo dmgbase - (dmgbase * (distance RPG_RADIUS))
            
            
// zemletryasenie!!111
            
Util_ScreenShake(i,0.5,16.0,16.0)
            
rocket_damagetoplayer(rocket,origin_,i,flDmgToDo)
        }
    }
}
// ScreenShake
stock Util_ScreenShake(idFloat:durationFloat:frequencyFloat:amplitude)
{
    static 
ScreenShake 0;
    if( !
ScreenShake )
    {
        
ScreenShake get_user_msgid("ScreenShake");
    }
    
message_beginid MSG_ONE_UNRELIABLE MSG_BROADCASTScreenShake_id);
    
write_shortFixedUnsigned16amplitude1<<12 ) ); // shake amount
    
write_shortFixedUnsigned16duration1<<12 ) ); // shake lasts this long
    
write_shortFixedUnsigned16frequency1<<) ); // shake noise frequency
    
message_end();
}

// урон игроку
stock rocket_damagetoplayer(rocketFloat:sentryOrigin[3], targetFloat:dmg) {
    new 
sentry entity_get_edict(rocket,EV_ENT_owner)
    new 
sentryLevel GetSentryLevel(sentry)
    
    new 
newHealth get_user_health(target) - floatround(dmg)

    if (
newHealth <= 0) {
        new 
targetFrags get_user_frags(target) + 1
        
new owner GetSentryPeople(sentryOWNER)
        
        if(!
is_user_connected(owner))
            return
        
        new 
ownerFrags get_user_frags(owner) + 1
        set_user_frags
(targettargetFrags// otherwise frags are subtracted from victim for dying (!!)
        
set_user_frags(ownerownerFrags)
        
        new 
contributors[4]
        
contributors[0] = owner
        contributors
[1] = GetSentryPeople(sentryUPGRADER_1)
        
contributors[2] = GetSentryPeople(sentryUPGRADER_2)
        
contributors[3] = GetSentryPeople(sentryUPGRADER_3)
        
        for(new 
sizeof contributors i++){
            if(!
contributors[i])
                continue
                
            if(!
is_user_connected(contributors[i]) || get_user_team(contributors[i]) != get_user_team(contributors[0])){
                switch(
i){ // yao face
                    
case 1SetSentryPeople(sentry,UPGRADER_1,0)
                    case 
2SetSentryPeople(sentry,UPGRADER_2,0)
                    case 
3SetSentryPeople(sentry,UPGRADER_3,0)
                }
                
                continue
            }
            
            
// izvini 4yvak, no menya nakrilo
            
cs_set_user_money(contributors[i],
                
clamp(
                    
cs_get_user_money(contributors[i]) + (== SENTRYOWNERAWARD SENTRYASSISTAWARD),
                    
0,
                    
16000
                
)
            )
        }

        
// ny ebatb kakoy frag
        
message_begin(MSG_ALLg_msgDeathMsg, {000} ,0)
        
write_byte(owner)
        
write_byte(target)
        
write_byte(0)
        
write_string("sentry gun")
        
message_end()

        
scoreinfo_update(ownerownerFragscs_get_user_deaths(owner), int:cs_get_user_team(owner))
        
set_msg_block(g_msgDeathMsgBLOCK_ONCE)
    }

    
set_user_health(targetnewHealth)

    
message_begin(MSG_ONE_UNRELIABLEg_msgDamage, {0,0,0}, target)
    
write_byte(g_DMG[sentryLevel])
    
write_byte(g_DMG[sentryLevel])
    
write_long(DMG_BLAST)
    
write_coord(floatround(sentryOrigin[0]))
    
write_coord(floatround(sentryOrigin[1]))
    
write_coord(floatround(sentryOrigin[2]))
    
message_end()
}

stock FixedUnsigned16Float:valuescale )
{
    new 
output;

    
output floatround(value scale);
    if ( 
output )
        
output 0;
    if ( 
output 0xFFFF )
        
output 0xFFFF;

    return 
output;
}

FloatGetAngleOrigins(Float:fOrigin1[3], Float:fOrigin2[3] )
{
    new 
Float:fVector[3];
    new 
Float:fAngle[3];
    new 
Float:fLineAngle;
    
    
xs_vec_sub(fOrigin2fOrigin1fVector);
    
vector_to_angle(fVectorfAngle);
    
    if( 
fAngle[0] > 90.0 )
        
fLineAngle = -(360.0 fAngle[0]);
    else
        
fLineAngle fAngle[0]; 

Неинформативное название, неверный раздел, Вы должны зарегистрироваться, чтобы видеть ссылки.. Закрыто // Subb98
Аватара пользователя
Phubaxz
 
Сообщения: 14
Зарегистрирован: 07 дек 2016, 11:14
Предупреждения: 5
Благодарил (а): 6 раз.
Поблагодарили: 1 раз.
Языки программирования: Pawn
SourcePawn
C++
Php
Ruby
Python
C#

Re: Скачал скрипт он не работает сидел Плиз

Сообщение Subb98 » 07 дек 2016, 14:03

Добрый день. Пожалуйста, придумайте более информативное название для вашей темы (в соответствии Вы должны зарегистрироваться, чтобы видеть ссылки.) и сообщите мне его в ЛС, после чего будет рассмотрена возможность открытия вашей темы вновь. А также сообщите, в каком разделе Вы должны были создать эту тему.

Неинформативное название темы, неверный раздел, тема закрыта
По возможности принимаю небольшие заказы. $ Дорого.
Аватара пользователя
Subb98
Модератор
 
Сообщения: 4001
Зарегистрирован: 24 мар 2011, 19:42
Откуда: г. Пермь
Благодарил (а): 1175 раз.
Поблагодарили: 1937 раз.
Опыт программирования: Больше трех лет
Языки программирования: Pawn, PHP

Скрипт Сентра Буилд с 4 апамя нерабочий

Сообщение Phubaxz » 08 дек 2016, 17:46

Код: Выделить всё
#include <amxmodx>
#include <engine>
#include <fun>
#include <cstrike>
#include <fakemeta>
#include <hamsandwich>
#include <xs>

#if AMXX_VERSION_NUM < 183
    #define message_begin_f(%0,%1,%2,%3)    engfunc(EngFunc_MessageBegin,%0,%1,%2,%3)
    #define write_coord_f(%0)        engfunc(EngFunc_WriteCoord,%0)
    
    
#include <dhudmessage>
#endif


native sh_set_hero ( id )
native give_shield_grenade ( id )


#define is_valid_player(%1) ( 1 <= %1 <= g_iMaxPlayers )
#define is_valid_team(%1) ( 0 < %1 < 3 )

#define is_entity_on_ground(%1) ( entity_get_int ( %1, EV_INT_flags ) & FL_ONGROUND )

// сколько пушек у игрока уже построено
#define GetSentryCount(%1) g_iPlayerSentries[%1]

#define MAXUPGRADERANGE        75.0
#define SENTRYEXPLODERADIUS        250.0            // радиус отброса при взрыве
#define SENTRYTILTRADIUS            830.0            // likely you won't need to touch this. it's how accurate the cannon will aim at the target vertically (up/down, just for looks, aim is calculated differently)

#define SENTRYMINDISTANCE    256.0

#define MAXSENTRIES                32 * 3

#define TASK_GODMODE 114455

#define SENTRY_INT_PEOPLE        EV_INT_iuser2 // max 5 users using 6 bits!
#define SENTRY_INT_UGPRADERS        EV_INT_iuser3
#define SENTRY_PEOPLE_BITS        6
#define OWNER                    0
#define UPGRADER_1                1
#define UPGRADER_2                2
#define TARGET                    3
#define UPGRADER_3                4
#define MASK_OWNER                0xFFFFFFC0 // 11111111111111111111111111000000
#define MASK_UPGRADER_1            0xFFFFF03F // 11111111111111111111000000111111
#define MASK_UPGRADER_2            0xFFFC0FFF // 11111111111111000000111111111111
#define MASK_TARGET                0xFF03FFFF // 11111111000000111111111111111111
#define MASK_UPGRADER_3                0xC0FFFFFF // 11000000111111111111111111111111
new const MASKS_PEOPLE[5] = {MASK_OWNER, MASK_UPGRADER_1, MASK_UPGRADER_2, MASK_TARGET, MASK_UPGRADER_3}

GetSentryPeople(const SENTRY, const WHO) {
    new data = entity_get_int(SENTRY, SENTRY_INT_PEOPLE)
    data |= MASKS_PEOPLE[WHO]
    data ^= MASKS_PEOPLE[WHO]
    data = (data>>(WHO*SENTRY_PEOPLE_BITS))
    return data
}
SetSentryPeople(const SENTRY, const WHO, const IS) {
    new data = entity_get_int(SENTRY, SENTRY_INT_PEOPLE)
    data &= MASKS_PEOPLE[WHO] // nullify the setting
    data |= (IS<<(WHO*SENTRY_PEOPLE_BITS)) // set the setting
    entity_set_int(SENTRY, SENTRY_INT_PEOPLE, data) // store
}

#define SENTRY_INT_SETTINGS        EV_INT_iuser1
#define SENTRY_ROCKET_TIME        EV_FL_teleport_time
#define SENTRY_SETTINGS_BITS    2
#define SENTRY_SETTING_FIREMODE    0
#define SENTRY_SETTING_TEAM        1
#define SENTRY_SETTING_LEVEL    2
#define SENTRY_SETTING_PENDDIR    3
#define MASK_FIREMODE            0xFFFFFFFC // 11111111111111111111111111111100 = FFFFFFFC
#define MASK_TEAM                0xFFFFFFF3 // 11111111111111111111111111110011 = FFFFFFF3
#define MASK_LEVEL                0xFFFFFFCF // 11111111111111111111111111001111 = FFFFFFCF
#define MASK_PENDDIR            0xFFFFFF3F // 11111111111111111111111100111111 = FFFFFF3F
new const MASKS_SETTINGS[4] = {MASK_FIREMODE, MASK_TEAM, MASK_LEVEL, MASK_PENDDIR}

GetSentrySettings(const SENTRY, const SETTING) {
    new data = entity_get_int(SENTRY, SENTRY_INT_SETTINGS)
    data |= MASKS_SETTINGS[SETTING]
    data ^= MASKS_SETTINGS[SETTING]
    //data = (data>>(SETTING*SENTRY_SETTINGS_BITS))
    return (data>>(SETTING*SENTRY_SETTINGS_BITS))
}
SetSentrySettings(const SENTRY, const SETTING, const VALUE) {
    new data = entity_get_int(SENTRY, SENTRY_INT_SETTINGS)
    data &= MASKS_SETTINGS[SETTING] // nullify the setting
    //data |= (VALUE<<(SETTING*SENTRY_SETTINGS_BITS)) // set the setting
    entity_set_int(SENTRY, SENTRY_INT_SETTINGS, data | (VALUE<<(SETTING*SENTRY_SETTINGS_BITS))) // store
}

GetSentryFiremode(const SENTRY) {
    return GetSentrySettings(SENTRY, SENTRY_SETTING_FIREMODE)
}
SetSentryFiremode(const SENTRY, const MODE) {
    SetSentrySettings(SENTRY, SENTRY_SETTING_FIREMODE, MODE)
}
CsTeams:GetSentryTeam(const SENTRY) {
    return CsTeams:GetSentrySettings(SENTRY, SENTRY_SETTING_TEAM)
}
SetSentryTeam(const SENTRY, const CsTeams:TEAM) {
    SetSentrySettings(SENTRY, SENTRY_SETTING_TEAM, int:TEAM)
}
GetSentryLevel(const SENTRY) {
    return GetSentrySettings(SENTRY, SENTRY_SETTING_LEVEL)
}
SetSentryLevel(const SENTRY, const LEVEL) {
    SetSentrySettings(SENTRY, SENTRY_SETTING_LEVEL, LEVEL)
}
GetSentryPenddir(const SENTRY) {
    return GetSentrySettings(SENTRY, SENTRY_SETTING_PENDDIR)
}
SetSentryPenddir(const SENTRY, const PENDDIR) {
    SetSentrySettings(SENTRY, SENTRY_SETTING_PENDDIR, PENDDIR)
}

#define SENTRY_ENT_BASE            EV_ENT_euser1

#define SENTRY_FL_ANGLE            EV_FL_fuser1
#define SENTRY_FL_SPINSPEED        EV_FL_fuser2
#define SENTRY_FL_MAXSPIN        EV_FL_fuser3
#define SENTRY_FL_LASTTHINK        EV_FL_fuser4

#define SENTRY_DIR_CANNON        0

#define BASE_ENT_SENTRY            EV_ENT_euser1
#define BASE_INT_TEAM            EV_INT_iuser1

#define SENTRY_LEVEL_1            0
#define SENTRY_LEVEL_2            1
#define SENTRY_LEVEL_3            2
#define SENTRY_LEVEL_4            3
#define SENTRY_FIREMODE_NO        0
#define SENTRY_FIREMODE_YES        1
#define SENTRY_FIREMODE_NUTS    2
#define TARGETUPMODIFIER            18.0 // if player ducks on ground, traces don't hit...
#define DMG_BULLET                (1<<1)    //выстрел
#define DMG_BLAST                (1<<6)    // explosive blast damage
#define TE_EXPLFLAG_NONE        0
#define TE_EXPLOSION                3
#define TE_TRACER                6
#define TE_BREAKMODEL            108
#define PENDULUM_MAX            45.0 // how far sentry turret turns in each direction when idle, before turning back
#define PENDULUM_INCREMENT        10.0 // speed of turret turning...
#define SENTRYSHOCKPOWER        3.0 // multiplier, increase to make exploding sentries throw stuff further away
#define CANNONHEIGHTFROMFEET    20.0 // tweakable to make tracer originate from the same height as the sentry's cannon. Also traces rely on this Y-wise offset.
#define PLAYERORIGINHEIGHT        36.0 // this is the distance from a player's EV_VEC_origin to ground, if standing up
#define HEIGHTDIFFERENCEALLOWED    20.0 // increase value to allow building in slopes with higher angles. You can set to 0.0 and you will only be able to build on exact flat ground. note: mostly applies to downhill building, uphill is still likely to "collide" with ground...

#define PLACE_RANGE 45.0

#define SENTRY_RADAR            20 // use as high as possible but should still be working (ie be able to see sentries plotted on radar while in menu, too high values doesn't seem to work)
#define SENTRY_RADAR_TEAMBUILT    21 // same as above

#define RPG_RADIUS    250.0
#define RPG_DAMAGE    150.0
#define RPG_DISTANCE    400.0

new const szModels[][] =
{
    "models/dmsentries/base.mdl",
    "models/dmsentries/sentry1_t.mdl",
    "models/dmsentries/sentry2_t.mdl",
    "models/dmsentries/sentry3_t.mdl",
    "models/dmsentries/sentry1_ct.mdl",
    "models/dmsentries/sentry2_ct.mdl",
    "models/dmsentries/sentry3_ct.mdl",
    "models/rpgrocket.mdl",
    "models/computergibs.mdl"
}

new const szSounds[][] =
{
    "debris/bustmetal1.wav",
    "debris/bustmetal2.wav",
    "debris/metal1.wav",
    "debris/metal3.wav",
    "dmsentries/turridle.wav",
    "dmsentries/turrset.wav",
    "dmsentries/turrspot.wav",
    "dmsentries/building.wav",
    "dmsentries/fire.wav",
    "weapons/rocket1.wav"
}

new expDecal

#define SENTRYOWNERAWARD    300
#define SENTRYASSISTAWARD    150

new const g_DMG[4] = {5, 10, 15, 15}                                // количество урона от пушки в зависимости от ее уровня
new const Float:g_THINKFREQUENCIES[4] = {2.0, 1.0, 0.5, 0.5}        // через сколько захватывается цель
new const Float:g_HITRATIOS[4] = {0.6, 0.75, 0.85, 0.85}            // разброс
new const Float:g_HEALTHS[4] = {3000.0, 6000.0, 9000.0, 10000.0}    // сколько хп у пушки в зависимости от ее уровня (верхняя часть)
new const g_COST[4] = {3000, 600, 600, 16000}                        // стоимость установки/улучшения пушек
new const g_SENTRYCOST[3] = {3000, 3500, 4000}                            // стоимость установки/улучшения пушек
#define g_sentriesNum (g_teamsentriesNum[0]+g_teamsentriesNum[1])
new g_teamsentriesNum[2]    
new g_sentries
[MAXSENTRIES]
new g_iPlayerSentries[33]
new g_iPlayerSentriesEdicts[33][3]
new g_sModelIndexFireball
new g_msgDamage
new g_msgDeathMsg
new g_msgScoreInfo
new g_msgHostagePos
new g_msgHostageK
new g_iMaxPlayers
new Float
:g_ONEEIGHTYTHROUGHPI
new Float
:g_sentryOrigins[32][3]
new bool:g_inBuilding[33]
new sentries_num[33]
new gMsgID
new g_iTimer
[33]
new m_iTrail

public plugin_init
() {

    register_plugin("Sentry guns", "1.1", "JGHG & miRror")

    register_event ( "Spectator", "ev_Spectation", "a" )

    register_clcmd("sentry_build", "cmd_CreateSentry", 0, "- build a sentry gun where you are")
    register_clcmd("say /sgstats", "sgstats", 0, "- stats sentry")
    register_clcmd("say /forcesh", "givesgr")
    
    RegisterHam 
( Ham_Spawn, "player", "fw_PlayerSpawn_Post", 1 )

    register_forward ( FM_TraceLine, "fw_TraceLine_Post", 1 )

    RegisterHam ( Ham_TakeDamage, "func_breakable", "fw_TakeDamage" )
    
    register_touch 
( "sentry", "player", "fw_TouchSentry" )
    register_touch("rpg_rocket","*","fw_RpgTouch")
    
    register_message 
( 23, "msg_TempEntity" )
    register_think("sentrybase", "think_sentrybase")
    register_think ( "sentry", "fw_ThinkSentry" )

    g_msgDamage = get_user_msgid("Damage")
    g_msgDeathMsg = get_user_msgid("DeathMsg")
    g_msgScoreInfo = get_user_msgid("ScoreInfo")
    g_msgHostagePos = get_user_msgid("HostagePos")
    g_msgHostageK = get_user_msgid("HostageK")
    gMsgID = get_user_msgid("StatusIcon")
    
    g_iMaxPlayers 
= get_global_int(GL_maxClients)
    g_ONEEIGHTYTHROUGHPI = 180.0 / 3.141592654
    
    expDecal 
= get_decal_index("{scorch1")

    set_task ( 120.0, "checkhero", .flags = "b" )
}

public plugin_precache() {
    for(new i=0;i<sizeof(szModels);i++)
        precache_model(szModels[i])
    for(new i=0;i<sizeof(szSounds);i++)
        precache_sound(szSounds[i])
    g_sModelIndexFireball = precache_model("sprites/zerogxplode.spr")
    m_iTrail = precache_model("sprites/smoke.spr")
}

public plugin_natives ()
{
    register_native ( "get_sentry_people", "native_get_sentry_people", 1 )
    register_native ( "get_sentry_team", "native_get_sentry_team", 1 )
}

public native_get_sentry_people ( sentry, who )
{
    return GetSentryPeople ( sentry, who )
}

public CsTeams:native_get_sentry_team ( sentry )
{
    return GetSentryTeam ( sentry )
}

public sgstats(id)
{
    ChatColor ( id, "^1Пушек у КТ: [ ^4%