Raised This Month: $32 Target: $400
 8% 

Team grenade trail only VIP's


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
LithuanianJack
Senior Member
Join Date: Nov 2013
Location: Vilnius, Lithuania
Old 01-21-2017 , 15:40   Team grenade trail only VIP's
Reply With Quote #1

Hello. Can anyone edit this plugin, that it works only VIP members? ADMIN_LEVEL_H

If cvar "amx_grentrail_status" - 1, grenade trail see only VIP members

PHP Code:
/**
 *
 * 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_NAMEPLUGIN_VERSIONPLUGIN_AUTHOR);
    
    
g_iCvar_TrailStatus register_cvar("amx_grentrail_status""1");
    
    
g_iCvar_ColorFlash  register_cvar("amx_grentrail_color_fb""000255255");
    
g_iCvar_ColorHe     register_cvar("amx_grentrail_color_he""255063000");
    
g_iCvar_ColorSmoke  register_cvar("amx_grentrail_color_sg""031255127");
    
    
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(), 132);
}

public 
client_connect(iPlrId)
{
    
ClearPlayerBit(g_iConnectedUsersiPlrId);
    
ClearPlayerBit(g_iDeadUsersiPlrId);
}

public 
client_putinserver(iPlrId)
{
    if( !
is_user_bot(iPlrId) )
    {
        
SetPlayerBit(g_iConnectedUsersiPlrId);
        if( 
is_user_alive(iPlrId) )
            
ClearPlayerBit(g_iDeadUsersiPlrId);
        else
            
SetPlayerBit(g_iDeadUsersiPlrId);
    }
}

public 
client_disconnect(iPlrId)
{
    
ClearPlayerBit(g_iConnectedUsersiPlrId);
    
ClearPlayerBit(g_iDeadUsersiPlrId);
}

public 
Event_ResetHUD(iPlrId)
{
    if( 
CheckPlayerBit(g_iConnectedUsersiPlrId) )
    {
        if( 
is_user_alive(iPlrId) )
            
ClearPlayerBit(g_iDeadUsersiPlrId);
        else
            
SetPlayerBit(g_iDeadUsersiPlrId);
    }
}

public 
Event_Health(iPlrId)
{
    if( 
CheckPlayerBit(g_iConnectedUsersiPlrId) )
    {
        if( 
is_user_alive(iPlrId) )
            
ClearPlayerBit(g_iDeadUsersiPlrId);
        else
            
SetPlayerBit(g_iDeadUsersiPlrId);
    }
}

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

public 
grenade_throw(iPlrIdiGrenIdiWeaponType)
{
    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_SMOKEGRENADEiTemp get_pcvar_num(g_iCvar_ColorSmoke);
        default: return;
    }
    
    new 
iRed iTemp/1000000;
    
iTemp %= 1000000;
    new 
iGreen iTemp/1000;
    new 
iBlue iTemp%1000;
    
    
iTemp clamp(get_pcvar_num(g_iCvar_TeamColor), 01);
    
    switch( 
clamp(get_pcvar_num(g_iCvar_TrailStatus), 03) )
    {
        case 
1:
        {
            new 
CsTeams:iOwnerTeam cs_get_user_team(iPlrId);
            
            for( new 
iPlayer=1iPlayer<=g_iMaxPlayersiPlayer++ )
            {
                if( 
CheckPlayerBit(g_iConnectedUsersiPlayer) )
                {
                    if( 
cs_get_user_team(iPlayer)==iOwnerTeam )
                    {
                        
message_begin(MSG_TYPE_ALONESVC_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_ALONESVC_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=1iPlayer<=g_iMaxPlayersiPlayer++ )
            {
                if( 
CheckPlayerBit(g_iConnectedUsersiPlayer) )
                {
                    if( 
CheckPlayerBit(g_iDeadUsersiPlayer) || cs_get_user_team(iPlayer)==iOwnerTeam )
                    {
                        
message_begin(MSG_TYPE_ALONESVC_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_ALONESVC_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_ALLSVC_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_ALLSVC_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();
            }
        }
    }

LithuanianJack is offline
yas17sin
Veteran Member
Join Date: Oct 2016
Location: Morocco/Sale
Old 01-21-2017 , 16:12   Re: Team grenade trail only VIP's
Reply With Quote #2

here you go it's should work fine :

PHP Code:
/**
 *
 * 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 ACCESS_LEVEL        ADMIN_LEVEL_H

#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_NAMEPLUGIN_VERSIONPLUGIN_AUTHOR);
    
    
g_iCvar_TrailStatus register_cvar("amx_grentrail_status""1"ACCESS_LEVEL);
    
    
g_iCvar_ColorFlash  register_cvar("amx_grentrail_color_fb""000255255"ACCESS_LEVEL);
    
g_iCvar_ColorHe     register_cvar("amx_grentrail_color_he""255063000"ACCESS_LEVEL);
    
g_iCvar_ColorSmoke  register_cvar("amx_grentrail_color_sg""031255127"ACCESS_LEVEL);
    
    
g_iCvar_TeamColor   register_cvar("amx_grentrail_team_color""0"ACCESS_LEVEL);
    
    
register_event("ResetHUD""Event_ResetHUD""be");
    
register_event("Health",   "Event_Health",   "bd");
    
    
g_iMaxPlayers clamp(get_maxplayers(), 132);
}

public 
client_connect(iPlrId)
{
    
ClearPlayerBit(g_iConnectedUsersiPlrId);
    
ClearPlayerBit(g_iDeadUsersiPlrId);
}

public 
client_putinserver(iPlrId)
{
    if( !
is_user_bot(iPlrId) )
    {
        
SetPlayerBit(g_iConnectedUsersiPlrId);
        if( 
is_user_alive(iPlrId) )
            
ClearPlayerBit(g_iDeadUsersiPlrId);
        else
            
SetPlayerBit(g_iDeadUsersiPlrId);
    }
}

public 
client_disconnect(iPlrId)
{
    
ClearPlayerBit(g_iConnectedUsersiPlrId);
    
ClearPlayerBit(g_iDeadUsersiPlrId);
}

public 
Event_ResetHUD(iPlrId)
{
    if( 
CheckPlayerBit(g_iConnectedUsersiPlrId) )
    {
        if( 
is_user_alive(iPlrId) )
            
ClearPlayerBit(g_iDeadUsersiPlrId);
        else
            
SetPlayerBit(g_iDeadUsersiPlrId);
    }
}

public 
Event_Health(iPlrId)
{
    if( 
CheckPlayerBit(g_iConnectedUsersiPlrId) )
    {
        if( 
is_user_alive(iPlrId) )
            
ClearPlayerBit(g_iDeadUsersiPlrId);
        else
            
SetPlayerBit(g_iDeadUsersiPlrId);
    }
}

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

public 
grenade_throw(iPlrIdiGrenIdiWeaponType)
{
    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_SMOKEGRENADEiTemp get_pcvar_num(g_iCvar_ColorSmoke);
        default: return;
    }
    
    new 
iRed iTemp/1000000;
    
iTemp %= 1000000;
    new 
iGreen iTemp/1000;
    new 
iBlue iTemp%1000;
    
    
iTemp clamp(get_pcvar_num(g_iCvar_TeamColor), 01);
    
    switch( 
clamp(get_pcvar_num(g_iCvar_TrailStatus), 03) )
    {
        case 
1:
        {
            new 
CsTeams:iOwnerTeam cs_get_user_team(iPlrId);
            
            for( new 
iPlayer=1iPlayer<=g_iMaxPlayersiPlayer++ )
            {
                if( 
CheckPlayerBit(g_iConnectedUsersiPlayer) )
                {
                    if( 
cs_get_user_team(iPlayer)==iOwnerTeam )
                    {
                        
message_begin(MSG_TYPE_ALONESVC_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_ALONESVC_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=1iPlayer<=g_iMaxPlayersiPlayer++ )
            {
                if( 
CheckPlayerBit(g_iConnectedUsersiPlayer) )
                {
                    if( 
CheckPlayerBit(g_iDeadUsersiPlayer) || cs_get_user_team(iPlayer)==iOwnerTeam )
                    {
                        
message_begin(MSG_TYPE_ALONESVC_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_ALONESVC_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_ALLSVC_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_ALLSVC_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();
            }
        }
    }


Last edited by yas17sin; 01-21-2017 at 16:13.
yas17sin is offline
Send a message via ICQ to yas17sin
LithuanianJack
Senior Member
Join Date: Nov 2013
Location: Vilnius, Lithuania
Old 01-21-2017 , 17:11   Re: Team grenade trail only VIP's
Reply With Quote #3

Quote:
Originally Posted by yas17sin View Post
here you go it's should work fine :

PHP Code:
/**
 *
 * 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 ACCESS_LEVEL        ADMIN_LEVEL_H

#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_NAMEPLUGIN_VERSIONPLUGIN_AUTHOR);
    
    
g_iCvar_TrailStatus register_cvar("amx_grentrail_status""1"ACCESS_LEVEL);
    
    
g_iCvar_ColorFlash  register_cvar("amx_grentrail_color_fb""000255255"ACCESS_LEVEL);
    
g_iCvar_ColorHe     register_cvar("amx_grentrail_color_he""255063000"ACCESS_LEVEL);
    
g_iCvar_ColorSmoke  register_cvar("amx_grentrail_color_sg""031255127"ACCESS_LEVEL);
    
    
g_iCvar_TeamColor   register_cvar("amx_grentrail_team_color""0"ACCESS_LEVEL);
    
    
register_event("ResetHUD""Event_ResetHUD""be");
    
register_event("Health",   "Event_Health",   "bd");
    
    
g_iMaxPlayers clamp(get_maxplayers(), 132);
}

public 
client_connect(iPlrId)
{
    
ClearPlayerBit(g_iConnectedUsersiPlrId);
    
ClearPlayerBit(g_iDeadUsersiPlrId);
}

public 
client_putinserver(iPlrId)
{
    if( !
is_user_bot(iPlrId) )
    {
        
SetPlayerBit(g_iConnectedUsersiPlrId);
        if( 
is_user_alive(iPlrId) )
            
ClearPlayerBit(g_iDeadUsersiPlrId);
        else
            
SetPlayerBit(g_iDeadUsersiPlrId);
    }
}

public 
client_disconnect(iPlrId)
{
    
ClearPlayerBit(g_iConnectedUsersiPlrId);
    
ClearPlayerBit(g_iDeadUsersiPlrId);
}

public 
Event_ResetHUD(iPlrId)
{
    if( 
CheckPlayerBit(g_iConnectedUsersiPlrId) )
    {
        if( 
is_user_alive(iPlrId) )
            
ClearPlayerBit(g_iDeadUsersiPlrId);
        else
            
SetPlayerBit(g_iDeadUsersiPlrId);
    }
}

public 
Event_Health(iPlrId)
{
    if( 
CheckPlayerBit(g_iConnectedUsersiPlrId) )
    {
        if( 
is_user_alive(iPlrId) )
            
ClearPlayerBit(g_iDeadUsersiPlrId);
        else
            
SetPlayerBit(g_iDeadUsersiPlrId);
    }
}

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

public 
grenade_throw(iPlrIdiGrenIdiWeaponType)
{
    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_SMOKEGRENADEiTemp get_pcvar_num(g_iCvar_ColorSmoke);
        default: return;
    }
    
    new 
iRed iTemp/1000000;
    
iTemp %= 1000000;
    new 
iGreen iTemp/1000;
    new 
iBlue iTemp%1000;
    
    
iTemp clamp(get_pcvar_num(g_iCvar_TeamColor), 01);
    
    switch( 
clamp(get_pcvar_num(g_iCvar_TrailStatus), 03) )
    {
        case 
1:
        {
            new 
CsTeams:iOwnerTeam cs_get_user_team(iPlrId);
            
            for( new 
iPlayer=1iPlayer<=g_iMaxPlayersiPlayer++ )
            {
                if( 
CheckPlayerBit(g_iConnectedUsersiPlayer) )
                {
                    if( 
cs_get_user_team(iPlayer)==iOwnerTeam )
                    {
                        
message_begin(MSG_TYPE_ALONESVC_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_ALONESVC_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=1iPlayer<=g_iMaxPlayersiPlayer++ )
            {
                if( 
CheckPlayerBit(g_iConnectedUsersiPlayer) )
                {
                    if( 
CheckPlayerBit(g_iDeadUsersiPlayer) || cs_get_user_team(iPlayer)==iOwnerTeam )
                    {
                        
message_begin(MSG_TYPE_ALONESVC_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_ALONESVC_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_ALLSVC_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_ALLSVC_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();
            }
        }
    }

No. Not VIP members can see the granade trail, but i want only VIPs
LithuanianJack is offline
yas17sin
Veteran Member
Join Date: Oct 2016
Location: Morocco/Sale
Old 01-21-2017 , 19:28   Re: Team grenade trail only VIP's
Reply With Quote #4

here you go not tested :

PHP Code:
/**
 *
 * 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 ACCESS_LEVEL        ADMIN_LEVEL_H

#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_NAMEPLUGIN_VERSIONPLUGIN_AUTHOR);
    
    
g_iCvar_TrailStatus register_cvar("amx_grentrail_status""1"ACCESS_LEVEL);
    
    
g_iCvar_ColorFlash  register_cvar("amx_grentrail_color_fb""000255255"ACCESS_LEVEL);
    
g_iCvar_ColorHe     register_cvar("amx_grentrail_color_he""255063000"ACCESS_LEVEL);
    
g_iCvar_ColorSmoke  register_cvar("amx_grentrail_color_sg""031255127"ACCESS_LEVEL);
    
    
g_iCvar_TeamColor   register_cvar("amx_grentrail_team_color""0"ACCESS_LEVEL);
    
    
register_event("ResetHUD""Event_ResetHUD""be");
    
register_event("Health",   "Event_Health",   "bd");
    
    
g_iMaxPlayers clamp(get_maxplayers(), 132);
}

public 
client_connect(iPlrId)
{
    
ClearPlayerBit(g_iConnectedUsersiPlrId);
    
ClearPlayerBit(g_iDeadUsersiPlrId);
}

public 
client_putinserver(iPlrId)
{
    if( !
is_user_bot(iPlrId) )
    {
        
SetPlayerBit(g_iConnectedUsersiPlrId);
        if( 
is_user_alive(iPlrId) )
            
ClearPlayerBit(g_iDeadUsersiPlrId);
        else
            
SetPlayerBit(g_iDeadUsersiPlrId);
    }
}

public 
client_disconnect(iPlrId)
{
    
ClearPlayerBit(g_iConnectedUsersiPlrId);
    
ClearPlayerBit(g_iDeadUsersiPlrId);
}

public 
Event_ResetHUD(iPlrId)
{
    if( 
CheckPlayerBit(g_iConnectedUsersiPlrId) )
    {
        if( 
is_user_alive(iPlrId) )
            
ClearPlayerBit(g_iDeadUsersiPlrId);
        else
            
SetPlayerBit(g_iDeadUsersiPlrId);
    }
}

public 
Event_Health(iPlrId)
{
    if( 
CheckPlayerBit(g_iConnectedUsersiPlrId) )
    {
        if( 
is_user_alive(iPlrId) )
            
ClearPlayerBit(g_iDeadUsersiPlrId);
        else
            
SetPlayerBit(g_iDeadUsersiPlrId);
    }
}

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

public 
grenade_throw(iPlrIdiGrenIdiWeaponType)
    {
    new 
flags get_user_flags(iPlrId)
    if (
flags ACCESS_LEVEL)
{
    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_SMOKEGRENADEiTemp get_pcvar_num(g_iCvar_ColorSmoke);
        default: return;
    }
    
    new 
iRed iTemp/1000000;
    
iTemp %= 1000000;
    new 
iGreen iTemp/1000;
    new 
iBlue iTemp%1000;
    
    
iTemp clamp(get_pcvar_num(g_iCvar_TeamColor), 01);
    
    switch( 
clamp(get_pcvar_num(g_iCvar_TrailStatus), 03) )
    {
        case 
1:
        {
            new 
CsTeams:iOwnerTeam cs_get_user_team(iPlrId);
            
            for( new 
iPlayer=1iPlayer<=g_iMaxPlayersiPlayer++ )
            {
                if( 
CheckPlayerBit(g_iConnectedUsersiPlayer) )
                {
                    if( 
cs_get_user_team(iPlayer)==iOwnerTeam )
                    {
                        
message_begin(MSG_TYPE_ALONESVC_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_ALONESVC_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=1iPlayer<=g_iMaxPlayersiPlayer++ )
            {
                if( 
CheckPlayerBit(g_iConnectedUsersiPlayer) )
                {
                    if( 
CheckPlayerBit(g_iDeadUsersiPlayer) || cs_get_user_team(iPlayer)==iOwnerTeam )
                    {
                        
message_begin(MSG_TYPE_ALONESVC_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_ALONESVC_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_ALLSVC_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_ALLSVC_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();
            }
        }
    }


yas17sin is offline
Send a message via ICQ to yas17sin
LithuanianJack
Senior Member
Join Date: Nov 2013
Location: Vilnius, Lithuania
Old 01-22-2017 , 03:54   Re: Team grenade trail only VIP's
Reply With Quote #5

Quote:
Originally Posted by yas17sin View Post
here you go not tested :

PHP Code:
/**
 *
 * 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 ACCESS_LEVEL        ADMIN_LEVEL_H

#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_NAMEPLUGIN_VERSIONPLUGIN_AUTHOR);
    
    
g_iCvar_TrailStatus register_cvar("amx_grentrail_status""1"ACCESS_LEVEL);
    
    
g_iCvar_ColorFlash  register_cvar("amx_grentrail_color_fb""000255255"ACCESS_LEVEL);
    
g_iCvar_ColorHe     register_cvar("amx_grentrail_color_he""255063000"ACCESS_LEVEL);
    
g_iCvar_ColorSmoke  register_cvar("amx_grentrail_color_sg""031255127"ACCESS_LEVEL);
    
    
g_iCvar_TeamColor   register_cvar("amx_grentrail_team_color""0"ACCESS_LEVEL);
    
    
register_event("ResetHUD""Event_ResetHUD""be");
    
register_event("Health",   "Event_Health",   "bd");
    
    
g_iMaxPlayers clamp(get_maxplayers(), 132);
}

public 
client_connect(iPlrId)
{
    
ClearPlayerBit(g_iConnectedUsersiPlrId);
    
ClearPlayerBit(g_iDeadUsersiPlrId);
}

public 
client_putinserver(iPlrId)
{
    if( !
is_user_bot(iPlrId) )
    {
        
SetPlayerBit(g_iConnectedUsersiPlrId);
        if( 
is_user_alive(iPlrId) )
            
ClearPlayerBit(g_iDeadUsersiPlrId);
        else
            
SetPlayerBit(g_iDeadUsersiPlrId);
    }
}

public 
client_disconnect(iPlrId)
{
    
ClearPlayerBit(g_iConnectedUsersiPlrId);
    
ClearPlayerBit(g_iDeadUsersiPlrId);
}

public 
Event_ResetHUD(iPlrId)
{
    if( 
CheckPlayerBit(g_iConnectedUsersiPlrId) )
    {
        if( 
is_user_alive(iPlrId) )
            
ClearPlayerBit(g_iDeadUsersiPlrId);
        else
            
SetPlayerBit(g_iDeadUsersiPlrId);
    }
}

public 
Event_Health(iPlrId)
{
    if( 
CheckPlayerBit(g_iConnectedUsersiPlrId) )
    {
        if( 
is_user_alive(iPlrId) )
            
ClearPlayerBit(g_iDeadUsersiPlrId);
        else
            
SetPlayerBit(g_iDeadUsersiPlrId);
    }
}

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

public 
grenade_throw(iPlrIdiGrenIdiWeaponType)
    {
    new 
flags get_user_flags(iPlrId)
    if (
flags ACCESS_LEVEL)
{
    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_SMOKEGRENADEiTemp get_pcvar_num(g_iCvar_ColorSmoke);
        default: return;
    }
    
    new 
iRed iTemp/1000000;
    
iTemp %= 1000000;
    new 
iGreen iTemp/1000;
    new 
iBlue iTemp%1000;
    
    
iTemp clamp(get_pcvar_num(g_iCvar_TeamColor), 01);
    
    switch( 
clamp(get_pcvar_num(g_iCvar_TrailStatus), 03) )
    {
        case 
1:
        {
            new 
CsTeams:iOwnerTeam cs_get_user_team(iPlrId);
            
            for( new 
iPlayer=1iPlayer<=g_iMaxPlayersiPlayer++ )
            {
                if( 
CheckPlayerBit(g_iConnectedUsersiPlayer) )
                {
                    if( 
cs_get_user_team(iPlayer)==iOwnerTeam )
                    {
                        
message_begin(MSG_TYPE_ALONESVC_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_ALONESVC_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=1iPlayer<=g_iMaxPlayersiPlayer++ )
            {
                if( 
CheckPlayerBit(g_iConnectedUsersiPlayer) )
                {
                    if( 
CheckPlayerBit(g_iDeadUsersiPlayer) || cs_get_user_team(iPlayer)==iOwnerTeam )
                    {
                        
message_begin(MSG_TYPE_ALONESVC_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_ALONESVC_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_ALLSVC_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_ALLSVC_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();
            }
        }
    }


Thank you!
LithuanianJack is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 23:13.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode