Поиск Grenade Trail

Статус
В этой теме нельзя размещать новые ответы.

iOS

Сообщения
323
Реакции
100
Помог
5 раз(а)
Всем привет, ищу плагин "Цветной шлейф за гранатой" , знаю куча таких. Но хотелось бы, с самым лучшим кодом =)
 

iOS

Сообщения
323
Реакции
100
Помог
5 раз(а)
Та ну, полегче бы код)
12 Дек 2017
Нужен просто обычный плагин, без настроек.
 
Сообщения
1,536
Реакции
2,319
Помог
39 раз(а)
iOS, раз вы так хорошо разбираетесь в коде, то укажите нам "тяжелые" места.
 

iOS

Сообщения
323
Реакции
100
Помог
5 раз(а)
iOS, раз вы так хорошо разбираетесь в коде, то укажите нам "тяжелые" места.
Кто вам сказал что я разбираюсь в коде? Просто видел, такой плагин на 100 строк максимум. А этот на 600. + Не использую модуль csx.
 
Сообщения
96
Реакции
84
Помог
2 раз(а)
iOS, если там вырезать всё что касается шлейфа, то останется только amxmisc, и навскидку, строк 70
 
Сообщения
1,536
Реакции
2,319
Помог
39 раз(а)
iOS, вы сами и сказали:
Но хотелось бы, с самым лучшим кодом =)
Та ну, полегче бы код)
Я делаю вывод, что можете компетентно оценить плагин и его логику реализации.
Просто видел, такой плагин на 100 строк максимум. А этот на 600. + Не использую модуль csx.
Но как видно, вы простой потребитель, который ничего не понимает и смотрит на кол-во строк и думает, что если их меньше-значит плагин лучше.

Поэтому воздержитесь от фраз, которые связаны с оценкой кода, раз в этом ничего не смыслите.
 
Сообщения
133
Реакции
441
Помог
2 раз(а)
Та ну, полегче бы код)
12 Дек 2017
Нужен просто обычный плагин, без настроек.
Код:
#include <amxmodx>
#include <csx>

new g_trail

public plugin_precache()
{
    g_trail = precache_model("sprites/smoke.spr")
}

public grenade_throw(id, iGrenade, iWeapon)
{
    message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, id)
    write_byte(TE_BEAMFOLLOW)
    write_short(iGrenade)
    write_short(g_trail)
    write_byte(10)
    write_byte(5)
    write_byte(100)
    write_byte(100)
    write_byte(100)
    write_byte(192)
    message_end()
}
и в следующий раз открой гугл, введи запрос и шерсти по всем форумам, и ищи.
https://forums.alliedmods.net/showthread.php?p=1443603 - сам бы использовал этот плагин.
 

iOS

Сообщения
323
Реакции
100
Помог
5 раз(а)
Код:
#include <amxmodx>
#include <csx>

new g_trail

public plugin_precache()
{
    g_trail = precache_model("sprites/smoke.spr")
}

public grenade_throw(id, iGrenade, iWeapon)
{
    message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, id)
    write_byte(TE_BEAMFOLLOW)
    write_short(iGrenade)
    write_short(g_trail)
    write_byte(10)
    write_byte(5)
    write_byte(100)
    write_byte(100)
    write_byte(100)
    write_byte(192)
    message_end()
}
и в следующий раз открой гугл, введи запрос и шерсти по всем форумам, и ищи.
https://forums.alliedmods.net/showthread.php?p=1443603 - сам бы использовал этот плагин.
Не использую модуль csx.
12 Дек 2017
благодарю.
 
Сообщения
2,143
Реакции
1,223
Помог
44 раз(а)
Один think тебе может дать большую нагрузку, хоть это и несколько строчек.
 

iOS

Сообщения
323
Реакции
100
Помог
5 раз(а)
В чём причина такой ненависти к csx?
Вы же не думаете, что чем больше модулей, то тем больше нагрузка?
просто вместо него у меня dummy_csx, а ради одного плагина подгружать ещё один модуль, не охота.
 
Сообщения
496
Реакции
618
Помог
16 раз(а)
Нагрузка на ядро не зависит от числа подключенных модулей amxx.
Они просто висят в оперативе, коей у вас скорее всего с запасом.
 
Сообщения
2,720
Реакции
2,997
Помог
60 раз(а)
с самым лучшим кодом
а, по поводу CSX - не неси бред. Есть ещё вариант на FM || Ham сделать, но такой "хернёй" - здесь маяться никто не будет. :negative:
Код:
/**
* Modified by Safety1st
*
* - ability to disable color trail for particular grenade type. Set appropriate cvar to "0" for that.
* - another suggested colors
**/

