Senior Member
|
![Old](images/statusicon/post_old.svg)
12-13-2022
, 15:35
Re: [L4D]BUG after turning on the swith
|
#8
|
Code:
#pragma semicolon 1
#pragma newdecls required
#define DEBUG
#define PLUGIN_AUTHOR "ZB"
#define PLUGIN_VERSION "0.03"
#include <sourcemod>
#include <sdktools>
int m_map;
int activatortmp;
enum
{
A1M3 = 1,
B2M1,
C3M4,
D4M3,
D4M4,
F6M2,
}
public Plugin myinfo =
{
name = "[ZB_FIX]Zmob Bug Fixes",
author = PLUGIN_AUTHOR,
description = "Zmob Bug Fixes",
version = PLUGIN_VERSION,
url = ""
};
public void OnPluginStart()
{
RegConsoleCmd("sm_mob", Command_ZspawnMob);
RegConsoleCmd("sm_zmob", Command_ZspawnMob);
HookEvent("round_start", Event_RoundStart);
//HookEvent("player_use", Event_PlayerUse);
}
public void OnMapStart()
{
char sMap[64];
GetCurrentMap(sMap, sizeof(sMap));
m_map = 0;
if( IsFixMap )
{
if( strcmp(sMap, "l4d_hospital03_sewers") == 0 ) m_map = A1M3;
else if( strcmp(sMap, "l4d_garage01_alleys") == 0 ) m_map = B2M1;
else if( strcmp(sMap, "l4d_smalltown04_mainstreet") == 0 ) m_map = C3M4;
else if( strcmp(sMap, "l4d_airport03_garage") == 0 ) m_map = D4M3;
else if( strcmp(sMap, "l4d_airport04_terminal") == 0 ) m_map = D4M4;
else if( strcmp(sMap, "l4d_farm02_traintunnel") == 0 ) m_map = F6M2;
}
else
{
//if( strcmp(sMap, "l4d_hospital04_interior") == 0 || strcmp(sMap, "l4d_vs_hospital04_interior") == 0 ) m_map = A1M3;
return;
}
}
//--------------------Event--------------------//
public void Event_RoundStart(Event event, const char[] name, bool dontBroadcast)
{
CreateTimer(1.0, tmrStart,TIMER_REPEAT);
}
public Action tmrStart(Handle timer)
{
int ent = -1;
if(m_map == A1M3 && (ent = FindByClassTargetName("func_button", "washer_lift_button2")) != -1)
HookSingleEntityOutput(ent, "OnPressed", OnStartTouch, true);
else if(m_map == B2M1 && (ent = FindByClassTargetName("func_button", "fire_howitzer")) != -1)
HookSingleEntityOutput(ent, "OnPressed", OnStartTouch, true);
else if(m_map == C3M4 && (ent = FindByClassTargetName("func_button", "button")) != -1)
HookSingleEntityOutput(ent, "OnPressed", OnStartTouch, true);
else if(m_map == D4M3 && (ent = FindByClassTargetName("prop_physics", "barricade_gas_can")) != -1)
HookSingleEntityOutput(ent, "OnBreak", OnStartTouch, true);
else if(m_map == D4M4 && (ent = FindByClassTargetName("func_button", "van_button")) != -1)
HookSingleEntityOutput(ent, "OnPressed", OnStartTouch, true);
else if(m_map == F6M2 && (ent = FindByClassTargetName("logic_relay", "emergency_door_relay")) != -1)
HookSingleEntityOutput(ent, "OnTrigger", OnStartTouch, true);
}
public void OnStartTouch(const char[] output, int caller, int activator, float delay)
{
CreateTimer(5.0, zmobfix_timer,3);
activatortmp = activator;
}
public Action zmobfix_timer(Handle timer,int time)
{
if( time >= 1)
{
CreateTimer( 30.0, zmobfix_timer, --time);
EmitSoundToAll("npc/mega_mob/mega_mob_incoming.wav", _, SNDCHAN_AUTO, SNDLEVEL_RAIDSIREN, SND_NOFLAGS, SNDVOL_NORMAL, SNDPITCH_LOW, -1, NULL_VECTOR, NULL_VECTOR, true, 0.0);
SpawnAWitch();
zmobfix(activatortmp);
}
else if(time == 0)
{
return Plugin_Stop;
}
return Plugin_Continue;
}
public Action zmobfix(int args)
{
char name[] = "mob";
char command[] = "z_spawn";
char iflags = GetCommandFlags(command);
SetCommandFlags(command, iflags & ~FCVAR_CHEAT);
FakeClientCommand(activatortmp, "z_spawn %s", name);
SetCommandFlags(command, iflags);
ShowActivity2(activatortmp, "ZB", "Spawned a %s", name);
PrintToChatAll("\x04[test]trigger:%N",activatortmp);
}
public Action Command_ZspawnMob(int client, int args)
{
char name[] = "mob";
char command[] = "z_spawn";
int flags = GetCommandFlags(command);
SetCommandFlags(command, flags & ~FCVAR_CHEAT);
FakeClientCommand(client, "z_spawn %s", name);
SetCommandFlags(command, flags);
}
bool IsFixMap()
{
char sMap[64];
GetCurrentMap(sMap, sizeof(sMap));
if (StrEqual(sMap, "l4d_hospital02_subway", false))
{
//UnflagAndExecuteCommand(TriggeringBot, "ent_fire", "filter_generator", "TestActivator");
}
else if (StrEqual(sMap, "l4d_hospital03_sewers", false))
{
int ent = -1;
ent = FindByClassTargetName("func_button", "washer_lift_button2");
if(ent != -1 )
{
PrintToChatAll("\x04[ZB] button,on");
}
else
{
//TriggerPanicEvent();
PrintToChatAll("\x04[ZB] button,off");
}
}
}
int FindByClassTargetName(const char[] sClass, const char[] sTarget)
{
char sName[64];
int ent = -1;
while( (ent = FindEntityByClassname(ent, sClass)) != -1 )
{
GetEntPropString(ent, Prop_Data, "m_iName", sName, 64);
if( strcmp(sTarget, sName) == 0 ) return ent;
}
return -1;
}
Code:
L 12/14/2022 - 04:17:59: [SM] Exception reported: Client index 203 is invalid
L 12/14/2022 - 04:17:59: [SM] Blaming: test\ZB_MobFix.smx
L 12/14/2022 - 04:17:59: [SM] Call stack trace:
L 12/14/2022 - 04:17:59: [SM] [0] FakeClientCommand
L 12/14/2022 - 04:17:59: [SM] [1] Line 117, I:\ZB_MobFix.sp::zmobfix
L 12/14/2022 - 04:17:59: [SM] [2] Line 101, I:\ZB_MobFix.sp::zmobfix_timer
Sometimes it will be effective, sometimes it will be invalid and an error will be reported. How to solve it?
__________________
Please forgive, If I'm not describing it accurately. I use google translate ![Sad](images/smilies/frown.gif)
Functional tests are all from L4D1, and are only keen to solve and fix various bugs of L4D1:
|
|