AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugin/Gameplay Ideas and Requests (https://forums.alliedmods.net/forumdisplay.php?f=60)
-   -   [CSGO] Help need to restrict a plugin to Custom2! (https://forums.alliedmods.net/showthread.php?t=264961)

Krotis 06-23-2015 19:41

[CSGO] Help need to restrict a plugin to Custom2!
 
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);
    }



Puppetmaster 06-23-2015 23:53

Re: [CSGO] Help need to restrict a plugin to Custom2!
 
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);
    }



All times are GMT -4. The time now is 05:15.

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