Raised This Month: $51 Target: $400
 12% 

[CS:GO] Sniper Laser ADMIN FLAG


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
asdfxD
Veteran Member
Join Date: Apr 2011
Old 02-21-2015 , 07:07   [CS:GO] Sniper Laser ADMIN FLAG
Reply With Quote #1

hi, someone can add an admin only option to this plugin?

PHP Code:
/*
laser_aim.sp

Name:
    Laser Aim

Description:
    Creates A Beam For every times when player holds in arms a Snipers Rifle
    
Versions:
    0.1 ѕервый релиз
    0.2 Ћазеры показываютс¤ только у живых
    0.3 лазеры показыватьс¤ только у владельцев снайперских винтовок
    1.0 Public release
    1.1 Added zoom cheking, Fixed laser's start position, Removed timer
    1.2 Added dot on target
    1.3 Duck/stand hooking, optimised code
*/

#include <sourcemod>
#include <sdktools>

#define VERSION "1.3" 

new Handle:g_CvarEnable INVALID_HANDLE;

new 
g_sprite;
new 
g_glow;

new 
m_iFOV;

new 
Handle:g_CvarRed INVALID_HANDLE;
new 
Handle:g_CvarBlue INVALID_HANDLE;
new 
Handle:g_CvarGreen INVALID_HANDLE;

new 
Handle:g_CvarTrans INVALID_HANDLE;
new 
Handle:g_CvarLife INVALID_HANDLE;
new 
Handle:g_CvarWidth INVALID_HANDLE;
new 
Handle:g_CvarDotWidth INVALID_HANDLE;

public 
OnMapStart()
{
    
g_sprite PrecacheModel("materials/sprites/laserbeam.vmt");
    
g_glow PrecacheModel("sprites/glow01.vmt");
}

public 
Plugin:myinfo =
{
    
name "Laser Aim",
    
author "Leonardo",
    
description "Creates A Beam For every times when player holds in arms a Snipers Rifle",
    
version VERSION,
    
url "www.sourcemod.net"
};

public 
OnPluginStart()
{
    
CreateConVar("sm_laser_aim"VERSION"1 turns the plugin on 0 is off"FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD);
    
g_CvarEnable CreateConVar("sm_laser_aim_on""1""1 turns the plugin on 0 is off"FCVAR_NOTIFY);

    
g_CvarRed CreateConVar("sm_laser_aim_red""200""Amount OF Red In The Beam");
    
g_CvarGreen CreateConVar("sm_laser_aim_green""0""Amount Of Green In The Beam");
    
g_CvarBlue CreateConVar("sm_laser_aim_blue""0""Amount OF Blue In The Beams");
    
g_CvarTrans CreateConVar("sm_laser_aim_alpha""17""Amount OF Transparency In Beam");
    
    
g_CvarLife CreateConVar("sm_laser_aim_life""0.1""Life of the Beam");
    
g_CvarWidth CreateConVar("sm_laser_aim_width""0.12""Width of the Beam");
    
g_CvarDotWidth CreateConVar("sm_laser_aim_dot_width""0.25""Width of the Dot");

    
m_iFOV FindSendPropOffs("CBasePlayer","m_iFOV");
}

public 
OnGameFrame()
{
    for (new 
i=1i<=MaxClientsi++)
    {
        
//new client = GetClientOfUserId(i);
        
if(IsClientInGame(i) && IsClientConnected(i) && IsPlayerAlive(i))
        {
            new 
i_playerTeam GetClientTeam(i);
            
            new 
String:s_playerWeapon[32];
            
GetClientWeapon(is_playerWeaponsizeof(s_playerWeapon));
            
            new 
i_playerFOV;
            
i_playerFOV GetEntData(im_iFOV);
                
            if(
GetConVarBool(g_CvarEnable) && (i_playerTeam 1))
                if(
StrEqual("weapon_awp"s_playerWeapon) || StrEqual("weapon_sg550"s_playerWeapon) || StrEqual("weapon_g3sg1"s_playerWeapon))
                    if((
i_playerFOV == 15) || (i_playerFOV == 40) || (i_playerFOV == 10))
                        
CreateBeam(i);
        }
    }
}

