mirror of
https://github.com/Jackzmc/sourcemod-plugins.git
synced 2025-05-08 07:53:20 +00:00
survivor_identity_fix: Fix edge cases in the passing
- Swap models on player_spawn and door_open - Swamp right before death (prevents the kick on round_end)
This commit is contained in:
parent
7cf000d665
commit
3ea9678b53
2 changed files with 45 additions and 21 deletions
Binary file not shown.
|
@ -63,6 +63,8 @@ public void OnPluginStart()
|
||||||
HookEvent("player_first_spawn", Event_PlayerFirstSpawn);
|
HookEvent("player_first_spawn", Event_PlayerFirstSpawn);
|
||||||
HookEvent("player_disconnect", Event_PlayerDisconnect);
|
HookEvent("player_disconnect", Event_PlayerDisconnect);
|
||||||
HookEvent("finale_start", Event_FinaleStart);
|
HookEvent("finale_start", Event_FinaleStart);
|
||||||
|
HookEvent("player_spawn", Event_PlayerSpawn);
|
||||||
|
HookEvent("player_death", Event_PlayerDeath, EventHookMode_Pre);
|
||||||
|
|
||||||
if(isLateLoad) {
|
if(isLateLoad) {
|
||||||
for(int i = 1; i <= MaxClients; i++) {
|
for(int i = 1; i <= MaxClients; i++) {
|
||||||
|
@ -235,40 +237,62 @@ public void OnClientCookiesCached(int client) {
|
||||||
}
|
}
|
||||||
//Prevent issues with L4D1 characters being TP'd and stuck in brain dead form
|
//Prevent issues with L4D1 characters being TP'd and stuck in brain dead form
|
||||||
static bool IsTemporarilyL4D2[MAXPLAYERS]; //Use index 0 to state if its activated
|
static bool IsTemporarilyL4D2[MAXPLAYERS]; //Use index 0 to state if its activated
|
||||||
|
static char currentMap[16];
|
||||||
public void OnMapStart() {
|
public void OnMapStart() {
|
||||||
char map[16];
|
for(int i = 0; i < sizeof(survivor_models); i++) {
|
||||||
GetCurrentMap(map, sizeof(map));
|
PrecacheModel(survivor_models[i], true);
|
||||||
if(StrEqual(map, "c6m3_port")) {
|
}
|
||||||
UnhookEvent("door_open", Event_DoorOpen);
|
|
||||||
|
GetCurrentMap(currentMap, sizeof(currentMap));
|
||||||
|
if(StrEqual(currentMap, "c6m3_port")) {
|
||||||
HookEvent("door_open", Event_DoorOpen);
|
HookEvent("door_open", Event_DoorOpen);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
public Action Event_DoorOpen(Event event, const char[] name, bool dontBroadcast) {
|
public void Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast) {
|
||||||
for(int i = 1; i <= MaxClients; i++) {
|
int client = GetClientOfUserId(event.GetInt("userid"));
|
||||||
if(IsClientConnected(i) && IsClientInGame(i) && GetClientTeam(i) == 2) {
|
SwapL4D1Survivor(client);
|
||||||
int playerType = GetEntProp(i, Prop_Send, "m_survivorCharacter");
|
}
|
||||||
//If character is L4D1 Character (4: bill, etc..) then swap
|
public Action Event_PlayerDeath(Event event, const char[] name, bool dontBroadcast) {
|
||||||
if(playerType > 3) {
|
if(StrEqual(currentMap, "c6m3_port")) {
|
||||||
SetEntProp(i, Prop_Send, "m_survivorCharacter", playerType - 4);
|
int client = GetClientOfUserId(event.GetInt("userid"));
|
||||||
IsTemporarilyL4D2[i] = true;
|
if(GetClientTeam(client) == 2) {
|
||||||
}
|
SwapL4D1Survivor(client);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Plugin_Continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Event_DoorOpen(Event event, const char[] name, bool dontBroadcast) {
|
||||||
|
for(int i = 1; i <= MaxClients; i++) {
|
||||||
|
if(IsClientConnected(i) && IsClientInGame(i) && GetClientTeam(i) == 2 && !IsTemporarilyL4D2[i]) {
|
||||||
|
SwapL4D1Survivor(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
IsTemporarilyL4D2[0] = true;
|
|
||||||
UnhookEvent("door_open", Event_DoorOpen);
|
UnhookEvent("door_open", Event_DoorOpen);
|
||||||
}
|
}
|
||||||
//On finale start: Set back to their L4D1 character.
|
//On finale start: Set back to their L4D1 character.
|
||||||
public Action Event_FinaleStart(Event event, const char[] name, bool dontBroadcast) {
|
public Action Event_FinaleStart(Event event, const char[] name, bool dontBroadcast) {
|
||||||
if(IsTemporarilyL4D2[0]) {
|
for(int i = 1; i <= MaxClients; i++) {
|
||||||
for(int i = 0; i <= MaxClients; i++) {
|
if(IsClientConnected(i) && IsClientInGame(i) && GetClientTeam(i) == 2) {
|
||||||
if(i > 0 && IsClientConnected(i) && IsClientInGame(i) && GetClientTeam(i) == 2 && IsTemporarilyL4D2[i]) {
|
RevertL4D1Survivor(i);
|
||||||
int playerType = GetEntProp(i, Prop_Send, "m_survivorCharacter");
|
|
||||||
SetEntProp(i, Prop_Send, "m_survivorCharacter", playerType + 4);
|
|
||||||
}
|
|
||||||
IsTemporarilyL4D2[i] = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void SwapL4D1Survivor(int client) {
|
||||||
|
int playerType = GetEntProp(client, Prop_Send, "m_survivorCharacter");
|
||||||
|
//If character is L4D1 Character (4: bill, etc..) then swap
|
||||||
|
if(playerType > 3) {
|
||||||
|
SetEntProp(client, Prop_Send, "m_survivorCharacter", playerType - 4);
|
||||||
|
IsTemporarilyL4D2[client] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void RevertL4D1Survivor(int client) {
|
||||||
|
if(IsTemporarilyL4D2[client]) {
|
||||||
|
int playerType = GetEntProp(client, Prop_Send, "m_survivorCharacter");
|
||||||
|
SetEntProp(client, Prop_Send, "m_survivorCharacter", playerType + 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
//Either use preferred model OR find the least-used.
|
//Either use preferred model OR find the least-used.
|
||||||
public Action Event_PlayerFirstSpawn(Event event, const char[] name, bool dontBroadcast) {
|
public Action Event_PlayerFirstSpawn(Event event, const char[] name, bool dontBroadcast) {
|
||||||
int client = GetClientOfUserId(event.GetInt("userid"));
|
int client = GetClientOfUserId(event.GetInt("userid"));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue