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

Flag +HP points how to?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MonsteQ
Member
Join Date: May 2018
Location: Hungary
Old 05-21-2018 , 11:19   Flag +HP points how to?
Reply With Quote #1

Exists? CS:GO only

1 kill / +5 hp only for a particular flag eg. (t flag) - (ADMIN_CUSTOM6)

Last edited by MonsteQ; 05-21-2018 at 11:59.
MonsteQ is offline
sdz
Senior Member
Join Date: Feb 2012
Old 05-21-2018 , 12:20   Re: Flag +HP points how to?
Reply With Quote #2

something like this
PHP Code:
#include <sourcemod>

public void OnPluginStart()
{
    
HookEvent("player_death"Event_PlayerDeathEventHookMode_Post);
}

public 
void Event_PlayerDeath(Event event, const char[] namebool dontBroadcast)
{
    
int attacker GetClientOfUserId(event.GetInt("attacker"));
    if(!
IsClientInGame(attacker) || !IsClientAuthorized(attacker)) return

    
//Get the flags of the dude:
    
char steamid[32]; GetClientAuthId(attackerAuthId_Steam2steamidsizeof(steamid));
    
AdminId admin FindAdminByIdentity("steam"steamid);

    
//is valid admin?
    
if(admin == INVALID_ADMIN_ID) return;

    if(
admin.HasFlag(Admin_Custom6Access_Real))
    {
        
SetEntityHealth(attackerGetClientHealth(attacker) + 5);
        return;
    }

    return;

or something like this with a cvar?
PHP Code:
#include <sourcemod>

ConVar g_cvFlagRequired;

public 
void OnPluginStart()
{
    
g_cvFlagRequired CreateConVar("flag_hp_required""t""Flag required to recieve hp");
    
HookEvent("player_death"Event_PlayerDeathEventHookMode_Post);
}

public 
void Event_PlayerDeath(Event event, const char[] namebool dontBroadcast)
{
    
int attacker GetClientOfUserId(event.GetInt("attacker"));
    if(!
IsClientInGame(attacker) || !IsClientAuthorized(attacker)) return

    
//Get the flags of the dude:
    
char steamid[32]; GetClientAuthId(attackerAuthId_Steam2steamidsizeof(steamid));
    
AdminId admin FindAdminByIdentity("steam"steamid);

    
//is valid admin?
    
if(admin == INVALID_ADMIN_ID) return;

    
AdminFlag flag;

    
//if the cvar isn't good then just hardcode stuff:
    
if(FindFlagByChar(g_cvFlagRequired.IntValueflag))
    {
        if(
admin.HasFlag(flagAccess_Real))
        {
            
SetEntityHealth(attackerGetClientHealth(attacker) + 5);
        }
    }
    else
    {
        if(
admin.HasFlag(Admin_Custom6Access_Real))
        {
            
SetEntityHealth(attackerGetClientHealth(attacker) + 5);
        }
    }

    return;

Attached Files
File Type: sp Get Plugin or Get Source (hp_on_frag.sp - 186 views - 1.3 KB)

Last edited by sdz; 05-21-2018 at 12:29.
sdz is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 05-21-2018 , 12:44   Re: Flag +HP points how to?
Reply With Quote #3

It's not a good idea to hard-code admin flags via cvars. Just create a plugin with CheckCommandAccess() and allow the custom6 flag to access the feature/function.

PHP Code:
stock bool IsAdminAllowed(int client)
{
     return (
CheckCommandAccess(client"hp_override"ADMFLAG_CUSTOM6false));

PHP Code:
if (IsAdminAllowed(client))
{
     
// Insert code here

__________________
Psyk0tik is offline
MonsteQ
Member
Join Date: May 2018
Location: Hungary
Old 05-21-2018 , 14:25   Re: Flag +HP points how to?
Reply With Quote #4

Quote:
Originally Posted by Crasher_3637 View Post
It's not a good idea to hard-code admin flags via cvars. Just create a plugin with CheckCommandAccess() and allow the custom6 flag to access the feature/function.

PHP Code:
stock bool IsAdminAllowed(int client)
{
     return (
CheckCommandAccess(client"hp_override"ADMFLAG_CUSTOM6false));

PHP Code:
if (IsAdminAllowed(client))
{
     
// Insert code here

Please put this commands to complete plugin. I don't understand this programmer-language.
MonsteQ is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 05-21-2018 , 14:54   Re: Flag +HP points how to?
Reply With Quote #5

Untested:

PHP Code:
#include <sourcemod>
#pragma semicolon 1
#pragma newdecls required
#define HP_VERSION "1.0"

public Plugin myinfo =
{
     
name "1 Kill/+5 HP for Admins",
     
author "Psyk0tik (Crasher_3637), MonsteQ, sidezz",
     
description "Gives +5 HP per kill for admins.",
     
version HP_VERSION,
     
url "https://forums.alliedmods.net/showthread.php?t=307697"
};

ConVar g_cvHPEnable;

public 
void OnPluginStart()
{
     
g_cvHPEnable CreateConVar("hp_enable""1""Enable plugin?\n(0: OFF)\n(1: ON)");
     
CreateConVar("hp_version"HP_VERSION"Plugin version."FCVAR_NOTIFY|FCVAR_DONTRECORD);
     
HookEvent("player_death"ePlayerDeath);
     
AutoExecConfig(true"hp_kills_for_admins");
}

public 
Action ePlayerDeath(Event event, const char[] namebool dontBroadcast)
{
     
int iAttacker GetClientOfUserId(event.GetInt("attacker"));
     
int iVictim GetClientOfUserId(event.GetInt("userid"));
     if (!
g_cvHPEnable.BoolValue)
     {
          return 
Plugin_Continue;
     }
     if (
IsAdminAllowed(iAttacker) && IsValidClient(iAttacker) && iAttacker != iVictim)
     {
          
SetEntityHealth(iAttackerGetClientHealth(iAttacker) + 5);
     }
     return 
Plugin_Continue;
}

stock bool IsValidClient(int client)
{
     return (
client && client <= MaxClients && IsClientInGame(client) && !IsClientInKickQueue(client) && IsPlayerAlive(client));
}

stock bool IsAdminAllowed(int client)
{
     return (
CheckCommandAccess(client"hp_override"ADMFLAG_CUSTOM6false));

__________________
Psyk0tik is offline
MonsteQ
Member
Join Date: May 2018
Location: Hungary
Old 05-22-2018 , 05:21   Re: Flag +HP points how to?
Reply With Quote #6

Quote:
Originally Posted by Crasher_3637 View Post
Untested:

PHP Code:
#include <sourcemod>
#pragma semicolon 1
#pragma newdecls required
#define HP_VERSION "1.0"

public Plugin myinfo =
{
     
name "1 Kill/+5 HP for Admins",
     
author "Psyk0tik (Crasher_3637), MonsteQ, sidezz",
     
description "Gives +5 HP per kill for admins.",
     
version HP_VERSION,
     
url "https://forums.alliedmods.net/showthread.php?t=307697"
};

ConVar g_cvHPEnable;

public 
void OnPluginStart()
{
     
g_cvHPEnable CreateConVar("hp_enable""1""Enable plugin?\n(0: OFF)\n(1: ON)");
     
CreateConVar("hp_version"HP_VERSION"Plugin version."FCVAR_NOTIFY|FCVAR_DONTRECORD);
     
HookEvent("player_death"ePlayerDeath);
     
AutoExecConfig(true"hp_kills_for_admins");
}

public 
Action ePlayerDeath(Event event, const char[] namebool dontBroadcast)
{
     
int iAttacker GetClientOfUserId(event.GetInt("attacker"));
     
int iVictim GetClientOfUserId(event.GetInt("userid"));
     if (!
g_cvHPEnable.BoolValue)
     {
          return 
Plugin_Continue;
     }
     if (
IsAdminAllowed(iAttacker) && IsValidClient(iAttacker) && iAttacker != iVictim)
     {
          
SetEntityHealth(iAttackerGetClientHealth(iAttacker) + 5);
     }
     return 
Plugin_Continue;
}

stock bool IsValidClient(int client)
{
     return (
client && client <= MaxClients && IsClientInGame(client) && !IsClientInKickQueue(client) && IsPlayerAlive(client));
}

stock bool IsAdminAllowed(int client)
{
     return (
CheckCommandAccess(client"hp_override"ADMFLAG_CUSTOM6false));

Thanks, I really happy. I'm not tested yet, but i hope this plugin is running. Thanks again 1000x <3
MonsteQ is offline
ThatKidWhoGames
Veteran Member
Join Date: Jun 2013
Location: IsValidClient()
Old 05-23-2018 , 22:59   Re: Flag +HP points how to?
Reply With Quote #7

Quote:
Originally Posted by sidezz View Post
there's the guy
He's literally giving you constructive criticism dude...

Last edited by ThatKidWhoGames; 05-23-2018 at 23:01.
ThatKidWhoGames is offline
iskenderkebab33
Senior Member
Join Date: Jun 2018
Old 07-09-2018 , 07:00   Re: Flag +HP points how to?
Reply With Quote #8

Quote:
Originally Posted by Crasher_3637 View Post
Untested:

PHP Code:
#include <sourcemod>
#pragma semicolon 1
#pragma newdecls required
#define HP_VERSION "1.0"

public Plugin myinfo =
{
     
name "1 Kill/+5 HP for Admins",
     
author "Psyk0tik (Crasher_3637), MonsteQ, sidezz",
     
description "Gives +5 HP per kill for admins.",
     
version HP_VERSION,
     
url "https://forums.alliedmods.net/showthread.php?t=307697"
};

ConVar g_cvHPEnable;

public 
void OnPluginStart()
{
     
g_cvHPEnable CreateConVar("hp_enable""1""Enable plugin?\n(0: OFF)\n(1: ON)");
     
CreateConVar("hp_version"HP_VERSION"Plugin version."FCVAR_NOTIFY|FCVAR_DONTRECORD);
     
HookEvent("player_death"ePlayerDeath);
     
AutoExecConfig(true"hp_kills_for_admins");
}

public 
Action ePlayerDeath(Event event, const char[] namebool dontBroadcast)
{
     
int iAttacker GetClientOfUserId(event.GetInt("attacker"));
     
int iVictim GetClientOfUserId(event.GetInt("userid"));
     if (!
g_cvHPEnable.BoolValue)
     {
          return 
Plugin_Continue;
     }
     if (
IsAdminAllowed(iAttacker) && IsValidClient(iAttacker) && iAttacker != iVictim)
     {
          
SetEntityHealth(iAttackerGetClientHealth(iAttacker) + 5);
     }
     return 
Plugin_Continue;
}

stock bool IsValidClient(int client)
{
     return (
client && client <= MaxClients && IsClientInGame(client) && !IsClientInKickQueue(client) && IsPlayerAlive(client));
}

stock bool IsAdminAllowed(int client)
{
     return (
CheckCommandAccess(client"hp_override"ADMFLAG_CUSTOM6false));

can you do also for all players, please.
iskenderkebab33 is offline
Dr.Mohammad
Senior Member
Join Date: Jan 2016
Location: CSGO Servers
Old 07-09-2018 , 08:37   Re: Flag +HP points how to?
Reply With Quote #9

Quote:
Originally Posted by iskenderkebab33 View Post
can you do also for all players, please.
please test this:

PHP Code:
#include <sourcemod> 
#pragma semicolon 1 
#pragma newdecls required 
#define HP_VERSION "1.0" 

public Plugin myinfo 

     
name "1 Kill/+5 HP for Admins"
     
author "Psyk0tik (Crasher_3637), MonsteQ, sidezz"
     
description "Gives +5 HP per kill for admins."
     
version HP_VERSION
     
url "https://forums.alliedmods.net/showthread.php?t=307697" 
}; 

ConVar g_cvHPEnable
ConVar g_cvHPAdmin;

public 
void OnPluginStart() 

     
g_cvHPEnable CreateConVar("hp_enable""1""Enable plugin?\n(0: OFF)\n(1: ON)"); 
         
g_cvHPAdmin CreateConVar("hp_admin""0""Enable plugin only for Admin?\n(0: OFF)\n(1: ON)"); 
     
CreateConVar("hp_version"HP_VERSION"Plugin version."FCVAR_NOTIFY|FCVAR_DONTRECORD); 
     
HookEvent("player_death"ePlayerDeath); 
     
AutoExecConfig(true"hp_kills_for_admins"); 


public 
Action ePlayerDeath(Event event, const char[] namebool dontBroadcast)   
{
    if (!
g_cvHPEnable.BoolValue)
    {
        return 
Plugin_Handled;
    }
    
int iAttacker GetClientOfUserId(event.GetInt("attacker"));
    
int iVictim GetClientOfUserId(event.GetInt("userid"));
    if ((!
g_cvHPAdmin.BoolValue || (g_cvHPAdmin.BoolValue && IsAdminAllowed(iAttacker))) && IsValidClient(iAttacker) && iAttacker != iVictim)
    {
        
SetEntityHealth(iAttackerGetClientHealth(iAttacker) + 5);
    }
    return 
Plugin_Continue;   
}  

stock bool IsValidClient(int client

     return (
client && client <= MaxClients && IsClientInGame(client) && !IsClientInKickQueue(client) && IsPlayerAlive(client)); 


stock bool IsAdminAllowed(int client

     return (
CheckCommandAccess(client"hp_override"ADMFLAG_CUSTOM6false)); 


Last edited by Dr.Mohammad; 07-10-2018 at 07:56. Reason: last version. this worke. thank you Crasher_3637
Dr.Mohammad is offline
mug1wara
AlliedModders Donor
Join Date: Jun 2018
Old 07-09-2018 , 08:40   Re: Flag +HP points how to?
Reply With Quote #10

Why y'all have to be so complicated, just use CheckCommandAccess?
mug1wara 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:58.


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