![](images/misc/post_spacer.gif) |
Senior Member
|
![Old](images/statusicon/post_old.svg)
07-14-2018
, 18:40
Re: CS:GO Give Player P250 after Killing 5 Enemy with Knife
|
#5
|
Quote:
Originally Posted by micapat
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(iClient, SDKHook_SpawnPost, OnPlayerSpawnPost);
}
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[] szName, bool bDontBroadcast)
{
char szWeapon[32];
// Get the weapon name
hEvent.GetString("weapon", szWeapon, sizeof(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 ((1 <= iAttacker <= MaxClients) && IsClientInGame(iAttacker) && IsPlayerAlive(iAttacker))
{
gl_iPlayerKill[iAttacker]++;
if (gl_iPlayerKill[iAttacker] == 5)
{
GivePlayerItem(iAttacker, "weapon_p250");
}
}
}
}
|
thanks, gona test it now.
|
|
|
|