mirror of
https://github.com/Jackzmc/sourcemod-plugins.git
synced 2025-05-07 16:43:21 +00:00
L4D2Toolz: Implement anti-bot drop melee completely
This commit is contained in:
parent
3ec21557e2
commit
d56a46fc8c
2 changed files with 20 additions and 3 deletions
Binary file not shown.
|
@ -13,7 +13,9 @@
|
||||||
bool bLasersUsed[2048];
|
bool bLasersUsed[2048];
|
||||||
ConVar hLaserNotice, hFinaleTimer, hFFNotice, hMPGamemode;
|
ConVar hLaserNotice, hFinaleTimer, hFFNotice, hMPGamemode;
|
||||||
int iFinaleStartTime;
|
int iFinaleStartTime;
|
||||||
|
int botDropMeleeWeapon[MAXPLAYERS+1];
|
||||||
|
|
||||||
|
//TODO: Remove the Plugin_Stop on pickup, and give item back instead. keep reference to dropped weapon to delete.
|
||||||
public Plugin myinfo = {
|
public Plugin myinfo = {
|
||||||
name = "L4D2 Misc Tools",
|
name = "L4D2 Misc Tools",
|
||||||
author = "Includes: Notice on laser use, Timer for gauntlet runs",
|
author = "Includes: Notice on laser use, Timer for gauntlet runs",
|
||||||
|
@ -61,18 +63,33 @@ public Action Event_BotPlayerSwap(Event event, const char[] name, bool dontBroad
|
||||||
SDKHook(bot, SDKHook_WeaponDrop, Event_OnWeaponDrop);
|
SDKHook(bot, SDKHook_WeaponDrop, Event_OnWeaponDrop);
|
||||||
}else{
|
}else{
|
||||||
//Player replaced a bot
|
//Player replaced a bot
|
||||||
|
int client = GetClientOfUserId(event.GetInt("player"));
|
||||||
|
if(botDropMeleeWeapon[bot] > 0) {
|
||||||
|
//todo:
|
||||||
|
int meleeOwnerEnt = GetEntPropEnt(botDropMeleeWeapon[bot], Prop_Send, "m_hOwnerEntity");
|
||||||
|
if(meleeOwnerEnt == -1) {
|
||||||
|
EquipPlayerWeapon(client, botDropMeleeWeapon[bot]);
|
||||||
|
botDropMeleeWeapon[bot] = -1;
|
||||||
|
}else{
|
||||||
|
PrintToChatAll("client %N cannot equip", client);
|
||||||
|
PrintToConsole(client, "Could not give back your melee weapon, %N has it instead.", meleeOwnerEnt);
|
||||||
|
}
|
||||||
|
}
|
||||||
SDKUnhook(bot, SDKHook_WeaponDrop, Event_OnWeaponDrop);
|
SDKUnhook(bot, SDKHook_WeaponDrop, Event_OnWeaponDrop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void OnClientDisconnect(int client) {
|
||||||
|
botDropMeleeWeapon[client] = -1;
|
||||||
|
}
|
||||||
|
|
||||||
public Action Event_OnWeaponDrop(int client, int weapon) {
|
public Action Event_OnWeaponDrop(int client, int weapon) {
|
||||||
char wpn[32];
|
char wpn[32];
|
||||||
GetEdictClassname(weapon, wpn, sizeof(wpn));
|
GetEdictClassname(weapon, wpn, sizeof(wpn));
|
||||||
if(StrEqual(wpn, "weapon_melee") && GetEntProp(client, Prop_Send, "m_humanSpectatorUserID") > 0) {
|
if(StrEqual(wpn, "weapon_melee") && GetEntProp(client, Prop_Send, "m_humanSpectatorUserID") > 0) {
|
||||||
return Plugin_Stop;
|
botDropMeleeWeapon[client] = weapon;
|
||||||
}else{
|
|
||||||
return Plugin_Continue;
|
|
||||||
}
|
}
|
||||||
|
return Plugin_Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue