mirror of
https://github.com/Jackzmc/sourcemod-plugins.git
synced 2025-05-05 20:33:20 +00:00
Update identity fix
This commit is contained in:
parent
9adbe21719
commit
76fd3221e0
4 changed files with 39 additions and 22 deletions
|
@ -217,7 +217,7 @@ Also features a part that will increase the item count on any item, kit, or weap
|
||||||
* `l4d2_extraitem_chance` - The base chance (multiplied by player count) of an extra item being spawned. Default: 0.056
|
* `l4d2_extraitem_chance` - The base chance (multiplied by player count) of an extra item being spawned. Default: 0.056
|
||||||
|
|
||||||
### l4d_survivor_identity_fix
|
### l4d_survivor_identity_fix
|
||||||
A fork of Merudo, Shadowysn's identity fix plugin that adds support for other plugins to update the model cache. This is used by [L4D2Tools](#L4D2Tools) to update the identity when someone changes their model with sm_model. It also will clear the memory of model when a player disconnects entirely or on a new map.
|
A fork of [Survivor Identity Fix plugin](https://forums.alliedmods.net/showthread.php?t=280539) that adds support for other plugins to update the model cache. This is used by [L4D2Tools](#L4D2Tools) to update the identity when someone changes their model with `sm_model`. It also will clear the memory of model when a player disconnects entirely or on a new map.
|
||||||
|
|
||||||
In addition, has a fix for the passing finale, and will automatically move L4D characters to L4D2 until finale starts preventing game messing up their characters.
|
In addition, has a fix for the passing finale, and will automatically move L4D characters to L4D2 until finale starts preventing game messing up their characters.
|
||||||
|
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -17,21 +17,25 @@
|
||||||
#define TEAM_SURVIVOR 2
|
#define TEAM_SURVIVOR 2
|
||||||
#define TEAM_PASSING 4
|
#define TEAM_PASSING 4
|
||||||
|
|
||||||
char g_Models[MAXPLAYERS+1][128];
|
|
||||||
int g_iPendingCookieModel[MAXPLAYERS+1];
|
|
||||||
|
|
||||||
#define GAMEDATA "l4d_survivor_identity_fix"
|
#define GAMEDATA "l4d_survivor_identity_fix"
|
||||||
|
#define NAME_SetModel "CBasePlayer::SetModel"
|
||||||
|
#define SIG_SetModel_LINUX "@_ZN11CBasePlayer8SetModelEPKc"
|
||||||
|
#define SIG_SetModel_WINDOWS "\\x55\\x8B\\x2A\\x8B\\x2A\\x2A\\x56\\x57\\x50\\x8B\\x2A\\xE8\\x2A\\x2A\\x2A\\x2A\\x8B\\x2A\\x2A\\x2A\\x2A\\x2A\\x8B\\x2A\\x8B\\x2A\\x2A\\x8B"
|
||||||
|
#define SIG_L4D1SetModel_WINDOWS "\\x8B\\x2A\\x2A\\x2A\\x56\\x57\\x50\\x8B\\x2A\\xE8\\x2A\\x2A\\x2A\\x2A\\x8B\\x3D"
|
||||||
|
|
||||||
|
char g_Models[MAXPLAYERS+1][128];
|
||||||
|
static int g_iPendingCookieModel[MAXPLAYERS+1];
|
||||||
|
|
||||||
Handle hConf = null;
|
Handle hConf = null;
|
||||||
#define NAME_SetModel "CBasePlayer::SetModel"
|
|
||||||
static Handle hDHookSetModel = null, hModelPrefCookie;
|
static Handle hDHookSetModel = null, hModelPrefCookie;
|
||||||
static ConVar hCookiesEnabled;
|
static ConVar hCookiesEnabled;
|
||||||
static bool isLateLoad, cookieModelsSet;
|
static bool isLateLoad, cookieModelsSet;
|
||||||
static int survivors;
|
static int survivors;
|
||||||
#define SIG_SetModel_LINUX "@_ZN11CBasePlayer8SetModelEPKc"
|
static bool IsTemporarilyL4D2[MAXPLAYERS]; //Use index 0 to state if its activated
|
||||||
#define SIG_SetModel_WINDOWS "\\x55\\x8B\\x2A\\x8B\\x2A\\x2A\\x56\\x57\\x50\\x8B\\x2A\\xE8\\x2A\\x2A\\x2A\\x2A\\x8B\\x2A\\x2A\\x2A\\x2A\\x2A\\x8B\\x2A\\x8B\\x2A\\x2A\\x8B"
|
static char currentMap[16];
|
||||||
|
|
||||||
|
|
||||||
#define SIG_L4D1SetModel_WINDOWS "\\x8B\\x2A\\x2A\\x2A\\x56\\x57\\x50\\x8B\\x2A\\xE8\\x2A\\x2A\\x2A\\x2A\\x8B\\x3D"
|
|
||||||
|
|
||||||
//TODO: Setup cookies
|
//TODO: Setup cookies
|
||||||
|
|
||||||
|
@ -224,20 +228,17 @@ public void OnClientCookiesCached(int client) {
|
||||||
char modelPref[2];
|
char modelPref[2];
|
||||||
GetClientCookie(client, hModelPrefCookie, modelPref, sizeof(modelPref));
|
GetClientCookie(client, hModelPrefCookie, modelPref, sizeof(modelPref));
|
||||||
if(strlen(modelPref) > 0) {
|
if(strlen(modelPref) > 0) {
|
||||||
int type = StringToInt(modelPref);
|
int type;
|
||||||
if(type > 0 && type <= 8) {
|
if(StringToIntEx(modelPref, type) > 0) {
|
||||||
|
PrintToServer(">>> %N has cookie for: %s", client, survivor_models[type - 1]);
|
||||||
strcopy(g_Models[client], 64, survivor_models[type - 1]);
|
strcopy(g_Models[client], 64, survivor_models[type - 1]);
|
||||||
g_iPendingCookieModel[client] = type;
|
g_iPendingCookieModel[client] = type;
|
||||||
//A valid cookie was found, set their model.
|
|
||||||
}else{
|
|
||||||
SetClientCookie(client, hModelPrefCookie, "0");
|
|
||||||
//Set to current model?
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//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 char currentMap[16];
|
|
||||||
public void OnMapStart() {
|
public void OnMapStart() {
|
||||||
for(int i = 0; i < sizeof(survivor_models); i++) {
|
for(int i = 0; i < sizeof(survivor_models); i++) {
|
||||||
PrecacheModel(survivor_models[i], true);
|
PrecacheModel(survivor_models[i], true);
|
||||||
|
@ -251,12 +252,19 @@ public void OnMapStart() {
|
||||||
}
|
}
|
||||||
public void Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast) {
|
public void Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast) {
|
||||||
int client = GetClientOfUserId(event.GetInt("userid"));
|
int client = GetClientOfUserId(event.GetInt("userid"));
|
||||||
SwapL4D1Survivor(client);
|
if(StrEqual(currentMap, "c6m1_riverbank") && GetClientTeam(client) == 2) {
|
||||||
|
//If player died as l4d1 character on first map, revert it
|
||||||
|
RevertL4D1Survivor(client);
|
||||||
|
}else if(StrEqual(currentMap, "c6m3_port") && GetClientTeam(client) == 2) {
|
||||||
|
//If player not swapped (joined, or via prev. map, switch)
|
||||||
|
RequestFrame(Frame_SwapSurvivor, client);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public Action Event_PlayerDeath(Event event, const char[] name, bool dontBroadcast) {
|
public Action Event_PlayerDeath(Event event, const char[] name, bool dontBroadcast) {
|
||||||
if(StrEqual(currentMap, "c6m3_port")) {
|
//Switch players to L4D2 right before death.
|
||||||
|
if(StrEqual(currentMap, "c6m3_port") || StrEqual(currentMap, "c6m1_riverbank")) {
|
||||||
int client = GetClientOfUserId(event.GetInt("userid"));
|
int client = GetClientOfUserId(event.GetInt("userid"));
|
||||||
if(GetClientTeam(client) == 2) {
|
if(client && GetClientTeam(client) == 2) {
|
||||||
SwapL4D1Survivor(client);
|
SwapL4D1Survivor(client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -273,12 +281,21 @@ public void Event_DoorOpen(Event event, const char[] name, bool dontBroadcast) {
|
||||||
}
|
}
|
||||||
//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) {
|
||||||
for(int i = 1; i <= MaxClients; i++) {
|
if(StrEqual(currentMap, "c6m3_port")) {
|
||||||
if(IsClientConnected(i) && IsClientInGame(i) && GetClientTeam(i) == 2) {
|
for(int i = 1; i <= MaxClients; i++) {
|
||||||
RevertL4D1Survivor(i);
|
if(IsClientConnected(i) && IsClientInGame(i) && GetClientTeam(i) == 2) {
|
||||||
|
RevertL4D1Survivor(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public void Frame_SwapSurvivor(int client) {
|
||||||
|
SwapL4D1Survivor(client);
|
||||||
|
}
|
||||||
|
public void Frame_RevertSurvivor(int client) {
|
||||||
|
RevertL4D1Survivor(client);
|
||||||
|
}
|
||||||
|
|
||||||
void SwapL4D1Survivor(int client) {
|
void SwapL4D1Survivor(int client) {
|
||||||
int playerType = GetEntProp(client, Prop_Send, "m_survivorCharacter");
|
int playerType = GetEntProp(client, Prop_Send, "m_survivorCharacter");
|
||||||
//If character is L4D1 Character (4: bill, etc..) then swap
|
//If character is L4D1 Character (4: bill, etc..) then swap
|
||||||
|
@ -303,7 +320,7 @@ public Action Event_PlayerFirstSpawn(Event event, const char[] name, bool dontBr
|
||||||
|
|
||||||
if(!cookieModelsSet) {
|
if(!cookieModelsSet) {
|
||||||
cookieModelsSet = true;
|
cookieModelsSet = true;
|
||||||
CreateTimer(0.1, Timer_SetAllCookieModels);
|
CreateTimer(0.2, Timer_SetAllCookieModels);
|
||||||
PrintToServer("Over 4 clients, setting models for all users based on cookie.");
|
PrintToServer("Over 4 clients, setting models for all users based on cookie.");
|
||||||
}else {
|
}else {
|
||||||
PrintToServer("Client joined with model cookie | client %N | cookie %d", client, g_iPendingCookieModel[client]);
|
PrintToServer("Client joined with model cookie | client %N | cookie %d", client, g_iPendingCookieModel[client]);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue