Senior Member
Join Date: Nov 2012
Location: Denmark
|
01-03-2023
, 15:49
Cleanup l4d2 plugin
|
#1
|
My l4d2 server randomly crashes. And I suspect it might have something to do with this plugin someone was kind enough to make for me o nthe fly, a very very long time ago. Untested by anybody except only uploaded on my server.
The plugin reflects any teamdamage, back to the shooter. But not for admin. For admin, he can teamkill anybody.
Could anybody help me clean or see if any changes are needed?
This is the plugin that was made.
PHP Code:
#pragma semicolon 1 #include <sourcemod> #include <sdkhooks>
bool bSmoked[MAXPLAYERS+1];
public void OnPluginStart() { HookEvent("round_start", OnRoundStart); HookEvent("tongue_grab", OnTongueGrab); HookEvent("tongue_release", OnTongueRelease); }
public void OnPluginEnd() { UnhookEvent("round_start", OnRoundStart); UnhookEvent("tongue_grab", OnTongueGrab); UnhookEvent("tongue_release", OnTongueRelease); for (int i = 1; i <= MaxClients; i++) { if (IsClientInGame(i)) { SDKUnhook(i, SDKHook_OnTakeDamage, OnTakeDamage); } } }
public void OnClientPutInServer(int client) { SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage); }
public Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype, int &weapon, float damageForce[3], float damagePosition[3]) { if (!IsSurvivor(victim) || IsDominated(victim) || IsGettingUp(victim) || !IsSurvivor(attacker) || !IsPlayerAlive(attacker) || attacker == victim) { return Plugin_Continue; } if (CheckCommandAccess(attacker, "sm_admin", ADMFLAG_GENERIC) || IsPhysicsProp(inflictor) || IsGrenade(inflictor)) { return Plugin_Continue; } SDKHooks_TakeDamage(attacker, inflictor, attacker, damage, damagetype, weapon, damageForce, damagePosition); damage = 0.0; return Plugin_Changed; }
public void OnClientDisconnect(int client) { SDKUnhook(client, SDKHook_OnTakeDamage, OnTakeDamage); }
public void OnMapStart() { for (int i = 1; i <= MaxClients; i++) { if (IsClientInGame(i)) { bSmoked[i] = false; } } }
public void OnRoundStart(Event event, const char[] name, bool dontBroadcast) { for (int i = 1; i <= MaxClients; i++) { if (IsClientInGame(i)) { bSmoked[i] = false; } } }
public void OnTongueGrab(Event event, const char[] name, bool dontBroadcast) { int grabbed = GetClientOfUserId(event.GetInt("victim")); if (!IsSurvivor(grabbed) || bSmoked[grabbed]) { return; } bSmoked[grabbed] = true; }
public void OnTongueRelease(Event event, const char[] name, bool dontBroadcast) { int released = GetClientOfUserId(event.GetInt("victim")); if (!IsSurvivor(released) || !bSmoked[released]) { return; } bSmoked[released] = false; }
bool IsDominated(int client) { return (GetEntProp(client, Prop_Send, "m_isIncapacitated", 1) || bSmoked[client] || GetEntPropEnt(client, Prop_Send, "m_pounceAttacker") > 0 || GetEntPropEnt(client, Prop_Send, "m_jockeyAttacker") > 0 || GetEntPropEnt(client, Prop_Send, "m_carryAttacker") > 0 || GetEntPropEnt(client, Prop_Send, "m_pummelAttacker") > 0); }
bool IsGettingUp(int client) { int iSequence = GetEntProp(client, Prop_Send, "m_nSequence"); char sModel[128]; GetEntPropString(client, Prop_Data, "m_ModelName", sModel, sizeof(sModel)); if (StrEqual(sModel, "models/survivors/survivor_gambler.mdl", false)) { if (iSequence == 620 || iSequence == 629 || iSequence == 667 || iSequence == 671 || iSequence == 672) { return true; } } else if (StrEqual(sModel, "models/survivors/survivor_producer", false) || StrEqual(sModel, "models/survivors/survivor_adawong.mdl", false)) { if (iSequence == 629 || iSequence == 637 || iSequence == 674 || iSequence == 678 || iSequence == 679) { return true; } } else if (StrEqual(sModel, "models/survivors/survivor_coach.mdl", false)) { if (iSequence == 621 || iSequence == 629 || iSequence == 656 || iSequence == 660 || iSequence == 661) { return true; } } else if (StrEqual(sModel, "models/survivors/survivor_mechanic.mdl", false)) { if (iSequence == 625 || iSequence == 634 || iSequence == 671 || iSequence == 675 || iSequence == 676) { return true; } } else if (StrEqual(sModel, "models/survivors/survivor_namvet.mdl", false) || StrEqual(sModel, "models/survivors/survivor_manager.mdl", false)) { if (iSequence == 528 || iSequence == 537 || iSequence == 759 || iSequence == 763 || iSequence == 764) { return true; } } else if (StrEqual(sModel, "models/survivors/survivor_teenangst.mdl", false)) { if (iSequence == 537 || iSequence == 546 || iSequence == 819 || iSequence == 823 || iSequence == 824) { return true; } } else if (StrEqual(sModel, "models/survivors/survivor_biker.mdl", false)) { if (iSequence == 531 || iSequence == 540 || iSequence == 762 || iSequence == 766 || iSequence == 767) { return true; } } return false; }
stock bool IsSurvivor(int client) { return (client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2); }
stock bool IsPhysicsProp(int entity) { if (entity > 0 && IsValidEntity(entity) && IsValidEdict(entity)) { char sEntityClass[64]; GetEdictClassname(entity, sEntityClass, sizeof(sEntityClass)); return StrEqual(sEntityClass, "prop_physics"); } return false; }
stock bool IsGrenade(int entity) { if (entity > 0 && IsValidEntity(entity) && IsValidEdict(entity)) { char sEntityClass[64]; GetEdictClassname(entity, sEntityClass, sizeof(sEntityClass)); return (StrEqual(sEntityClass, "inferno") || StrEqual(sEntityClass, "pipe_bomb_projectile")); } return false; }
Last edited by wendigo; 01-03-2023 at 15:49.
|
|