public 
Action:CreateBeam(any:client)
{
    new 
Float:f_playerViewOrigin[3];
    
GetClientAbsOrigin(clientf_playerViewOrigin);
    if(
GetClientButtons(client) & IN_DUCK)
        
f_playerViewOrigin[2] += 40;
    else
        
f_playerViewOrigin[2] += 60;

    new 
Float:f_playerViewDestination[3];        
    
GetPlayerEye(clientf_playerViewDestination);

    new 
Float:distance GetVectorDistancef_playerViewOriginf_playerViewDestination );

    new 
Float:percentage 0.4 / ( distance 100 );

    new 
Float:f_newPlayerViewOrigin[3];
    
f_newPlayerViewOrigin[0] = f_playerViewOrigin[0] + ( ( f_playerViewDestination[0] - f_playerViewOrigin[0] ) * percentage );
    
f_newPlayerViewOrigin[1] = f_playerViewOrigin[1] + ( ( f_playerViewDestination[1] - f_playerViewOrigin[1] ) * percentage ) - 0.08;
    
f_newPlayerViewOrigin[2] = f_playerViewOrigin[2] + ( ( f_playerViewDestination[2] - f_playerViewOrigin[2] ) * percentage );

    new 
color[4];
    
color[0] = GetConVarIntg_CvarRed ); 
    
color[1] = GetConVarIntg_CvarGreen );
    
color[2] = GetConVarIntg_CvarBlue );
    
color[3] = GetConVarIntg_CvarTrans );
    
    new 
Float:life;
    
life GetConVarFloatg_CvarLife );

    new 
Float:width;
    
width GetConVarFloatg_CvarWidth );
    new 
Float:dotWidth;
    
dotWidth GetConVarFloatg_CvarDotWidth );
    
    
TE_SetupBeamPointsf_newPlayerViewOriginf_playerViewDestinationg_sprite000lifewidth0.010.0color);
    
TE_SendToAll();
    
    
TE_SetupGlowSpritef_playerViewDestinationg_glowlifedotWidthcolor[3] );
    
TE_SendToAll();
    
    return 
Plugin_Continue;
}

bool:GetPlayerEye(clientFloat:pos[3])
{
    new 
Float:vAngles[3], Float:vOrigin[3];
    
GetClientEyePosition(client,vOrigin);
    
GetClientEyeAngles(clientvAngles);
    
    new 
Handle:trace TR_TraceRayFilterEx(vOriginvAnglesMASK_SHOTRayType_InfiniteTraceEntityFilterPlayer);
    
    if(
TR_DidHit(trace))
    {
        
TR_GetEndPosition(postrace);
        
CloseHandle(trace);
        return 
true;
    }
    
CloseHandle(trace);
    return 
false;
}

public 
bool:TraceEntityFilterPlayer(entitycontentsMask)
{
    return 
entity GetMaxClients();

thanks
asdfxD is offline
thecount
Veteran Member
Join Date: Jul 2013
Old 02-21-2015 , 13:37   Re: [CS:GO] Sniper Laser ADMIN FLAG
Reply With Quote #2

This should work. It only allows it for admins at or above generic level.
Attached Files
File Type: sp Get Plugin or Get Source (LaserAim.sp - 535 views - 5.6 KB)
thecount is offline
asdfxD
Veteran Member
Join Date: Apr 2011
Old 02-21-2015 , 14:28   Re: [CS:GO] Sniper Laser ADMIN FLAG
Reply With Quote #3

Quote:
Originally Posted by thecount View Post
This should work. It only allows it for admins at or above generic level.
wow, thank you.
asdfxD is offline
bman87
Senior Member
Join Date: Dec 2008
Location: Michigan
Old 02-22-2015 , 16:40   Re: [CS:GO] Sniper Laser ADMIN FLAG
Reply With Quote #4

I am trying to get laser beams to work in CSGO, I am not having any luck. This code works for you?
bman87 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 14:45.


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