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

levelrank - teamkill


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
szogun
Senior Member
Join Date: Apr 2016
Old 03-27-2018 , 15:24   levelrank - teamkill
Reply With Quote #1

Hello
Trying to rework a slightly level rank plug in order for the teamkill not to deduct points only to give the player a point when he kills someone from his team

PHP Code:
void MakeHooks()
{
    
HookLR(weapon_fire);
    
HookLR(player_death);
    
HookLR(player_hurt);
    
HookLR(round_mvp);
    
HookLR(round_end);
    
HookLR(round_start);
    
HookLR(bomb_planted);
    
HookLR(bomb_defused);
    
HookLR(bomb_dropped);
    
HookLR(bomb_pickup);
    
HookLR(hostage_killed);
    
HookLR(hostage_rescued);
}

public 
void LRHooks(Handle hEventchar[] sEvNamebool bDontBroadcast)
{
    switch(
sEvName[0])
    {
        case 
'w':
        {
            
int iClient GetClientOfUserId(GetEventInt(hEvent"userid"));
            if(
g_bInitialized[iClient] && IsClientInGame(iClient))
            {
                
char sWeaponName[64];
                
GetEventString(hEvent"weapon"sWeaponNamesizeof(sWeaponName));
                if(!
StrEqual(sWeaponName"hegrenade") || !StrEqual(sWeaponName"flashbang") || !StrEqual(sWeaponName"smokegrenade") || !StrEqual(sWeaponName"molotov") || !StrEqual(sWeaponName"incgrenade") || !StrEqual(sWeaponName"decoy"))
                {
                    
SHOOTS(iClient)++;
                }
            }
        }

        case 
'p':
        {
            switch(
sEvName[7])
            {
                case 
'h':
                {
                    
int iClient GetClientOfUserId(GetEventInt(hEvent"userid"));
                    
int iAttacker GetClientOfUserId(GetEventInt(hEvent"attacker"));

                    if(
iClient && iAttacker && iAttacker != iClient && g_bInitialized[iClient] && g_bInitialized[iAttacker] && IsClientInGame(iClient) && IsClientInGame(iAttacker))
                    {
                        if(
GetEventInt(hEvent"hitgroup"))
                        {
                            
HITS(iAttacker)++;
                        }
                    }
                }

                case 
'd':
                {
                    
int iClient GetClientOfUserId(GetEventInt(hEvent"userid"));
                    
int iAttacker GetClientOfUserId(GetEventInt(hEvent"attacker"));

                    if(!
iAttacker || !iClient)
                        return;

                    if(
IsFakeClient(iClient) || IsFakeClient(iAttacker))
                        return;

                    if(
iAttacker == iClient)
                    {
                        
NotifClient(iClient, -g_iGiveSuicideg_iGiveSuicide"Suicide");
                    }
                    else
                    {
                        if(
GetClientTeam(iClient) == GetClientTeam(iAttacker))
                        {
                            
NotifClient(iAttacker, -g_iGiveTeamKillg_iGiveTeamKill"TeamKill");
                        }
                        else
                        {
                            if(
g_iTypeStatistics != 1)
                            {
                                
NotifClient(iAttackerg_iGiveKillg_iGiveKill"Kill");
                                
NotifClient(iClient, -g_iGiveDeathg_iGiveDeath"MyDeath");
                            }
                            else
                            {
                                
int iRankAttacker EXP(iAttacker);
                                
int iRankVictim EXP(iClient);

                                if(
iRankAttacker == 0iRankAttacker 1;
                                if(
iRankVictim == 0iRankVictim 1;

                                
int iExpCoeff RoundToNearest((float(iRankVictim) / float(iRankAttacker)) * g_fKillCoeff);

                                if(
iExpCoeff 1iExpCoeff 1;

                                if((
KILLS(iAttacker) > 9) || (DEATHS(iAttacker) > 9)) NotifClient(iAttackeriExpCoeffiExpCoeff"Kill");
                                else 
NotifClient(iAttackerg_iGiveCalibrationg_iGiveCalibration"CalibrationPlus");

                                if((
KILLS(iClient) > 9) || (DEATHS(iClient) > 9)) NotifClient(iClient, -iExpCoeffiExpCoeff"MyDeath");
                                else 
NotifClient(iClient, -g_iGiveCalibrationg_iGiveCalibration"CalibrationMinus");
                            }

                            if(
GetEventBool(hEvent"headshot") && g_bInitialized[iAttacker])
                            {
                                
HEADSHOTS(iAttacker)++;
                                
NotifClient(iAttackerg_iGiveHeadShotg_iGiveHeadShot"HeadShotKill");
                            }

                            if(
g_iEngineGame == EngineGameCSGO)
                            {
                                
int iAssister GetClientOfUserId(GetEventInt(hEvent"assister"));
                                if(
iAssister && g_bInitialized[iAssister])
                                {
                                    
ASSISTS(iAssister)++;
                                    
NotifClient(iAssisterg_iGiveAssistg_iGiveAssist"AssisterKill");
                                }
                            }

                            if(
g_bInitialized[iAttacker])
                            {
                                
KILLS(iAttacker)++;
                                
g_iKillstreak[iAttacker]++;
                            }
                        }
                    }

                    if(
g_bInitialized[iClient])
                    {
                        
DEATHS(iClient)++;
                    }

                    
GiveExpForStreakKills(iClient);
                }
            }
        }

        case 
'r':
        {
            switch(
sEvName[6])
            {
                case 
'e':
                {
                    
int iTeamcheckteam;
                    for(
int iClient 1iClient <= MaxClientsiClient++)
                    {
                        if(
IsClientInGame(iClient))
                        {
                            if(
IsPlayerAlive(iClient))
                            {
                                
GiveExpForStreakKills(iClient);
                            }

                            if((
checkteam GetEventInt(hEvent"winner")) > 1)
                            {
                                if((
iTeam GetClientTeam(iClient)) > 1)
                                {
                                    if(
iTeam == checkteam)
                                    {
                                        
NotifClient(iClientg_iRoundWing_iRoundWin"RoundWin");
                                    }
                                    else 
NotifClient(iClient, -g_iRoundLoseg_iRoundLose"RoundLose");
                                }
                            }
                        }
                    }
                }

                case 
'm'NotifClient(GetClientOfUserId(GetEventInt(hEvent"userid")), g_iRoundMVPg_iRoundMVP"RoundMVP");

                case 
's':
                {
                    
GetCountPlayers();
                    
g_iCountPlayers 0;

                    for(
int i 1<= MaxClientsi++)
                    {
                        if(
g_bInitialized[i] && IsClientInGame(i))
                        {
                            
GetPlacePlayer(i);
                            
g_iCountPlayers++;
                        }
                    }

                    if(
g_bSpawnMessage)
                    {
                        
char sMessage[PLATFORM_MAX_PATH];
                        
bool bWarningMessage false;
                        if(
g_iCountPlayers g_iMinimumPlayers && g_iTypeStatistics != 2)
                        {
                            
bWarningMessage true;
                        }

                        for(
int i 1<= MaxClientsi++)
                        {
                            if(
bWarningMessage)
                            {
                                
FormatEx(sMessagesizeof(sMessage), "%T""RoundStartCheckCount"ig_iCountPlayersg_iMinimumPlayers);
                                
LR_PrintToChat(i"%s"sMessage);
                            }

                            
FormatEx(sMessagesizeof(sMessage), "%T""RoundStartMessageRanks"ig_sMainMenuStr);
                            
LR_PrintToChat(i"%s"sMessage);
                        }
                    }
                }
            }
        }

        case 
'b':
        {
            
int iClient GetClientOfUserId(GetEventInt(hEvent"userid"));
            switch(
sEvName[6])
            {
                case 
'l'g_bHaveBomb[iClient] = falseNotifClient(iClientg_iBombPlantedg_iBombPlanted"BombPlanted");
                case 
'e'NotifClient(iClientg_iBombDefusedg_iBombDefused"BombDefused");
                case 
'r': if(g_bHaveBomb[iClient]) {g_bHaveBomb[iClient] = falseNotifClient(iClient, -g_iBombDroppedg_iBombDropped"BombDropped");}
                case 
'i': if(!g_bHaveBomb[iClient]) {g_bHaveBomb[iClient] = trueNotifClient(iClientg_iBombPickupg_iBombPickup"BombPickup");}
            }
        }

        case 
'h':
        {
            
int iClient GetClientOfUserId(GetEventInt(hEvent"userid"));
            switch(
sEvName[8])
            {
                case 
'k'NotifClient(iClient, -g_iHostageKilledg_iHostageKilled"HostageKilled");
                case 
'r'NotifClient(iClientg_iHostageRescuedg_iHostageRescued"HostageRescued");
            }
        }
    }
}

void GiveExpForStreakKills(int iClient)
{
    if(
g_iKillstreak[iClient] > 1)
    {
        switch(
g_iKillstreak[iClient])
        {
            case 
2NotifClient(iClientg_iBonus[0], g_iBonus[0], "DoubleKill");
            case 
3NotifClient(iClientg_iBonus[1], g_iBonus[1], "TripleKill");
            case 
4NotifClient(iClientg_iBonus[2], g_iBonus[2], "Domination");
            case 
5NotifClient(iClientg_iBonus[3], g_iBonus[3], "Rampage");
            case 
6NotifClient(iClientg_iBonus[4], g_iBonus[4], "MegaKill");
            case 
7NotifClient(iClientg_iBonus[5], g_iBonus[5], "Ownage");
            case 
8NotifClient(iClientg_iBonus[6], g_iBonus[6], "UltraKill");
            case 
9NotifClient(iClientg_iBonus[7], g_iBonus[7], "KillingSpree");
            case 
10NotifClient(iClientg_iBonus[8], g_iBonus[8], "MonsterKill");
            case 
11NotifClient(iClientg_iBonus[9], g_iBonus[9], "Unstoppable");
            default: 
NotifClient(iClientg_iBonus[10], g_iBonus[10], "GodLike");
        }
    }

    
g_iKillstreak[iClient] = 0;
    
SaveDataPlayer(iClient);

szogun is offline
stickz
Senior Member
Join Date: Oct 2012
Location: Ontario, Canada
Old 03-27-2018 , 20:10   Re: levelrank - teamkill
Reply With Quote #2

This code is crude. It's nearly impossible to understand. You should create more functions and comment things. Other people can't help you when the code is this messy. Also use new syntax.

Example: Declare event properly and don't repeat these lines multiple times in switch statements.
Code:
public void LRHooks(Event hEvent, char[] sEvName, bool bDontBroadcast) 
{ 
    int iClient = GetClientOfUserId(hEvent.GetInt("userid"));
    int iAttacker = GetClientOfUserId(hEvent.GetInt("attacker"));
}
Edit: A new event needs to be created for these things. It's too messy calling the same event hook for unrelated tasks.

Last edited by stickz; 03-27-2018 at 20:40.
stickz 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 18:07.


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