Raised This Month: $334 Target: $400
 83%   Almost there!

Error in plugin code block


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Darkwob
Senior Member
Join Date: Oct 2018
Location: Turkey
Old 09-25-2021 , 16:16   Error in plugin code block
Reply With Quote #1

limit code I added in the Plugin does not work stable. While testing, I reached the limit and no player can use this command anymore (even though they haven't used it before). and normally a limit value reset is required at the start of each round, but that doesn't work either, this command resets a timer. I don't understand where I made a mistake. can you help me?


PHP Code:
new iPenaltyCounter[MAXPLAYERS 1]; //global varib 
PHP Code:
         AdminId clientId GetUserAdmin(client);
         if (
clientId == INVALID_ADMIN_ID || iPounces[client] == 0)
         {
          
PrintToChat(client"\x05CountDown Cannot \x03Be Reset \x05Because You Didn't Do \x04Brutal!");
           return 
Plugin_Handled;
          }
          
        if (
iPenalty[client] < && iPenaltyCounter[client] < 3
        {
            
iPenalty[client] = 0;
            
iPenaltyCounter[client]++;
            
CPrintToChat(client"\x05You Can Used \x03Counts Reset \x04(\x03%i\x05/\x033\x04)"iPenaltyCounter[client]);
            
CPrintToChat(client"iPenalty %i iPenaltyCounter %i client %i"iPenalty[client],clientiPenaltyCounter[client]);
        }
        else { 
            
CPrintToChat(client"\x05You Cannot Use Count Reset \x04Limit Reached.");
        } 
PHP Code:
public void OnClientPostAdminCheck(int client) {
    
//If I want, let's set back to 0 once he's inside our server
    
iPenaltyCounter[client] = 0;

Quote:
iPenaltyCounter[client] // This is a limit variable.
Quote:
iPenalty[client] // This is a timer variable
__________________
HTML Code:
<a href="https://www.gametracker.com/server_info/157.90.180.232:27215/" target="_blank"><img src="https://cache.gametracker.com/server_info/157.90.180.232:27215/b_560_95_1.png" border="0" width="560" height="95" alt=""/></a>

Last edited by Darkwob; 09-25-2021 at 16:17.
Darkwob is offline
Send a message via AIM to Darkwob Send a message via Yahoo to Darkwob Send a message via Skype™ to Darkwob
PC Gamer
Veteran Member
Join Date: Mar 2014
Old 09-26-2021 , 20:34   Re: Error in plugin code block
Reply With Quote #2

Post all of your code.
PC Gamer is offline
Darkwob
Senior Member
Join Date: Oct 2018
Location: Turkey
Old 09-27-2021 , 06:43   Re: Error in plugin code block
Reply With Quote #3

Quote:
Originally Posted by PC Gamer View Post
Post all of your code.
here is the code block with reset and limit actions. No other code has been changed.
__________________
HTML Code:
<a href="https://www.gametracker.com/server_info/157.90.180.232:27215/" target="_blank"><img src="https://cache.gametracker.com/server_info/157.90.180.232:27215/b_560_95_1.png" border="0" width="560" height="95" alt=""/></a>
Darkwob is offline
Send a message via AIM to Darkwob Send a message via Yahoo to Darkwob Send a message via Skype™ to Darkwob
azalty
AlliedModders Donor
Join Date: Feb 2020
Location: France
Old 09-27-2021 , 12:22   Re: Error in plugin code block
Reply With Quote #4

PHP Code:
CPrintToChat(client"iPenalty %i iPenaltyCounter %i client %i"iPenalty[client],clientiPenaltyCounter[client]); 
to
PHP Code:
CPrintToChat(client"iPenalty %i iPenaltyCounter %i client %i"iPenalty[client], iPenaltyCounter[client], client); 
If you use colorvariables, you can use {color} instead of \x05 and similar.
List of colors (CS:GO):

default (white): \x01
teamcolour (will be purple if message from server): \x03
red: \x07
lightred: \x0F
darkred: \x02
bluegrey: \x0A
blue: \x0B
darkblue: \x0C
purple: \x03
orchid: \x0E
yellow: \x09
gold: \x10
lightgreen: \x05
green: \x04
lime: \x06
grey: \x08
grey2: \x0D


clientId is a bad name for an AdminId. It works but it's confusing.

PHP Code:
new iPenaltyCounter[MAXPLAYERS 1]; 
to
PHP Code:
int iPenaltyCounter[MAXPLAYERS 1]; 
(or even g_iPenaltyCounter if you want to use this style)

The rest seems okay. We need more code since the problem doesn't seem to come from here. That's what "PC Gamer" meant.

you can change
PHP Code:
public void OnClientPostAdminCheck(int client) {
    
//If I want, let's set back to 0 once he's inside our server
    
iPenaltyCounter[client] = 0;

to
PHP Code:
public void OnClientDisconnect(int client) {
    
iPenaltyCounter[client] = 0;

since you don't need to wait the admin check to set that variable. Resetting on connection/disconnection doesn't really matter though. I just like to do it on disconnects, especially if I work with databases (push/update values to DB).

What do you mean by "This is a timer variable"?
__________________

Last edited by azalty; 09-27-2021 at 12:26.
azalty is offline
Darkwob
Senior Member
Join Date: Oct 2018
Location: Turkey
Old 09-28-2021 , 13:52   Re: Error in plugin code block
Reply With Quote #5

Quote:
Originally Posted by azalty View Post
PHP Code:
CPrintToChat(client"iPenalty %i iPenaltyCounter %i client %i"iPenalty[client],clientiPenaltyCounter[client]); 
to
PHP Code:
CPrintToChat(client"iPenalty %i iPenaltyCounter %i client %i"iPenalty[client], iPenaltyCounter[client], client); 
If you use colorvariables, you can use {color} instead of \x05 and similar.
List of colors (CS:GO):

default (white): \x01
teamcolour (will be purple if message from server): \x03
red: \x07
lightred: \x0F
darkred: \x02
bluegrey: \x0A
blue: \x0B
darkblue: \x0C
purple: \x03
orchid: \x0E
yellow: \x09
gold: \x10
lightgreen: \x05
green: \x04
lime: \x06
grey: \x08
grey2: \x0D


clientId is a bad name for an AdminId. It works but it's confusing.

PHP Code:
new iPenaltyCounter[MAXPLAYERS 1]; 
to
PHP Code:
int iPenaltyCounter[MAXPLAYERS 1]; 
(or even g_iPenaltyCounter if you want to use this style)

The rest seems okay. We need more code since the problem doesn't seem to come from here. That's what "PC Gamer" meant.

you can change
PHP Code:
public void OnClientPostAdminCheck(int client) {
    
//If I want, let's set back to 0 once he's inside our server
    
iPenaltyCounter[client] = 0;

to
PHP Code:
public void OnClientDisconnect(int client) {
    
iPenaltyCounter[client] = 0;

since you don't need to wait the admin check to set that variable. Resetting on connection/disconnection doesn't really matter though. I just like to do it on disconnects, especially if I work with databases (push/update values to DB).

What do you mean by "This is a timer variable"?
thanks for the answer actually the first thing you answered was a debug code , in order to find out what was the cause of the error. ok, I'll share the entire code with you, but as I said, there is nothing that triggers a reset in other code blocks.

PHP Code:
#pragma semicolon 1
#include <colors>
#include <sourcemod>
#include <sdkhooks>
#include <sdktools>
#include <sdktools_sound>

#define HUNTER "sound/hunter_allu.mp3"
#define ENTITY_PROPANE    "models/props_junk/propanecanister001a.mdl"
#define MOLOTOV 0
#define EXPLODE 1

new iPenaltyCounter[MAXPLAYERS 1];
ConVar bhpDistancebhpMaxAttemptsbhpCoolTimebhpShowDamagebhpShowDistancebhpShowKills,
    
bhpAvgDistancebhpRankTypebhpListMaxbhpListType;

float fDistancefCoolTimefPouncePos[MAXPLAYERS+1][3];
int iMaxAttemptsiRankTypeiListMaxiListTypeiPounces[MAXPLAYERS+1], iPenalty[MAXPLAYERS+1],
iListPage[MAXPLAYERS+1] = 1;


Handle hPenaltyTime[MAXPLAYERS+1] = null;
bool bShowDamagebShowDistancebShowKillsbAvgDistancebShowPenalty[MAXPLAYERS+1], bListDone;
char sGame[12], sMap[64];

public 
APLRes AskPluginLoad2(Handle myselfbool latechar[] errorint err_max)
{
    
GetGameFolderName(sGamesizeof(sGame));
    if (!
StrEqual(sGame"left4dead"false) && !StrEqual(sGame"left4dead2"false))
    {
        
strcopy(errorerr_max"[BHP] Plugin Supports L4D And L4D2 Only!");
        return 
APLRes_SilentFailure;
    }
    
    return 
APLRes_Success;
}

public 
Plugin myinfo =
{
    
name "Hunter Fatal Jump",
    
author "cravenge <3",
    
description "Version king_oxo.",
    
version "3.12",
    
url ""
};

public 
void OnPluginStart()
{
    
CreateConVar("brutal_hunter_pounce_version""3.12""Brutal Hunter Pounce Version"FCVAR_NOTIFY|FCVAR_SPONLY|FCVAR_DONTRECORD);
    
bhpDistance CreateConVar("brutal_hunter_pounce_distance""1750.0""Distance To Make Deadly Hunter Pounces"FCVAR_NOTIFY|FCVAR_SPONLYtrue1.0);
    
bhpMaxAttempts CreateConVar("brutal_hunter_pounce_max_attempts""2""Maximum Attempts Of Brutal Hunter Pounces"FCVAR_NOTIFY|FCVAR_SPONLY);
    
bhpCoolTime CreateConVar("brutal_hunter_pounce_cool_time""60.0""Cool Time For Every Smashing Hunter Pounce"FCVAR_NOTIFY|FCVAR_SPONLY);
    
bhpShowDamage CreateConVar("brutal_hunter_pounce_show_damage""1""Enable/Disable Damage Display"FCVAR_NOTIFY|FCVAR_SPONLYtrue0.0true1.0);
    
bhpShowDistance CreateConVar("brutal_hunter_pounce_show_distance""1""Enable/Disable Distance Display"FCVAR_NOTIFY|FCVAR_SPONLYtrue0.0true1.0);
    
bhpShowKills CreateConVar("brutal_hunter_pounce_show_kills""1""Enable/Disable Kills Display"FCVAR_NOTIFY|FCVAR_SPONLYtrue0.0true1.0);
    
bhpAvgDistance CreateConVar("brutal_hunter_pounce_avg_distance""1""Enable/Disable Average Distance"FCVAR_NOTIFY|FCVAR_SPONLYtrue0.0true1.0);
    
bhpRankType CreateConVar("brutal_hunter_pounce_rank_type""0""Rank Type: 0=By Kills, 1=By Damage, 2=By Distance"FCVAR_NOTIFY|FCVAR_SPONLYtrue0.0true1.0);
    
bhpListMax CreateConVar("brutal_hunter_pounce_list_max""10""Maximum Number Of Players To List In The Stats"FCVAR_NOTIFY|FCVAR_SPONLYtrue3.0true10.0);
    
bhpListType CreateConVar("brutal_hunter_pounce_list_type""1""Stats Listing Type: 0=All Players, 1=Top Players Only"FCVAR_NOTIFY|FCVAR_SPONLYtrue0.0true1.0);
    
    
fDistance bhpDistance.FloatValue;
    
fCoolTime bhpCoolTime.FloatValue;
    
    
iMaxAttempts bhpMaxAttempts.IntValue;
    
iRankType bhpRankType.IntValue;
    
iListMax bhpListMax.IntValue;
    
iListType bhpListType.IntValue;
    
    
bShowDamage bhpShowDamage.BoolValue;
    
bShowDistance bhpShowDistance.BoolValue;
    
bShowKills bhpShowKills.BoolValue;
    
bAvgDistance bhpAvgDistance.BoolValue;
    
    
bhpDistance.AddChangeHook(OnBHPCVarsChanged);
    
bhpMaxAttempts.AddChangeHook(OnBHPCVarsChanged);
    
bhpCoolTime.AddChangeHook(OnBHPCVarsChanged);
    
bhpShowDamage.AddChangeHook(OnBHPCVarsChanged);
    
bhpShowDistance.AddChangeHook(OnBHPCVarsChanged);
    
bhpShowKills.AddChangeHook(OnBHPCVarsChanged);
    
bhpAvgDistance.AddChangeHook(OnBHPCVarsChanged);
    
bhpRankType.AddChangeHook(OnBHPCVarsChanged);
    
bhpListMax.AddChangeHook(OnBHPCVarsChanged);
    
bhpListType.AddChangeHook(OnBHPCVarsChanged);
    
    
AutoExecConfig(true"brutal_hunter_pounce");
    
    
HookEvent("round_start"OnRoundEvents);
    
HookEvent("round_end"OnRoundEvents);
    
HookEvent("map_transition"OnRoundEvents);
    
    
HookEvent("ability_use"OnAbilityUse);
    
HookEvent("lunge_pounce"OnLungePounce);
    
    
RegConsoleCmd("sm_hunthud"TogglePenalty"Toggles Penalty Notification");
    
RegConsoleCmd("sm_bhp_reset"ResetBHP"Resets Brutal Pounce Count");
    
    
//RegConsoleCmd("sm_bhp_list", ListBHP, "Displays List Of Brutal Pounces Made");
    
RegConsoleCmd("sm_tophunters"ListBHP"Displays List Of Brutal Pounces Made");
}

public 
void OnBHPCVarsChanged(ConVar cvar, const char[] oldValue, const char[] newValue)
{
    
fDistance bhpDistance.FloatValue;
    
fCoolTime bhpCoolTime.FloatValue;
    
    
iMaxAttempts bhpMaxAttempts.IntValue;
    
iRankType bhpRankType.IntValue;
    
iListMax bhpListMax.IntValue;
    
iListType bhpListType.IntValue;
    
    
bShowDamage bhpShowDamage.BoolValue;
    
bShowDistance bhpShowDistance.BoolValue;
    
bShowKills bhpShowKills.BoolValue;
    
bAvgDistance bhpAvgDistance.BoolValue;
}

public 
Action TogglePenalty(int clientint args)
{
    if (
client == || !IsClientInGame(client))
    {
        return 
Plugin_Handled;
    }
    
    if (
bShowPenalty[client])
    {
        
bShowPenalty[client] = false;
    }
    else
    {
        
bShowPenalty[client] = true;
    }
    
CPrintToChat(client"\x04Penalty Notification\x01: \x03%s", (bShowPenalty[client]) ? "\x03On" "\x03Off");
    return 
Plugin_Handled;
}

public 
Action ResetBHP(int clientint args) {
     if (
CheckCommandAccess(client""ADMFLAG_CUSTOM3true))
     {
         
AdminId clientId GetUserAdmin(client);
         if (
clientId == INVALID_ADMIN_ID || iPounces[client] == 0)
         {
          
PrintToChat(client"\x05CountDown Cannot \x03Be Reset \x05Because You Didn't Do \x04Brutal!");
           return 
Plugin_Handled;
          }
          
        if (
iPenalty[client] < && iPenaltyCounter[client] < 3
        {
            
iPenalty[client] = 0;
            
iPenaltyCounter[client]++;
            
CPrintToChat(client"\x05You Can Used \x03Counts Reset \x04(\x03%i\x05/\x033\x04)"iPenaltyCounter[client]);
        }
        else { 
            
CPrintToChat(client"\x05You Cannot Use Count Reset \x04Limit Reached.");
        }
        
    }
    else { 
        
PrintToChat (client"\x05No Acces");
    }
    return 
Plugin_Handled;  
}

public 
void OnClientDisconnect(int client) {
    
//If u want, let's set back to 0 once he's inside our server
    
iPenaltyCounter[client] = 0;
}


public 
Action ListBHP(int clientint args)
{
    if (
client == || !IsClientInGame(client))
    {
        return 
Plugin_Handled;
    }
    
    if (
iListPage[client] != 1)
    {
        
iListPage[client] = 1;
    }
    
BHPStats(client____iListPage[client]);
    
    return 
Plugin_Handled;
}

public 
void OnPluginEnd()
{
    
bhpDistance.RemoveChangeHook(OnBHPCVarsChanged);
    
bhpMaxAttempts.RemoveChangeHook(OnBHPCVarsChanged);
    
bhpCoolTime.RemoveChangeHook(OnBHPCVarsChanged);
    
bhpShowDamage.RemoveChangeHook(OnBHPCVarsChanged);
    
bhpShowDistance.RemoveChangeHook(OnBHPCVarsChanged);
    
bhpShowKills.RemoveChangeHook(OnBHPCVarsChanged);
    
bhpAvgDistance.RemoveChangeHook(OnBHPCVarsChanged);
    
bhpRankType.RemoveChangeHook(OnBHPCVarsChanged);
    
bhpListMax.RemoveChangeHook(OnBHPCVarsChanged);
    
bhpListType.RemoveChangeHook(OnBHPCVarsChanged);
    
    
//delete bhpDistance;
    
delete bhpMaxAttempts;
    
delete bhpCoolTime;
    
delete bhpShowDamage;
    
delete bhpShowDistance;
    
delete bhpShowKills;
    
//delete bhpAvgDistance;
    //delete bhpRankType;
    //delete bhpListMax;
    //delete bhpListType;
    
    
UnhookEvent("round_start"OnRoundEvents);
    
UnhookEvent("round_end"OnRoundEvents);
    
UnhookEvent("map_transition"OnRoundEvents);
    
    
UnhookEvent("ability_use"OnAbilityUse);
    
UnhookEvent("lunge_pounce"OnLungePounce);
}

public 
void OnMapStart()
{
    
GetCurrentMap(sMapsizeof(sMap));
    
    
PrecacheSound(HUNTERtrue);
    
    
InitPrecache();
    
    
//AddFileToDownloadsTable("sound/hunter_allu.mp3");
}

InitPrecache()
{
    
/* Precache models */
    
PrecacheModel("models/props_junk/propanecanister001a.mdl"true);
    
PrecacheModel("models/props_junk/gascan001a.mdl"true);
    
    
/* Precache particles */
    
PrecacheParticle("gas_explosion_main");
    
PrecacheParticle("electrical_arc_01_cp0");
    
PrecacheParticle("electrical_arc_01_system");
}

public 
void OnRoundEvents(Event event, const char[] namebool dontBroadcast)
{
    if (
fDistance 1.0)
    {
        return;
    }
    
    for (
int i 1<= MaxClientsi++)
    {
        if (
IsClientInGame(i))
        {
            
iPounces[i] = 0;
            
iPenalty[i] = 0;
            
iListPage[i] = 1;
            
bShowPenalty[i] = true;
            
            for (
int i2 0i2 3i2++)
            {
                
fPouncePos[i][i2] = 0.0;
            }
            if (
hPenaltyTime[i] != null)
            {
                if (
StrEqual(sGame"left4dead2"false))
                {
                    
KillTimer(hPenaltyTime[i]);
                }
                
hPenaltyTime[i] = null;
            }
        }
    }
}

public 
void OnAbilityUse(Event event, const char[] namebool dontBroadcast)
{
    if (
fDistance <= 0.0)
    {
        return;
    }
    
    
int user GetClientOfUserId(event.GetInt("userid"));
    if (
user || !IsClientInGame(user) || GetClientTeam(user) != || GetEntProp(userProp_Send"m_zombieClass") != 3)
    {
        return;
    }
    
    
char sAbility[24];
    
event.GetString("ability"sAbility24);
    if (
StrEqual(sAbility"ability_lunge"false))
    {
        if (
iPounces[user] <= iMaxAttempts)
        {
            
GetClientAbsOrigin(userfPouncePos[user]);
        }
        
        if (!
IsFakeClient(user))
        {
            
CreateTimer(0.1MakeFartherPounceuser);
        }
    }
}

public 
Action MakeFartherPounce(Handle timerany client)
{
    
KillTimer(timer);
    if (!
IsServerProcessing())
    {
        return 
Plugin_Stop;
    }
    
    
float fVelocity[3];
    
GetEntPropVector(clientProp_Data"m_vecVelocity"fVelocity);
    
    
fVelocity[0] *= 1.0;
    
fVelocity[1] *= 1.0;
    
fVelocity[2] *= 1.2;
    
    
TeleportEntity(clientNULL_VECTORNULL_VECTORfVelocity);
    return 
Plugin_Stop;
}

public 
void OnLungePounce(Event event, const char[] namebool dontBroadcast)
{
    if (
fDistance 1.0)
    {
        return;
    }
    
    
int pouncer GetClientOfUserId(event.GetInt("userid"));
    if (
pouncer || pouncer MaxClients || !IsClientInGame(pouncer) || GetClientTeam(pouncer) != || GetEntProp(pouncerProp_Send"m_zombieClass") != 3)
    {
        return;
    }
    
    
int pounced GetClientOfUserId(event.GetInt("victim"));
    if (
pounced || pounced MaxClients || !IsClientInGame(pounced) || GetClientTeam(pounced) != 2)
    {
        return;
    }
    
    
float fLandedPos[3];
    
GetClientAbsOrigin(pouncerfLandedPos);
    
    if (
GetVectorDistance(fPouncePos[pouncer], fLandedPos) < fDistance)
    {
        
CPrintToChat(pouncer"\x04Fatal Jump\x01 \x03Failed!\x01 \x05(\x04%.1f\x05 / \x04%.1f\x05)"GetVectorDistance(fPouncePos[pouncer], fLandedPos), fDistance);
        return;
    }
    
    if (
iPounces[pouncer] > iMaxAttempts)
    {
        
CPrintToChat(pouncer"\x03Maximum Limits Reached!\x01 \x04%s\x01", (GetUserAdmin(pouncer) == INVALID_ADMIN_ID) ? "" " \x03Please Wait Other Round\x01");
        return;
    }
    
    if (
iPenalty[pouncer] > 0)
    {
        if (!
bShowPenalty[pouncer])
        {
            
CPrintToChat(pouncer"\x04Fatal Jump\x01 For \x03Please Wait!\x01");
        }
        return;
    }
    
    
int iDmg = (GetEntProp(pouncedProp_Send"m_isIncapacitated"1)) ? GetClientHealth(pounced) : (GetClientHealth(pounced) + FindConVar("survivor_incap_health").IntValue);
    
BHPStats(pouncer1iDmgRoundFloat(GetVectorDistance(fPouncePos[pouncer], fLandedPos)), true);
    
    
Event ePlayerHurt CreateEvent("player_hurt"true);
    
ePlayerHurt.SetInt("userid"GetClientUserId(pounced));
    
ePlayerHurt.SetInt("attacker"GetClientUserId(pouncer));
    
ePlayerHurt.SetString("weapon""hunter_claw");
    
ePlayerHurt.SetInt("dmg_health"iDmg);
    
ePlayerHurt.Fire();
    
    if (!
GetEntProp(pouncedProp_Send"m_isIncapacitated"1) && GetEntProp(pouncedProp_Send"m_currentReviveCount") < FindConVar("survivor_max_incapacitated_count").IntValue)
    {
        
Event ePlayerIncapacitated CreateEvent("player_incapacitated"true);
        
ePlayerIncapacitated.SetInt("userid"GetClientUserId(pounced));
        
ePlayerIncapacitated.SetInt("attacker"GetClientUserId(pouncer));
        
ePlayerIncapacitated.SetString("weapon""hunter_claw");
        
ePlayerIncapacitated.Fire();
    }
    
ForcePlayerSuicide(pounced);
    
EmitSoundToAll(HUNTERSNDCHAN_WEAPONSNDLEVEL_SCREAMING);
    
ExplodeMain(fLandedPos);
    
    
Event ePlayerDeath CreateEvent("player_death"true);
    
ePlayerDeath.SetInt("userid"GetClientUserId(pounced));
    
ePlayerDeath.SetInt("attacker"GetClientUserId(pouncer));
    
ePlayerDeath.SetString("weapon""hunter_claw");
    
ePlayerDeath.Fire();
    
    
iPounces[pouncer] += 1;
    
CPrintToChat(pouncer"\x05Your Hunter Kills In This Round: \x04(\x01\x03%d / %i\x01\x04)\x01"iPounces[pouncer], iMaxAttempts 1);
    
    if (
bShowDamage && bShowDistance)
    {
        
CPrintToChatAll("\x03%N\x01 \x05Was\x01 Brutally Pounced \x05By\x01 \x03%N\x01 \x05From A Deadly Distance\x01 \x04[\x01%.2f\x04]\x01 \x05And Got His\x01 Spine Broken."pouncedpouncerGetVectorDistance(fPouncePos[pouncer], fLandedPos));
    }
    
/*else if (bShowDamage)
    {
        CPrintToChatAll("{orange}[{red}HUNTER{orange}] {olive}%N{default} Brutally Pounced {olive}%N! {orange}[%i Dmg]", pouncer, pounced, iDmg);
    }
    else if (bShowDistance)
    {
        CPrintToChatAll("\x03%N\x01 \x05Was\x01 Brutally Pounced \x05By\x01 \x03%N\x01 \x05From A Deadly Distance\x01 \x04[\x01%.2f\x04]\x01 \x05And Got His\x01 Spine Broken.", pouncer, pounced, GetVectorDistance(fPouncePos[pouncer], fLandedPos));
    }
    else
    {
        CPrintToChatAll("\x03%N\x01 \x05Was\x01 Brutally Pounced \x05By\x01 \x03%N\x01 \x05From A Deadly Distance\x01 \x04[\x01%.2f\x04]\x01 \x05And Got His\x01 Spine Broken.", pouncer, pounced);
    }
    */
    
if (hPenaltyTime[pouncer] == null)
    {
        
iPenalty[pouncer] = RoundToNearest(fCoolTime iPounces[pouncer]);
        
hPenaltyTime[pouncer] = CreateTimer(1.0ShowNextBPpouncerTIMER_FLAG_NO_MAPCHANGE|TIMER_REPEAT);
    }
}

public 
Action ShowNextBP(Handle timerany client)
{
    if (!
IsClientInGame(client))
    {
        if (
hPenaltyTime[client] != null)
        {
            if (
StrEqual(sGame"left4dead2"false))
            {
                
KillTimer(hPenaltyTime[client]);
            }
            
hPenaltyTime[client] = null;
        }
        return 
Plugin_Stop;
    }
    
    if (
hPenaltyTime[client] == null)
    {
        return 
Plugin_Stop;
    }
    
    if (
iPenalty[client] < 1)
    {
        
CPrintToChat(client"\x05Again You Can Make\x01 \x04A Fatal Jump.\x01");
        
        if (
hPenaltyTime[client] != null)
        {
            if (
StrEqual(sGame"left4dead2"false))
            {
                
KillTimer(hPenaltyTime[client]);
            }
            
hPenaltyTime[client] = null;
        }
        return 
Plugin_Stop;
    }
    
    if (
bShowPenalty[client])
    {
        
PrintHintText(client"Wait %d %s For You Next Fatal Jump\nType !hunthud To Hide This Timer"iPenalty[client], (iPenalty[client] == 1) ? "Second" "Seconds");
    }
    
iPenalty[client] -= 1;
    return 
Plugin_Continue;
}

void BHPStats(int clientint iKill 0int iDamage 0int iDistance 0bool bUpdate falseint iPage 1)
{
    
char sRequirePath[PLATFORM_MAX_PATH];
    
BuildPath(Path_SMsRequirePathsizeof(sRequirePath), "data/bhpstats");
    if (!
DirExists(sRequirePath))
    {
        
CreateDirectory(sRequirePathFPERM_O_READ|FPERM_O_WRITE|FPERM_O_EXEC);
    }
    
    
BuildPath(Path_SMsRequirePathsizeof(sRequirePath), "data/bhpstats/%s.txt"sMap);
    
KeyValues kvStats = new KeyValues("bhpstats");
    
    if (!
bUpdate)
    {
        if (!
kvStats.ImportFromFile(sRequirePath))
        {
            
CPrintToChat(client"\x04[\x05SM\x04]\x01 No Saved Data!");
            
delete kvStats;
            
            return;
        }
        
        
kvStats.JumpToKey("pouncers");
        
int iTotal kvStats.GetNum("total"0);
        
        
decl String:bhpNames[iTotal][MAX_NAME_LENGTH];
        new 
bhpRecord[iTotal][4];
        
        
kvStats.GoBack();
        
kvStats.JumpToKey("records");
        
kvStats.GotoFirstSubKey();
        
        for (
int i 0iTotali++)
        {
            
kvStats.GetString("name"bhpNames[i], MAX_NAME_LENGTH"Unknown Player");
            
            
bhpRecord[i][0] = i;
            
//bhpRecord[i][1] = kvStats.GetNum("kills", 0);
            //bhpRecord[i][2] = kvStats.GetNum("dmg", 0);
            
bhpRecord[i][3] = kvStats.GetNum("dist"0);
            
            
kvStats.GotoNextKey();
        }
        
        
SortCustom2D(bhpRecordiTotalBPRankSort);
        
        
Panel pStats = new Panel();
        
        
char sTitle[128];
        
Format(sTitlesizeof(sTitle), "MAP: (%s)"sMap);
        
pStats.SetTitle(sTitle);
        
        
pStats.DrawText(" \n");
        
        
char sTextList[128];
        for (
int i = (iListType == && iPage 1) ? iListMax iPage 0iTotali++)
        {
            if (
bShowKills)
            {
                if (
bShowDamage && bShowDistance)
                {
                    if (
== 0)
                    {
                        if (
bAvgDistance)
                        {
                            
strcopy(sTextListsizeof(sTextList), "No.    Name     |  Avg. Distance");
                        }
                        else
                        {
                            
strcopy(sTextListsizeof(sTextList), "No.    Name     |  Avg. Distance");
                        }
                        
pStats.DrawText(sTextList);
                    }
                    
Format(sTextListsizeof(sTextList), "%i. %s  | %d"1bhpNames[bhpRecord[i][0]], bhpRecord[i][3]);
                }
                else if (
bShowDamage)
                {
                    if (
== 0)
                    {
                        
strcopy(sTextListsizeof(sTextList), "No.    Name     |  Avg. Distance");
                        
pStats.DrawText(sTextList);
                    }
                    
Format(sTextListsizeof(sTextList), "%i. %s  | %d"1bhpNames[bhpRecord[i][0]], bhpRecord[i][3]);
                }
                else if (
bShowDistance)
                {
                    if (
== 0)
                    {
                        if (
bAvgDistance)
                        {
                            
strcopy(sTextListsizeof(sTextList), "No.    Name     |  Avg. Distance");
                        }
                        else
                        {
                            
strcopy(sTextListsizeof(sTextList), "No.    Name     |  Avg. Distance");
                        }
                        
pStats.DrawText(sTextList);
                    }
                    
Format(sTextListsizeof(sTextList), "%i. %s  | %d"i+1bhpNames[bhpRecord[i][0]], bhpRecord[i][3]);
                }
                else
                {
                    if (
== 0)
                    {
                        
strcopy(sTextListsizeof(sTextList), "No.    Name    -  Kills");
                        
pStats.DrawText(sTextList);
                    }
                    
Format(sTextListsizeof(sTextList), "%i. %s - %d"1bhpNames[bhpRecord[i][0]], bhpRecord[i][1]);
                }
            }
            else
            {
                if (
bShowDamage && bShowDistance)
                {
                    if (
== 0)
                    {
                        if (!
bAvgDistance)
                        {
                            
strcopy(sTextListsizeof(sTextList), "No.    Name     |  Avg. Distance");
                        }
                        else
                        {
                            
strcopy(sTextListsizeof(sTextList), "No.    Name     |  Avg. Distance");
                        }
                        
pStats.DrawText(sTextList);
                    }
                    
Format(sTextListsizeof(sTextList), "%i. %s  | %d"1bhpNames[bhpRecord[i][0]], bhpRecord[i][3]);
                }
                else if (
bShowDamage)
                {
                    if (
== 0)
                    {
                        
strcopy(sTextListsizeof(sTextList), "No.    Name    -  Damage");
                        
pStats.DrawText(sTextList);
                    }
                    
Format(sTextListsizeof(sTextList), "%i. %s - %d"1bhpNames[bhpRecord[i][0]], bhpRecord[i][2]);
                }
                else if (
bShowDistance)
                {
                    if (
== 0)
                    {
                        if (!
bAvgDistance)
                        {
                            
strcopy(sTextListsizeof(sTextList), "No.    Name    -  Distance");
                        }
                        else
                        {
                            
strcopy(sTextListsizeof(sTextList), "No.    Name    -  Avg. Distance");
                        }
                        
pStats.DrawText(sTextList);
                    }
                    
Format(sTextListsizeof(sTextList), "%i. %s - %d"1bhpNames[bhpRecord[i][0]], bhpRecord[i][3]);
                }
                else
                {
                    if (
== 0)
                    {
                        
strcopy(sTextListsizeof(sTextList), "No.    Name    ");
                        
pStats.DrawText(sTextList);
                    }
                    
Format(sTextListsizeof(sTextList), "%i. %s"1bhpNames[bhpRecord[i][0]]);
                }
            }
            
pStats.DrawText(sTextList);
            
            if (
>= (iListMax iPage) - || >= iTotal)
            {
                
pStats.DrawText(" \n");
                
                if (
iListType != 1)
                {
                    if (
iPage 1)
                    {
                        
pStats.DrawItem("Back");
                    }
                    
                    if (
iListMax iTotal)
                    {
                        
pStats.DrawItem("Next");
                    }
                    
pStats.DrawText(" \n");
                }
                
                break;
            }
        }
        
        
Format(sTextListsizeof(sTextList), "%d Brutal %s Recorded On This Map!"iTotal, (iTotal 1) ? "Pouncers" "Pouncer");
        
pStats.DrawText(sTextList);
        
        
pStats.Send(clientpStatsHandler20);
        
delete pStats;
    }
    else
    {
        
char sFileVersion[16];
        
kvStats.GetString("Version"sFileVersionsizeof(sFileVersion), "0.0");
        if (
FileExists(sRequirePath) && !StrEqual(sFileVersion"3.12"false))
        {
            
DeleteFile(sRequirePath);
        }
        
        
char sName[MAX_NAME_LENGTH], sSteamID[32];
        
int iTotaliTotalKilliTotalDmgiTotalDist;
        
        
GetClientName(clientsNamesizeof(sName));
        
GetClientAuthString(clientsSteamIDsizeof(sSteamID));
        
        
kvStats.ImportFromFile(sRequirePath);
        
kvStats.SetString("version""3.12");
        
kvStats.JumpToKey("records"true);
        
        if (!
kvStats.JumpToKey(sSteamID))
        {
            
kvStats.GoBack();
            
kvStats.JumpToKey("pouncers"true);
            
            
iTotal kvStats.GetNum("total"0);
            
iTotal += 1;
            
            
kvStats.SetNum("total"iTotal);
            
kvStats.GoBack();
            
            
kvStats.JumpToKey("records");
            
kvStats.JumpToKey(sSteamIDtrue);
        }
        
        
kvStats.SetString("name"sName);
        
        
iTotalKill kvStats.GetNum("kills"0);
        
iTotalKill += 1;
        
        
kvStats.SetNum("kills"iTotalKill);
        
        
iTotalDmg kvStats.GetNum("dmg"0);
        
iTotalDmg += iDamage;
        
        
kvStats.SetNum("dmg"iTotalDmg);
        
        
iTotalDist kvStats.GetNum("dist"0);
        
iTotalDist += iDistance;
        
        if (
bAvgDistance)
        {
            
kvStats.SetNum("dist"RoundFloat(float(iTotalDist) / float(iTotalKill)));
        }
        else
        {
            
kvStats.SetNum("dist"iTotalDist);
        }
        
        
kvStats.Rewind();
        
kvStats.ExportToFile(sRequirePath);
    }
    
    
delete kvStats;
}

public 
int BPRankSort(int[] array1int[] array2, const int[][] completeArrayHandle hndl)
{
    if (
array1[iRankType+1] > array2[iRankType+1])
    {
        return -
1;
    }
    
    if (
array1[iRankType+1] == array2[iRankType+1])
    {
        return 
0;
    }
    
    return 
1;
}

public 
int pStatsHandler(Menu menuMenuAction actionint param1int param2)
{
    if (
action == MenuAction_Select && iListType != 0)
    {
        if (
param1 && param1 <= MaxClients && IsClientInGame(param1))
        {
            
iListPage[param1] += (param2 == 1) ? : (-1);
            
BHPStats(param1____iListPage[param1]);
        }
    }
}

public 
ExplodeMain(Float:pos[3])
{
    
ShowParticle(pos"electrical_arc_01_system"5.0);
    
LittleFlower(posEXPLODE);
    
ShowParticle(pos"gas_explosion_main"5.0);
    
LittleFlower(posMOLOTOV);
}

public 
ShowParticle(Float:pos[3], String:particlename[], Float:time)
{
    
/* Show particle effect you like */
    
new particle CreateEntityByName("info_particle_system");
    if (
IsValidEdict(particle))
    {
        
TeleportEntity(particleposNULL_VECTORNULL_VECTOR);
        
DispatchKeyValue(particle"effect_name"particlename);
        
DispatchKeyValue(particle"targetname""particle");
        
DispatchSpawn(particle);
        
ActivateEntity(particle);
        
AcceptEntityInput(particle"start");
        
CreateTimer(timeDeleteParticlesparticle);
    }  
}

public 
PrecacheParticle(String:particlename[])
{
    
/* Precache particle */
    
new particle CreateEntityByName("info_particle_system");
    if (
IsValidEdict(particle))
    {
        
DispatchKeyValue(particle"effect_name"particlename);
        
DispatchKeyValue(particle"targetname""particle");
        
DispatchSpawn(particle);
        
ActivateEntity(particle);
        
AcceptEntityInput(particle"start");
        
CreateTimer(0.01DeleteParticlesparticle);
    }  
}

public 
Action:DeleteParticles(Handle:timerany:particle)
{
    
/* Delete particle */
    
if (IsValidEntity(particle))
    {
        new 
String:classname[64];
        
GetEdictClassname(particleclassnamesizeof(classname));
        if (
StrEqual(classname"info_particle_system"false))
                    
RemoveEdict(particle);
    }
}

public 
LittleFlower(Float:pos[3], type)
{
    
/* Cause fire(type=0) or explosion(type=1) */
    
new entity CreateEntityByName("prop_physics");
    if (
IsValidEntity(entity))
    {
        
pos[2] += 10.0;
        if (
type == 0)
            
/* fire */
            
DispatchKeyValue(entity"model""models/props_junk/gascan001a.mdl");
        else
            
/* explode */
            
DispatchKeyValue(entity"model""models/props_junk/propanecanister001a.mdl");
        
DispatchSpawn(entity);
        
SetEntData(entityGetEntSendPropOffs(entity"m_CollisionGroup"), 11true);
        
TeleportEntity(entityposNULL_VECTORNULL_VECTOR);
        
AcceptEntityInput(entity"break");
    }

__________________
HTML Code:
<a href="https://www.gametracker.com/server_info/157.90.180.232:27215/" target="_blank"><img src="https://cache.gametracker.com/server_info/157.90.180.232:27215/b_560_95_1.png" border="0" width="560" height="95" alt=""/></a>

Last edited by Darkwob; 09-28-2021 at 13:53.
Darkwob is offline
Send a message via AIM to Darkwob Send a message via Yahoo to Darkwob Send a message via Skype™ to Darkwob
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 14:35.


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