I created an SP file related to grenades, TNT, and Molotovs in No More Room in Hell.
However, even when I drop an item using the G key or right-click it in the inventory to drop it, a notification is still sent.
Did I make a mistake somewhere, or is there something I need to add?
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
public Plugin myinfo =
{
name = "NMRiH Grenade Alert",
author = "Memento",
description = "Notifies players when someone throws a grenade, TNT, or Molotov.",
version = "1.1",
url = ""
};
public void OnPluginStart()
{
for (int i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i))
{
SDKHook(i, SDKHook_WeaponDrop, OnWeaponDrop);
}
}
}
public void OnClientPutInServer(int client)
{
SDKHook(client, SDKHook_WeaponDrop, OnWeaponDrop);
}
public void OnWeaponDrop(int client, int weapon)
{
if (!IsValidEntity(weapon) || !IsClientInGame(client))
return;
// 현재 무기의 주인을 확인 (플레이어가 아직 소유 중인지 확인)
int owner = GetEntPropEnt(weapon, Prop_Send, "m_hOwnerEntity");
// 만약 무기의 주인이 없다면 (무작위로 떨어진 경우), 알림을 보내지 않음
if (owner == -1 || owner != client)
return;
char classname[64];
GetEdictClassname(weapon, classname, sizeof(classname));
char playerName[MAX_NAME_LENGTH];
GetClientName(client, playerName, sizeof(playerName));
if (StrContains(classname, "exp_grenade", false) != -1)
{
PrintToChatAll("\x04[알림] \x01%s 님이 수류탄을 던졌습니다!", playerName);
}
else if (StrContains(classname, "exp_tnt", false) != -1)
{
PrintToChatAll("\x04[알림] \x01%s 님이 TNT를 던졌습니다!", playerName);
}
else if (StrContains(classname, "exp_molotov", false) != -1)
{
PrintToChatAll("\x04[알림] \x01%s 님이 화염병을 던졌습니다!", playerName);
}
}
|