View Single Post
micapat
Veteran Member
Join Date: Feb 2010
Location: Nyuu, nyuu (France).
Old 07-14-2018 , 18:37   Re: CS:GO Give Player P250 after Killing 5 Enemy with Knife
Reply With Quote #4

PHP Code:
/* ========================================================================= */
/* INCLUDES                                                                  */
/* ========================================================================= */

#include <sourcemod> 
#include <sdkhooks> 
#include <sdktools> 

#pragma semicolon 1
#pragma newdecls  required

/* ========================================================================= */
/* DEFINES                                                                   */
/* ========================================================================= */

#define C_KILL_TRIGGER  (5)

/* ========================================================================= */
/* GLOBAL VARIABLES                                                          */
/* ========================================================================= */

int gl_iPlayerKillCounter[MAXPLAYERS 1];
int gl_iPlayerP250;

/* ========================================================================= */
/* FUNCTIONS                                                                 */
/* ========================================================================= */

/* ------------------------------------------------------------------------- */
/* Plugin                                                                    */
/* ------------------------------------------------------------------------- */

public void OnPluginStart()  

    
HookEvent("round_prestart"OnRoundPreStartPost);
    
HookEvent("player_death",   OnPlayerDeathPost); 


/* ------------------------------------------------------------------------- */
/* Round                                                                     */
/* ------------------------------------------------------------------------- */

public void OnRoundPreStartPost(Handle hEvent, const char[] szNamebool bDontBroadcast)
{
    
gl_iPlayerP250 0;
}

/* ------------------------------------------------------------------------- */
/* Client                                                                    */
/* ------------------------------------------------------------------------- */

public void OnClientConnected(int iClient

    
gl_iPlayerKillCounter[iClient] = 0


public 
void OnClientPutInServer(int iClient

    
SDKHook(iClientSDKHook_SpawnPostOnPlayerSpawnPost); 


public 
void OnClientDisconnect(int iClient
{
    
gl_iPlayerKillCounter[iClient] = 0
    
    if (
gl_iPlayerP250 == iClient)
    {
        
gl_iPlayerP250 0;
    }
}

/* ------------------------------------------------------------------------- */
/* Player                                                                    */
/* ------------------------------------------------------------------------- */

public void OnPlayerSpawnPost(int iPlayer

    if (
IsPlayerAlive(iPlayer)) 
    { 
        
gl_iPlayerKillCounter[iPlayer] = 0
    } 
}

public 
void OnPlayerDeathPost(Event hEvent, const char[] szNamebool bDontBroadcast
{
    
int iVictim GetClientOfUserId(hEvent.GetInt("userid"));
    
    if (
gl_iPlayerP250 == iVictim)
    {
        
gl_iPlayerP250 0;
    }
    else if (
gl_iPlayerP250 == 0)
    {
        
char szWeapon[32]; 
        
        
hEvent.GetString("weapon"szWeaponsizeof(szWeapon)); 
        
        if ((
StrContains(szWeapon"knife") != -1) || (StrContains(szWeapon"bayonet") != -1)) 
        { 
            
int iAttacker GetClientOfUserId(hEvent.GetInt("attacker"));
            
            if ((
<= iAttacker <= MaxClients) && IsClientInGame(iAttacker))
            {
                
gl_iPlayerKillCounter[iAttacker]++; 
                
                if (
gl_iPlayerKillCounter[iAttacker] == C_KILL_TRIGGER
                {
                    
GivePlayerItem(iAttacker"weapon_p250"); 
                    
                    
gl_iPlayerP250 iAttacker;
                } 
            } 
        }
    }
}

/* ========================================================================= */ 
__________________

Last edited by micapat; 07-14-2018 at 20:06.
micapat is offline