/**
 *
 * Team Grenade Trail
 *  by Numb
 *
 *
 * Description
 *  This plugin adds a trail after the grenade. Each type of grenade has an unique
 *  color what can be changed by cvar. Unlike other grenade trail plugins, this one
 *  has two major differences. First is that trails are actually made out of arrows
 *  what show direction in what grenade is moving (so now if you came out of corner
 *  and see a trail - you can instantly tell where to expect grenade to be). Second
 *  and most important one is that by default only team mates can see trails of your
 *  thrown grenades (this gives you and your team mates advantage from misunderstandings
 *  - no more guessing did any of those 10 noobs behind you thrown flashes or what;
 *  but when it comes to enemy grenades - you still must spot the model of the grenade
 *  to see and identify grenade type).
 *
 *
 * Requires:
 *  CStrike
 *  CSX
 *
 *
 * Cvars:
 *
 *  + "amx_grentrail_status" - who can see the trail.
 *  - "3" - everyone.
 *  - "2" - team and everyone who's dead.
 *  - "1" - only team. [default]
 *  - "0" - plugin disabled.
 *
 *  + "amx_grentrail_color_fb" - flashbang trail color [rrrgggbbb].
 *  - "000255255" - red 0; 255 green; 255 blue [default].
 *
 *  + "amx_grentrail_color_he" - explosive trail color [rrrgggbbb].
 *  - "255063000" - red 255; 63 green; 0 blue [default].
 *
 *  + "amx_grentrail_color_sg" - smokegren trail color [rrrgggbbb].
 *  - "031255127" - red 31; 255 green; 127 blue [default].
 *
 *  + "amx_grentrail_team_color" - extra trail line with owners team color.
 *  - "1" - enabled.
 *  - "0" - disabled. [default]
 *
 *
 * Additional info:
 *  Tested in Counter-Strike 1.6 with amxmodx 1.8.2 (dev build hg21).
 *
 *
 * Credits:
 *  Original idea came from AssKicR's ( http://forums.alliedmods.net/member.php?u=261 )
 *  plugin ( http://forums.alliedmods.net/showthread.php?p=19096 ) what was published in
 *  2004/May/05. Method of showing trails taken from jim_yang's
 *  ( http://forums.alliedmods.net/member.php?u=19661 ) plugin
 *  ( http://forums.alliedmods.net/showthread.php?t=50171 ) what was published in 2007/Jan/21.
 *
 *
 * Change-Log:
 *
 *  + 1.2
 *  - Added: Support for team color trail (this is another smaller trail what has no effect on the main one).
 *  - Changed: Improved plugin performance.
 *  - Changed: Renamed "amx_grentrail_team" cvar to "amx_grentrail_status".
 *  - Changed: Renamed "amx_grentrail_color_sm" cvar to "amx_grentrail_color_sg".
 *
 *  + 1.1
 *  - Fixed: An issue with team detection once player team was changed by some custom plugin.
 *
 *  + 1.0
 *  - First release.
 *
 *
 * Downloads:
 *  Amx Mod X forums: http://forums.alliedmods.net/showthread.php?p=1443603#post1443603
 *
**/

// ----------------------------------------- CONFIG START -----------------------------------------

// If you are having problems, that not everyone who should see the trail is seeing them, that can
// be due to message type and ping. Using "MSG_ONE_UNRELIABLE" and "MSG_BROADCAST" is better for server
// stability, however using "MSG_ONE" and "MSG_ALL" garanties that client will recieve the update.
//#define MSG_TYPE_ALONE MSG_ONE // default: (uncommented)
#define MSG_TYPE_ALONE MSG_ONE_UNRELIABLE // default: (commented)
#define MSG_TYPE_ALL MSG_ALL // default: (uncommented)
//#define MSG_TYPE_ALL MSG_BROADCAST // default: (commented)

// ------------------------------------------ CONFIG END ------------------------------------------


#include <amxmodx>
#include <cstrike>
#include <csx>

#define PLUGIN_NAME    "Team Grenade Trail"
#define PLUGIN_VERSION    "1.2"
#define PLUGIN_AUTHOR    "Numb"

#define SetPlayerBit(%1,%2)    ( %1 |=  ( 1 << ( %2 & 31 ) ) )
#define ClearPlayerBit(%1,%2)  ( %1 &= ~( 1 << ( %2 & 31 ) ) )
#define CheckPlayerBit(%1,%2)  ( %1 &   ( 1 << ( %2 & 31 ) ) )

