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

Adding so you need flag to use plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
OZZI
Junior Member
Join Date: Feb 2021
Old 03-06-2021 , 09:21   Adding so you need flag to use plugin
Reply With Quote #1

I have found a plugin that allows you to show the damage done to opponents in CS:GO, the thing is that i would like it to only be enabled for VIP users with the "a" flag. I have tried to use the CheckCommmandAccess, but since i have never programed in source I couldn't make it work.

The code:
PHP Code:
#pragma semicolon 1
#pragma newdecls required

#include <sdkhooks>
#include <sdktools_entinput>
#include <sdktools_functions>
#include <sdktools_stringtables>
#if SOURCEMOD_V_MINOR >= 9
    #include <sdktools_variant_t>
#endif

enum
{
    
HG_Generic 0,
    
HG_Head,
    
HG_Chest,
    
HG_Stomach,
    
HG_Leftarm,
    
HG_Rightarm,
    
HG_Leftleg,
    
HG_Rightleg
};

bool
    bCSGO
,
    
bEnable,
    
bMode,
    
g_bIsFired[MAXPLAYERS+1],
    
g_bIsCrit[MAXPLAYERS+1][MAXPLAYERS+1],
    
g_bState[MAXPLAYERS+1];
int
    iType
,
    
g_iTotalSGDamage[MAXPLAYERS+1][MAXPLAYERS+1];
float
    fDist
,
    
g_fPlayerPosLate[MAXPLAYERS+1][3];

public 
Plugin myinfo =
{
    
name        "Show Damage [Multi methods]",
    
version        "2.0.1",
    
description    "Show damage in hint message, HUD and Particle",
    
author        "TheBΦ$$♚#2967 (rewritten by Grey83)",
    
url            "http://sourcemod.net"
};

