mirror of
https://github.com/Jackzmc/sourcemod-plugins.git
synced 2025-05-09 02:23:20 +00:00
L4D2Tools: Add minor changes to anti-melee idle drop
- Teleport dropped wpn out of bounds to prevent pickup - On disconnect, teleport pending item to player?
This commit is contained in:
parent
641bdd450f
commit
445e0ea878
3 changed files with 70 additions and 57 deletions
Binary file not shown.
|
@ -1,7 +1,7 @@
|
||||||
#pragma semicolon 1
|
#pragma semicolon 1
|
||||||
#pragma newdecls required
|
#pragma newdecls required
|
||||||
|
|
||||||
#define DEBUG
|
//#define DEBUG
|
||||||
|
|
||||||
#define PLUGIN_VERSION "1.0"
|
#define PLUGIN_VERSION "1.0"
|
||||||
|
|
||||||
|
@ -10,11 +10,11 @@
|
||||||
#include <sdkhooks>
|
#include <sdkhooks>
|
||||||
#include "jutils.inc"
|
#include "jutils.inc"
|
||||||
|
|
||||||
|
static bool bLasersUsed[2048];
|
||||||
|
static ConVar hLaserNotice, hFinaleTimer, hFFNotice, hMPGamemode;
|
||||||
|
static int iFinaleStartTime, botDropMeleeWeapon[MAXPLAYERS+1];
|
||||||
|
|
||||||
bool bLasersUsed[2048];
|
static float OUT_OF_BOUNDS[3] = {0.0, -1000.0, 0.0};
|
||||||
ConVar hLaserNotice, hFinaleTimer, hFFNotice, hMPGamemode;
|
|
||||||
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.
|
//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 = {
|
||||||
|
@ -112,7 +112,8 @@ public Action Event_BotPlayerSwap(Event event, const char[] name, bool dontBroad
|
||||||
//Player replaced a bot
|
//Player replaced a bot
|
||||||
int client = GetClientOfUserId(event.GetInt("player"));
|
int client = GetClientOfUserId(event.GetInt("player"));
|
||||||
if(botDropMeleeWeapon[bot] > 0) {
|
if(botDropMeleeWeapon[bot] > 0) {
|
||||||
//todo:
|
//TODO: If entity (weapon) not valid (aka level switched), give them a new one no matter what
|
||||||
|
//Also possibly prevent players from picking up any dropped weapons (no duplicates then ^)
|
||||||
int meleeOwnerEnt = GetEntPropEnt(botDropMeleeWeapon[bot], Prop_Send, "m_hOwnerEntity");
|
int meleeOwnerEnt = GetEntPropEnt(botDropMeleeWeapon[bot], Prop_Send, "m_hOwnerEntity");
|
||||||
if(meleeOwnerEnt == -1) {
|
if(meleeOwnerEnt == -1) {
|
||||||
EquipPlayerWeapon(client, botDropMeleeWeapon[bot]);
|
EquipPlayerWeapon(client, botDropMeleeWeapon[bot]);
|
||||||
|
@ -126,17 +127,29 @@ public Action Event_BotPlayerSwap(Event event, const char[] name, bool dontBroad
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnClientDisconnect(int client) {
|
public void OnClientDisconnect(int client) {
|
||||||
botDropMeleeWeapon[client] = -1;
|
if(botDropMeleeWeapon[client] > -1) {
|
||||||
|
float pos[3];
|
||||||
|
GetClientAbsOrigin(client, pos);
|
||||||
|
TeleportEntity(botDropMeleeWeapon[client], pos, NULL_VECTOR, NULL_VECTOR);
|
||||||
|
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(IsFakeClient(client) && StrEqual(wpn, "weapon_melee") && GetEntProp(client, Prop_Send, "m_humanSpectatorUserID") > 0) {
|
||||||
|
#if defined DEBUG 0
|
||||||
|
PrintToServer("Bot %N dropped melee weapon %s", client, wpn);
|
||||||
|
#endif
|
||||||
|
CreateTimer(0.1, Timer_HideEntity, weapon);
|
||||||
botDropMeleeWeapon[client] = weapon;
|
botDropMeleeWeapon[client] = weapon;
|
||||||
}
|
}
|
||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
}
|
}
|
||||||
|
public Action Timer_HideEntity(Handle timer, int entity) {
|
||||||
|
TeleportEntity(entity, OUT_OF_BOUNDS, NULL_VECTOR, NULL_VECTOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void Event_EnterSaferoom(Event event, const char[] name, bool dontBroadcast) {
|
public void Event_EnterSaferoom(Event event, const char[] name, bool dontBroadcast) {
|
||||||
|
|
|
@ -139,6 +139,54 @@ stock bool FindSurvivorModel(const char str[16], char[] model, int modelStrSize)
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
//returns true if model found
|
||||||
|
stock bool GetSurvivorName(int client, char[] buffer, int length) {
|
||||||
|
|
||||||
|
char modelName[38];
|
||||||
|
GetClientModel(client, modelName, sizeof(modelName));
|
||||||
|
if(StrContains(modelName,"biker",false) > -1) {
|
||||||
|
strcopy(buffer, length, "Francis");
|
||||||
|
}else if(StrContains(modelName,"teenangst",false) > -1) {
|
||||||
|
strcopy(buffer, length, "Zoey");
|
||||||
|
}else if(StrContains(modelName,"namvet",false) > -1) {
|
||||||
|
strcopy(buffer, length, "Bill");
|
||||||
|
}else if(StrContains(modelName,"manager",false) > -1) {
|
||||||
|
strcopy(buffer, length, "Louis");
|
||||||
|
}else if(StrContains(modelName,"coach",false) > -1) {
|
||||||
|
strcopy(buffer, length, "Coach");
|
||||||
|
}else if(StrContains(modelName,"producer",false) > -1) {
|
||||||
|
strcopy(buffer, length, "Rochelle");
|
||||||
|
}else if(StrContains(modelName,"gambler",false) > -1) {
|
||||||
|
strcopy(buffer, length, "Nick");
|
||||||
|
}else if(StrContains(modelName,"mechanic",false) > -1) {
|
||||||
|
strcopy(buffer, length, "Ellis");
|
||||||
|
}else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
stock int GetSurvivorType(const char[] modelName) {
|
||||||
|
if(StrContains(modelName,"biker",false) > -1) {
|
||||||
|
return 6;
|
||||||
|
}else if(StrContains(modelName,"teenangst",false) > -1) {
|
||||||
|
return 5;
|
||||||
|
}else if(StrContains(modelName,"namvet",false) > -1) {
|
||||||
|
return 4;
|
||||||
|
}else if(StrContains(modelName,"manager",false) > -1) {
|
||||||
|
return 7;
|
||||||
|
}else if(StrContains(modelName,"coach",false) > -1) {
|
||||||
|
return 2;
|
||||||
|
}else if(StrContains(modelName,"producer",false) > -1) {
|
||||||
|
return 1;
|
||||||
|
}else if(StrContains(modelName,"gambler",false) > -1) {
|
||||||
|
return 0;
|
||||||
|
}else if(StrContains(modelName,"mechanic",false) > -1) {
|
||||||
|
return 3;
|
||||||
|
}else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
stock bool TraceFilter(int entity, int contentsMask) {
|
stock bool TraceFilter(int entity, int contentsMask) {
|
||||||
if( entity <= MaxClients )
|
if( entity <= MaxClients )
|
||||||
return false;
|
return false;
|
||||||
|
@ -193,54 +241,7 @@ stock bool SpawnMinigun(const float vPos[3], const float vAng[3]) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//returns true if model found
|
|
||||||
stock bool GetSurvivorName(int client, char[] buffer, int length) {
|
|
||||||
|
|
||||||
char modelName[38];
|
|
||||||
GetClientModel(client, modelName, sizeof(modelName));
|
|
||||||
if(StrContains(modelName,"biker",false) > -1) {
|
|
||||||
strcopy(buffer, length, "Francis");
|
|
||||||
}else if(StrContains(modelName,"teenangst",false) > -1) {
|
|
||||||
strcopy(buffer, length, "Zoey");
|
|
||||||
}else if(StrContains(modelName,"namvet",false) > -1) {
|
|
||||||
strcopy(buffer, length, "Bill");
|
|
||||||
}else if(StrContains(modelName,"manager",false) > -1) {
|
|
||||||
strcopy(buffer, length, "Louis");
|
|
||||||
}else if(StrContains(modelName,"coach",false) > -1) {
|
|
||||||
strcopy(buffer, length, "Coach");
|
|
||||||
}else if(StrContains(modelName,"producer",false) > -1) {
|
|
||||||
strcopy(buffer, length, "Rochelle");
|
|
||||||
}else if(StrContains(modelName,"gambler",false) > -1) {
|
|
||||||
strcopy(buffer, length, "Nick");
|
|
||||||
}else if(StrContains(modelName,"mechanic",false) > -1) {
|
|
||||||
strcopy(buffer, length, "Ellis");
|
|
||||||
}else{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
stock int GetSurvivorType(const char[] modelName) {
|
|
||||||
if(StrContains(modelName,"biker",false) > -1) {
|
|
||||||
return 6;
|
|
||||||
}else if(StrContains(modelName,"teenangst",false) > -1) {
|
|
||||||
return 5;
|
|
||||||
}else if(StrContains(modelName,"namvet",false) > -1) {
|
|
||||||
return 4;
|
|
||||||
}else if(StrContains(modelName,"manager",false) > -1) {
|
|
||||||
return 7;
|
|
||||||
}else if(StrContains(modelName,"coach",false) > -1) {
|
|
||||||
return 2;
|
|
||||||
}else if(StrContains(modelName,"producer",false) > -1) {
|
|
||||||
return 1;
|
|
||||||
}else if(StrContains(modelName,"gambler",false) > -1) {
|
|
||||||
return 0;
|
|
||||||
}else if(StrContains(modelName,"mechanic",false) > -1) {
|
|
||||||
return 3;
|
|
||||||
}else{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stock bool GiveClientWeapon(int client, const char[] wpnName, bool lasers) {
|
stock bool GiveClientWeapon(int client, const char[] wpnName, bool lasers) {
|
||||||
char sTemp[64];
|
char sTemp[64];
|
||||||
|
@ -298,8 +299,7 @@ stock int GetPrimaryAmmo(int client) {
|
||||||
else
|
else
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
stock void CheatCommand(int client, const char[] command, const char[] argument1, const char[] argument2)
|
stock void CheatCommand(int client, const char[] command, const char[] argument1, const char[] argument2) {
|
||||||
{
|
|
||||||
int userFlags = GetUserFlagBits(client);
|
int userFlags = GetUserFlagBits(client);
|
||||||
SetUserFlagBits(client, ADMFLAG_ROOT);
|
SetUserFlagBits(client, ADMFLAG_ROOT);
|
||||||
int flags = GetCommandFlags(command);
|
int flags = GetCommandFlags(command);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue