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

Solved CS:GO Give Player P250 after Killing 5 Enemy with Knife


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
iskenderkebab33
Senior Member
Join Date: Jun 2018
Old 07-14-2018 , 18:02   CS:GO Give Player P250 after Killing 5 Enemy with Knife
Reply With Quote #1

Hey, as the title says, i need a Plugin where Player gets a P250 (weapon_p250) after Killing 5 Enemys with the Knife.

- 5 Kills with Knife to get a P250
- By Death Counter will be reseted

Thanks.

Last edited by iskenderkebab33; 11-03-2018 at 17:34.
iskenderkebab33 is offline
micapat
Veteran Member
Join Date: Feb 2010
Location: Nyuu, nyuu (France).
Old 07-14-2018 , 18:13   Re: CS:GO Give Player P250 after Killing 5 Enemy with Knife
Reply With Quote #2

Need more information. Should the kill counter reset after a death? after a respawn? after a round restart?
__________________
micapat is offline
iskenderkebab33
Senior Member
Join Date: Jun 2018
Old 07-14-2018 , 18:29   Re: CS:GO Give Player P250 after Killing 5 Enemy with Knife
Reply With Quote #3

Quote:
Originally Posted by micapat View Post
Need more information. Should the kill counter reset after a death? after a respawn? after a round restart?
yes that would be nice
iskenderkebab33 is offline
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
iskenderkebab33
Senior Member
Join Date: Jun 2018
Old 07-14-2018 , 18:40   Re: CS:GO Give Player P250 after Killing 5 Enemy with Knife
Reply With Quote #5

Quote:
Originally Posted by micapat View Post
I'm not sure that it detects all the deaths with a knife:

PHP Code:
#include <sourcemod>
#include <sdkhooks>
#include <sdktools>

int gl_iPlayerKill[MAXPLAYERS 1];

public 
OnPluginStart() 
{
    
HookEvent("player_death"OnPlayerDeathPost);
}

public 
void OnClientConnected(int iClient)
{
    
gl_iPlayerKill[iClient] = 0;
}

public 
void OnClientPutInServer(int iClient)
{
    
SDKHook(iClientSDKHook_SpawnPostOnPlayerSpawnPost);
}

public 
void OnClientDisconnect(int iClient)
{
    
gl_iPlayerKill[iClient] = 0;
}

public 
void OnPlayerSpawnPost(int iPlayer)
{
    if (
IsPlayerAlive(iPlayer))
    {
        
gl_iPlayerKill[iPlayer] = 0;
    }
}

public 
void OnPlayerDeathPost(Event hEvent, const char[] szNamebool bDontBroadcast)
{
    
char szWeapon[32];
    
    
// Get the weapon name
    
hEvent.GetString("weapon"szWeaponsizeof(szWeapon));
    
    
// Check if the weapon is a knife
    
if (StrEqual(szWeapon"knife") || StrEqual(szWeapon"bayonet"))
    {
        
// Get the attacker
        
int iAttacker hEvent.GetInt("attacker");
        
        
// Check if it's a valid player
        
if ((<= iAttacker <= MaxClients) && IsClientInGame(iAttacker) && IsPlayerAlive(iAttacker))
        {
            
gl_iPlayerKill[iAttacker]++;
            
            if (
gl_iPlayerKill[iAttacker] == 5)
            {
                
GivePlayerItem(iAttacker"weapon_p250");
            }
        }
    }

thanks, gona test it now.
iskenderkebab33 is offline
micapat
Veteran Member
Join Date: Feb 2010
Location: Nyuu, nyuu (France).
Old 07-14-2018 , 18:42   Re: CS:GO Give Player P250 after Killing 5 Enemy with Knife
Reply With Quote #6

I just update 'if ((StrContains(szWeapon, "knife") != -1) || (StrContains(szWeapon, "bayonet") != -1))', it should work better
__________________
micapat is offline
iskenderkebab33
Senior Member
Join Date: Jun 2018
Old 07-14-2018 , 18:47   Re: CS:GO Give Player P250 after Killing 5 Enemy with Knife
Reply With Quote #7

Quote:
Originally Posted by micapat View Post
I just update 'if ((StrContains(szWeapon, "knife") != -1) || (StrContains(szWeapon, "bayonet") != -1))', it should work better
Code befor did'nt work, will test this now
iskenderkebab33 is offline
iskenderkebab33
Senior Member
Join Date: Jun 2018
Old 07-14-2018 , 18:51   Re: CS:GO Give Player P250 after Killing 5 Enemy with Knife
Reply With Quote #8

Quote:
Originally Posted by micapat View Post
I just update 'if ((StrContains(szWeapon, "knife") != -1) || (StrContains(szWeapon, "bayonet") != -1))', it should work better
1 issue, a Random Player will get the P250 not the Killer. I think you need to input iClient
iskenderkebab33 is offline
micapat
Veteran Member
Join Date: Feb 2010
Location: Nyuu, nyuu (France).
Old 07-14-2018 , 18:53   Re: CS:GO Give Player P250 after Killing 5 Enemy with Knife
Reply With Quote #9

Wait, you mean:

After 5 knife kills (From anybody), give a p250 to a random alive player?
__________________
micapat is offline
iskenderkebab33
Senior Member
Join Date: Jun 2018
Old 07-14-2018 , 18:57   Re: CS:GO Give Player P250 after Killing 5 Enemy with Knife
Reply With Quote #10

Quote:
Originally Posted by micapat View Post
Wait, you mean:

After 5 knife kills (From anybody), give a p250 to a random alive player?
yes, when i kill 5 Enemys with Knife, other Player will given the P250.
iskenderkebab33 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 02:37.


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