public 
void OnPluginStart()
{
    
EngineVersion ev GetEngineVersion();
    if(
ev == Engine_CSGObCSGO true;
    else if(
ev != Engine_CSSSetFailState("Plugin for CSS and CSGO only!");

    
LoadTranslations("Simple_Show_Damage.phrases");

    
ConVar cvar;
    
cvar CreateConVar("sm_show_damage_enable""1""Enable/Disable plugin?"_true_true1.0);
    
cvar.AddChangeHook(CVarChanged_Enable);
    
bEnable cvar.BoolValue;

    
cvar CreateConVar("sm_show_damage_type""0""0 = Show damage in Hint message\n1 = Show damage in HUD message\n2 = Show damage as particle"_true_truebCSGO 2.0 1.0);
    
cvar.AddChangeHook(CVarChanged_Type);
    
iType cvar.IntValue;

    
cvar CreateConVar("sm_show_damage_mode""1""0 = Show damage to victim only\n1 = Show damage and remaining health of victim"_true_true2.0);
    
cvar.AddChangeHook(CVarChanged_Mode);
    
bMode cvar.BoolValue;

    if(
bCSGO)
    {
        
cvar CreateConVar("sm_show_damage_hit_distance""50.0""Distance between victim player and damage numbers (NOTE: Make that value lower to prevent numbers show up through the walls)"_true0.0);
        
cvar.AddChangeHook(CVarChanged_Dist);
        
fDist cvar.FloatValue;
    }

    
HookEvent("player_hurt"Event_PlayerHurtEventHookMode_Pre);
    
AutoExecConfig(true"Simple_Show_Damage");
}

public 
void CVarChanged_Enable(ConVar cvar, const char[] oldValue, const char[] newValue)
{
    
bEnable cvar.BoolValue;
}

public 
void CVarChanged_Type(ConVar cvar, const char[] oldValue, const char[] newValue)
{
    
iType cvar.IntValue;
}

public 
void CVarChanged_Mode(ConVar cvar, const char[] oldValue, const char[] newValue)
{
    
bMode cvar.BoolValue;
}

public 
void CVarChanged_Dist(ConVar cvar, const char[] oldValue, const char[] newValue)
{
    
fDist cvar.FloatValue;
}

public 
void OnMapStart()
{
    if(!
bCSGO) return;

    
AddFileToDownloadsTable("particles/gammacase/hit_nums.pcf");
    
AddFileToDownloadsTable("materials/gammacase/fortnite/hitnums/nums_bw.vmt");
    
AddFileToDownloadsTable("materials/gammacase/fortnite/hitnums/nums_bw.vtf");
    
PrecacheGeneric("particles/gammacase/hit_nums.pcf"true);
}

public 
void Event_PlayerHurt(Event event, const char[] namebool dontBroadcast)
{
    if(!
bEnable)
        return;
        
        static 
int victimattackerhealthdmg;
        if(!(
attacker GetClientOfUserId(event.GetInt("attacker"))) || !(victim GetClientOfUserId(event.GetInt("userid")))
        || 
attacker == victim)
            return;

        
health event.GetInt("health");
        
dmg event.GetInt("dmg_health");

        switch(
iType)
        {
            case 
0:
            {
                if(!
bCSGO)
                {
                    if(!
bMode)
                        
PrintHintText(attacker"%t %i %t %N""Damage Giver"dmg"Damage Taker"victim);
                    else 
PrintHintText(attacker"%t  %t %N\n %t %i""Damage Giver"dmg"Damage Taker"victim"Health Remaining"health);
                    return;
                }

                if(!
bMode)
                    
PrintHintText(attacker"%t <font color='#FF0000'>%i</font> %t <font color='#3DB1FF'>%N""Damage Giver"dmg"Damage Taker"victim);
                else 
PrintHintText(attacker"%t <font color='#FF0000'>%i</font> %t <font color='#3DB1FF'>%N</font>\n %t <font color='#00FF00'>%i</font>""Damage Giver"dmg"Damage Taker"victim"Health Remaining"health);
            }
            case 
1:
            {
                if(!
bMode)
                {
                    if(
health 50)
                        
SetHudTextParams(-1.00.451.30253302001);    // green
                    
else if(health 20)
                        
SetHudTextParams(-1.00.451.325322902001);    // yellow
                    
else SetHudTextParams(-1.00.451.3255002001);    // red
                    
ShowHudText(attacker, -1"%i"dmg);
                }
                else
                {
                    if(
health 50)
                        
SetHudTextParams(0.430.451.30253302001);    // green
                    
else if(health 20)
                        
SetHudTextParams(0.430.451.325322902001);    // yellow
                    
else SetHudTextParams(0.430.451.3255002001);    // red
                    
ShowHudText(attacker, -1"%i"health);

                    
SetHudTextParams(0.570.451.32552552552001);    // white
                    
ShowHudText(attacker, -1"%i"dmg);
                }
            }
            case 
2:
            {
                static 
bool headshot;
                
headshot event.GetInt("hitgroup") == HG_Head;
                static 
char wpn[16];
                
event.GetString("weapon"wpnsizeof(wpn));
                if(!
strcmp(wpn"xm1014") || !strcmp(wpn"nova") || !strcmp(wpn"mag7") || !strcmp(wpn"sawedoff"))
                {
                    if(!
g_bIsFired[attacker])
                    {
                        
g_bIsFired[attacker] = true;
                        
g_iTotalSGDamage[attacker][victim] = dmg;

                        
CreateTimer(0.1TimerHit_CallBackGetClientUserId(attacker), TIMER_FLAG_NO_MAPCHANGE);
                    }
                    else 
g_iTotalSGDamage[attacker][victim] += dmg;

                    if(
headshotg_bIsCrit[attacker][victim] = true;
                    
GetClientAbsOrigin(victimg_fPlayerPosLate[victim]);
                }
                else 
ShowPRTDamage(attackervictimdmgheadshot);
            }
        }
}

public 
Action TimerHit_CallBack(Handle timerint useridint client)
{
        static 
int attacker;
        if(!(
attacker GetClientOfUserId(userid)))
            return 
Plugin_Stop;
        
        if(!(
CheckCommandAccess(client"reservation_admin"ADMFLAG_RESERVATION))) {
            return 
Plugin_Stop;
        }

        
g_bIsFired[attacker] = false;
        for(
int i 1<= MaxClientsi++) if(IsClientInGame(i) && g_iTotalSGDamage[attacker][i])
        {
            
ShowPRTDamage(attackerig_iTotalSGDamage[attacker][i], g_bIsCrit[attacker][i], true);
            
g_iTotalSGDamage[attacker][i] = 0;
            
g_bIsCrit[attacker][i] = false;
        }

        return 
Plugin_Continue;
}

stock void ShowPRTDamage(int attackerint victimint damagebool critbool late false)
{
    static 
float pos[3], pos2[3], ang[3], fwd[3], right[3], temppos[3], distd;
    static 
int entlcountdmgnums[8];
    static 
char buff[16];

    
count 0;

    while(
damage 0)
    {
        
dmgnums[count++] = damage 10;
        
damage /= 10;
    }

    
GetClientEyeAngles(attackerang);
    
GetClientAbsOrigin(attackerpos2);

    if(
late)
        
pos g_fPlayerPosLate[victim];
    else
        
GetClientAbsOrigin(victimpos);

    
GetAngleVectors(angfwdrightNULL_VECTOR);

    
RoundToCeil(float(count) / 2.0);

    
dist GetVectorDistance(pos2pos);
    if(
dist 700.0)
        
dist 700.0 6.0;
    else 
6.0;

    
pos[0] += right[0] * GetRandomFloat(-0.51.0);
    
pos[1] += right[1] * GetRandomFloat(-0.51.0);
    if(
GetEntProp(victimProp_Send"m_bDucked"))
        if(
crit)
            
pos[2] += 45.0 GetRandomFloat(0.010.0);
        else 
pos[2] += 25.0 GetRandomFloat(0.020.0);
    else
        if(
crit)
            
pos[2] += 60.0 GetRandomFloat(0.010.0);
        else 
pos[2] += 35.0 GetRandomFloat(0.020.0);

    for(
int i count 1>= 0i--)
    {
        
temppos pos;

        
temppos[0] -= fwd[0] * fDist right[0] * l;
        
temppos[1] -= fwd[1] * fDist right[1] * l;

        
ent CreateEntityByName("info_particle_system");
        if(
ent == -1)
            
SetFailState("Error creating \"info_particle_system\" entity!");

        
TeleportEntity(enttempposangNULL_VECTOR);

        
FormatEx(buffsizeof(buff), "%s_num%i_f%s"crit "crit" "def"dmgnums[i], l-- > "l" "r");

        
DispatchKeyValue(ent"effect_name"buff);
        
DispatchKeyValue(ent"start_active""1");
        
DispatchSpawn(ent);
        
ActivateEntity(ent);

        
SetEntPropEnt(entProp_Send"m_hOwnerEntity"attacker);
        
SDKHook(entSDKHook_SetTransmitSetTransmit_Hook);

        
SetVariantString("OnUser1 !self:kill::3:-1");
        
AcceptEntityInput(ent"AddOutput");
        
AcceptEntityInput(ent"FireUser1");
    }
}

public 
Action SetTransmit_Hook(int entityint client)
{
    static 
int buffer;
    if((
buffer GetEdictFlags(entity)) & FL_EDICT_ALWAYS)
        
SetEdictFlags(entity, (buffer FL_EDICT_ALWAYS));

    if(
g_bState[client] && (client == (buffer GetEntPropEnt(entityProp_Send"m_hOwnerEntity"))
    || (
buffer == GetEntPropEnt(clientProp_Send"m_hObserverTarget")
    && ((
buffer GetEntProp(clientProp_Send"m_iObserverMode")) == || buffer == 5))))
        return 
Plugin_Continue;

    return 
Plugin_Stop;

My, not so qualified, guess is that it would be in the "public void Event_PlayerHurt" that needs to be changed.

Last edited by DarkDeviL; 03-06-2021 at 20:05. Reason: Altered SPOILER-attempt to proper CODE tags.
OZZI 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 12:43.


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