new g_iCvar_ColorFlash;
new g_iCvar_ColorHe;
new g_iCvar_ColorSmoke;
new g_iCvar_TrailStatus;
new g_iCvar_TeamColor;

new g_iSpriteLine;
new g_iSpriteArrow;

new g_iConnectedUsers;
new g_iDeadUsers;
new g_iMaxPlayers;

public plugin_precache()
{
    g_iSpriteArrow = precache_model("sprites/arrow1.spr");
    g_iSpriteLine  = precache_model("sprites/smoke.spr");
}

public plugin_init()
{
    register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);
    
    g_iCvar_TrailStatus = register_cvar("amx_grentrail_status", "1");
    
    g_iCvar_ColorFlash  = register_cvar("amx_grentrail_color_fb", "255255255");
    g_iCvar_ColorHe     = register_cvar("amx_grentrail_color_he", "150000000");
    g_iCvar_ColorSmoke  = register_cvar("amx_grentrail_color_sg", "000080000");
    
    g_iCvar_TeamColor   = register_cvar("amx_grentrail_team_color", "0");
    
    register_event("ResetHUD", "Event_ResetHUD", "be");
    register_event("Health",   "Event_Health",   "bd");
    
    g_iMaxPlayers = clamp(get_maxplayers(), 1, 32);
}

public client_connect(iPlrId)
{
    ClearPlayerBit(g_iConnectedUsers, iPlrId);
    ClearPlayerBit(g_iDeadUsers, iPlrId);
}

public client_putinserver(iPlrId)
{
    if( !is_user_bot(iPlrId) )
    {
        SetPlayerBit(g_iConnectedUsers, iPlrId);
        if( is_user_alive(iPlrId) )
            ClearPlayerBit(g_iDeadUsers, iPlrId);
        else
            SetPlayerBit(g_iDeadUsers, iPlrId);
    }
}

public client_disconnect(iPlrId)
{
    ClearPlayerBit(g_iConnectedUsers, iPlrId);
    ClearPlayerBit(g_iDeadUsers, iPlrId);
}

public Event_ResetHUD(iPlrId)
{
    if( CheckPlayerBit(g_iConnectedUsers, iPlrId) )
    {
        if( is_user_alive(iPlrId) )
            ClearPlayerBit(g_iDeadUsers, iPlrId);
        else
            SetPlayerBit(g_iDeadUsers, iPlrId);
    }
}

public Event_Health(iPlrId)
{
    if( CheckPlayerBit(g_iConnectedUsers, iPlrId) )
    {
        if( is_user_alive(iPlrId) )
            ClearPlayerBit(g_iDeadUsers, iPlrId);
        else
            SetPlayerBit(g_iDeadUsers, iPlrId);
    }
}

public plugin_unpause()
{
    g_iConnectedUsers = 0;
    g_iDeadUsers = 0;
    
    for( new iPlrId=1; iPlrId<=g_iMaxPlayers; iPlrId++ )
    {
        if( is_user_connected(iPlrId) )
        {
            if( !is_user_bot(iPlrId) )
            {
                SetPlayerBit(g_iConnectedUsers, iPlrId);
                if( !is_user_alive(iPlrId) )
                    SetPlayerBit(g_iDeadUsers, iPlrId);
            }
        }
    }
}

