mirror of
https://github.com/Jackzmc/sourcemod-plugins.git
synced 2025-05-05 20:03:20 +00:00
l4d_survivor_identity_fix: Fill model list on late load
This commit is contained in:
parent
463b8ec8ec
commit
904f86ea9b
2 changed files with 16 additions and 3 deletions
Binary file not shown.
|
@ -23,6 +23,7 @@ char g_Models[MAXPLAYERS+1][128];
|
||||||
Handle hConf = null;
|
Handle hConf = null;
|
||||||
#define NAME_SetModel "CBasePlayer::SetModel"
|
#define NAME_SetModel "CBasePlayer::SetModel"
|
||||||
static Handle hDHookSetModel = null;
|
static Handle hDHookSetModel = null;
|
||||||
|
static bool isLateLoad;
|
||||||
|
|
||||||
#define SIG_SetModel_LINUX "@_ZN11CBasePlayer8SetModelEPKc"
|
#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_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"
|
||||||
|
@ -39,8 +40,9 @@ public Plugin myinfo =
|
||||||
}
|
}
|
||||||
|
|
||||||
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max) {
|
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max) {
|
||||||
CreateNative("IdentityFix_SetPlayerModel", Native_SetPlayerModel);
|
CreateNative("IdentityFix_SetPlayerModel", Native_SetPlayerModel);
|
||||||
return APLRes_Success;
|
if(late) isLateLoad = true;
|
||||||
|
return APLRes_Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnPluginStart()
|
public void OnPluginStart()
|
||||||
|
@ -52,7 +54,12 @@ public void OnPluginStart()
|
||||||
HookEvent("player_bot_replace", Event_PlayerToBot, EventHookMode_Post);
|
HookEvent("player_bot_replace", Event_PlayerToBot, EventHookMode_Post);
|
||||||
HookEvent("bot_player_replace", Event_BotToPlayer, EventHookMode_Post);
|
HookEvent("bot_player_replace", Event_BotToPlayer, EventHookMode_Post);
|
||||||
HookEvent("game_newmap", Event_NewGame);
|
HookEvent("game_newmap", Event_NewGame);
|
||||||
|
HookEvent("player_first_spawn", Event_PlayerFirstSpawn);
|
||||||
HookEvent("player_disconnect", Event_PlayerDisconnect);
|
HookEvent("player_disconnect", Event_PlayerDisconnect);
|
||||||
|
|
||||||
|
if(isLateLoad) {
|
||||||
|
CreateTimer(1.0, Timer_FillModelList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
@ -199,14 +206,20 @@ public Action Event_RoundEnd(Event event, const char[] name, bool dontBroadcast)
|
||||||
|
|
||||||
}*/
|
}*/
|
||||||
public void Event_NewGame(Event event, const char[] name, bool dontBroadcast) {
|
public void Event_NewGame(Event event, const char[] name, bool dontBroadcast) {
|
||||||
|
PrintToServer("Clearing models");
|
||||||
for(int i = 1; i < MaxClients + 1; i++) {
|
for(int i = 1; i < MaxClients + 1; i++) {
|
||||||
g_Models[i][0] = '\0';
|
g_Models[i][0] = '\0';
|
||||||
}
|
}
|
||||||
CreateTimer(10.0, Timer_FillModelList);
|
CreateTimer(10.0, Timer_FillModelList);
|
||||||
}
|
}
|
||||||
|
public Action Event_PlayerFirstSpawn(Event event, const char[] name, bool dontBroadcast) {
|
||||||
|
int client = GetClientOfUserId(event.GetInt("userid"));
|
||||||
|
if(IsSurvivor(client))
|
||||||
|
GetClientModel(client, g_Models[client], 64);
|
||||||
|
}
|
||||||
public Action Timer_FillModelList(Handle handle) {
|
public Action Timer_FillModelList(Handle handle) {
|
||||||
for(int i = 1; i < MaxClients + 1; i++) {
|
for(int i = 1; i < MaxClients + 1; i++) {
|
||||||
if(IsClientConnected(i) && IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i) == 2)
|
if(IsClientConnected(i) && IsClientInGame(i) && IsPlayerAlive(i) && IsSurvivor(i))
|
||||||
GetClientModel(i, g_Models[i], 64);
|
GetClientModel(i, g_Models[i], 64);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue