Raised This Month: $ Target: $400
 0% 

[CSGO] Help need to restrict a plugin to Custom2!


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Krotis
Senior Member
Join Date: Aug 2012
Old 06-23-2015 , 19:41   [CSGO] Help need to restrict a plugin to Custom2!
Reply With Quote #1

Hi! I need help to restrict this plugin to flag: CUSTOM2 but im not able to do that!
Can someone please help out!

PHP Code:
public OnPluginStart()
{
    
HookEventEx("player_death"death);
}

public 
death(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
attacker GetClientOfUserId(GetEventInt(event"attacker"));

    if(
attacker != && IsClientInGame(attacker) && IsPlayerAlive(attacker))
    {
        new 
hp GetClientHealth(attacker);

        if(
hp >= 150)
        {
            return;
        }

        new 
String:weapon[20];
        
GetEventString(event"weapon"weaponsizeof(weapon));

        if(
StrContains(weapon"flashbang") != -|| StrContains(weapon"grenade") != -|| StrContains(weapon"knife") != -1)
        {
            
hp += 15;
        }
        else
        {
            new 
victim GetClientOfUserId(GetEventInt(event"userid"));
            if(
CheckCommandAccess(victim"sm_admin"ADMFLAG_GENERIC))
            {
                
hp += 5;
            }
            else
            {
                
hp += 5;
            }

            if(
GetEventBool(event"headshot"))
            {
                
hp += 5;
            }
        }

        if(
hp 150)
        {
            
hp 150;
        }
        
SetEntProp(attackerProp_Send"m_iHealth"hp);
    }


Last edited by Krotis; 06-23-2015 at 19:42.
Krotis is offline
Puppetmaster
Senior Member
Join Date: Jun 2015
Location: Probably at a computer.
Old 06-23-2015 , 23:53   Re: [CSGO] Help need to restrict a plugin to Custom2!
Reply With Quote #2

Wouldn't changing this line

SetEntProp(attacker, Prop_Send, "m_iHealth", hp);

to this:

if (GetAdminFlag(GetUserAdmin(attacker), Admin_Custom2)) SetEntProp(attacker, Prop_Send, "m_iHealth", hp);

Sort your issue?

OR

Maybe put something like this after the GetClientOfUserId line:
if (!GetAdminFlag(GetUserAdmin(attacker), Admin_Custom2)) return;


Heres the code post fix:

Code:
public OnPluginStart()
{
    HookEventEx("player_death", death);
}

public death(Handle:event, const String:name[], bool:dontBroadcast)
{
    new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));

     if(!GetAdminFlag(GetUserAdmin(attacker), Admin_Custom2)) return; //return if the attacker does not have custom2 admin flag.

    if(attacker != 0 && IsClientInGame(attacker) && IsPlayerAlive(attacker))
    {
        new hp = GetClientHealth(attacker);

        if(hp >= 150)
        {
            return;
        }

        new String:weapon[20];
        GetEventString(event, "weapon", weapon, sizeof(weapon));

        if(StrContains(weapon, "flashbang") != -1 || StrContains(weapon, "grenade") != -1 || StrContains(weapon, "knife") != -1)
        {
            hp += 15;
        }
        else
        {
            new victim = GetClientOfUserId(GetEventInt(event, "userid"));
            if(CheckCommandAccess(victim, "sm_admin", ADMFLAG_GENERIC))
            {
                hp += 5;
            }
            else
            {
                hp += 5;
            }

            if(GetEventBool(event, "headshot"))
            {
                hp += 5;
            }
        }

        if(hp > 150)
        {
            hp = 150;
        }
        SetEntProp(attacker, Prop_Send, "m_iHealth", hp);
    }
}  

Last edited by Puppetmaster; 06-24-2015 at 00:24. Reason: Additional info fixes
Puppetmaster is offline
Reply


Thread Tools
Display Modes

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 05:16.


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