public grenade_throw(iPlrId, iGrenId, iWeaponType)
{
    new iTemp;
    switch( iWeaponType )
    {
        case CSW_FLASHBANG:    iTemp = get_pcvar_num(g_iCvar_ColorFlash);
        case CSW_HEGRENADE:    iTemp = get_pcvar_num(g_iCvar_ColorHe);
        case CSW_SMOKEGRENADE: iTemp = get_pcvar_num(g_iCvar_ColorSmoke);
        default: return;
    }
    
    if ( !iTemp )
        return
    
    new iRed = iTemp/1000000;
    iTemp %= 1000000;
    new iGreen = iTemp/1000;
    new iBlue = iTemp%1000;
    
    iTemp = clamp(get_pcvar_num(g_iCvar_TeamColor), 0, 1);
    
    switch( clamp(get_pcvar_num(g_iCvar_TrailStatus), 0, 3) )
    {
        case 1:
        {
            new CsTeams:iOwnerTeam = cs_get_user_team(iPlrId);
            
            for( new iPlayer=1; iPlayer<=g_iMaxPlayers; iPlayer++ )
            {
                if( CheckPlayerBit(g_iConnectedUsers, iPlayer) )
                {
                    if( cs_get_user_team(iPlayer)==iOwnerTeam )
                    {
                        message_begin(MSG_TYPE_ALONE, SVC_TEMPENTITY, _, iPlayer);
                        write_byte(TE_BEAMFOLLOW);
                        write_short(iGrenId);
                        write_short(g_iSpriteArrow);
                        write_byte(15);
                        write_byte(7);
                        write_byte(iRed);
                        write_byte(iGreen);
                        write_byte(iBlue);
                        write_byte(191);
                        message_end();
                        
                        if( iTemp )
                        {
                            message_begin(MSG_TYPE_ALONE, SVC_TEMPENTITY, _, iPlayer);
                            write_byte(TE_BEAMFOLLOW);
                            write_short(iGrenId);
                            write_short(g_iSpriteLine);
                            write_byte(15);
                            write_byte(1);
                            switch( iOwnerTeam )
                            {
                                case CS_TEAM_T:
                                {
                                    write_byte(255);
                                    write_byte(0);
                                    write_byte(0);
                                }
                                case CS_TEAM_CT:
                                {
                                    write_byte(0);
                                    write_byte(0);
                                    write_byte(255);
                                }
                                default:
                                {
                                    write_byte(127);
                                    write_byte(127);
                                    write_byte(127);
                                }
                            }
                            write_byte(191);
                            message_end();
                        }
                    }
                }
            }
        }
        case 2:
        {
            new CsTeams:iOwnerTeam = cs_get_user_team(iPlrId);
            
            for( new iPlayer=1; iPlayer<=g_iMaxPlayers; iPlayer++ )
            {
                if( CheckPlayerBit(g_iConnectedUsers, iPlayer) )
                {
                    if( CheckPlayerBit(g_iDeadUsers, iPlayer) || cs_get_user_team(iPlayer)==iOwnerTeam )
                    {
                        message_begin(MSG_TYPE_ALONE, SVC_TEMPENTITY, _, iPlayer);
                        write_byte(TE_BEAMFOLLOW);
                        write_short(iGrenId);
                        write_short(g_iSpriteArrow);
                        write_byte(15);
                        write_byte(7);
                        write_byte(iRed);
                        write_byte(iGreen);
                        write_byte(iBlue);
                        write_byte(191);
                        message_end();
                        
                        if( iTemp )
                        {
                            message_begin(MSG_TYPE_ALONE, SVC_TEMPENTITY, _, iPlayer);
                            write_byte(TE_BEAMFOLLOW);
                            write_short(iGrenId);
                            write_short(g_iSpriteLine);
                            write_byte(15);
                            write_byte(1);
                            switch( iOwnerTeam )
                            {
                                case CS_TEAM_T:
                                {
                                    write_byte(255);
                                    write_byte(0);
                                    write_byte(0);
                                }
                                case CS_TEAM_CT:
                                {
                                    write_byte(0);
                                    write_byte(0);
                                    write_byte(255);
                                }
                                default:
                                {
                                    write_byte(127);
                                    write_byte(127);
                                    write_byte(127);
                                }
                            }
                            write_byte(191);
                            message_end();
                        }
                    }
                }
            }
        }
        case 3:
        {
            message_begin(MSG_TYPE_ALL, SVC_TEMPENTITY);
            write_byte(TE_BEAMFOLLOW);
            write_short(iGrenId);
            write_short(g_iSpriteArrow);
            write_byte(15);
            write_byte(7);
            write_byte(iRed);
            write_byte(iGreen);
            write_byte(iBlue);
            write_byte(191);
            message_end();
            
            if( iTemp )
            {
                message_begin(MSG_TYPE_ALL, SVC_TEMPENTITY);
                write_byte(TE_BEAMFOLLOW);
                write_short(iGrenId);
                write_short(g_iSpriteLine);
                write_byte(15);
                write_byte(1);
                switch( cs_get_user_team(iPlrId) )
                {
                    case CS_TEAM_T:
                    {
                        write_byte(255);
                        write_byte(0);
                        write_byte(0);
                    }
                    case CS_TEAM_CT:
                    {
                        write_byte(0);
                        write_byte(0);
                        write_byte(255);
                    }
                    default:
                    {
                        write_byte(127);
                        write_byte(127);
                        write_byte(127);
                    }
                }
                write_byte(191);
                message_end();
            }
        }
    }
}
 
Статус
В этой теме нельзя размещать новые ответы.

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу