AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugin/Gameplay Ideas and Requests (https://forums.alliedmods.net/forumdisplay.php?f=60)
-   -   Solved CS:GO Give Player P250 after Killing 5 Enemy with Knife (https://forums.alliedmods.net/showthread.php?t=309134)

iskenderkebab33 07-14-2018 18:02

CS:GO Give Player P250 after Killing 5 Enemy with Knife
 
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.

micapat 07-14-2018 18:13

Re: CS:GO Give Player P250 after Killing 5 Enemy with Knife
 
Need more information. Should the kill counter reset after a death? after a respawn? after a round restart?

iskenderkebab33 07-14-2018 18:29

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

Originally Posted by micapat (Post 2603651)
Need more information. Should the kill counter reset after a death? after a respawn? after a round restart?

yes that would be nice

micapat 07-14-2018 18:37

Re: CS:GO Give Player P250 after Killing 5 Enemy with Knife
 
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;
                } 
            } 
        }
    }
}

/* ========================================================================= */ 


iskenderkebab33 07-14-2018 18:40

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

Originally Posted by micapat (Post 2603656)
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.

micapat 07-14-2018 18:42

Re: CS:GO Give Player P250 after Killing 5 Enemy with Knife
 
I just update 'if ((StrContains(szWeapon, "knife") != -1) || (StrContains(szWeapon, "bayonet") != -1))', it should work better :)

iskenderkebab33 07-14-2018 18:47

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

Originally Posted by micapat (Post 2603660)
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 07-14-2018 18:51

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

Originally Posted by micapat (Post 2603660)
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

micapat 07-14-2018 18:53

Re: CS:GO Give Player P250 after Killing 5 Enemy with Knife
 
Wait, you mean:

After 5 knife kills (From anybody), give a p250 to a random alive player?

iskenderkebab33 07-14-2018 18:57

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

Originally Posted by micapat (Post 2603668)
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.


All times are GMT -4. The time now is 09:41.

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