Minor updates

This commit is contained in:
Jackzie 2022-03-15 10:57:01 -05:00
parent 54391db7b7
commit 7fd2af923c
No known key found for this signature in database
GPG key ID: 1E834FE36520537A
2 changed files with 25 additions and 37 deletions

View file

@ -308,13 +308,12 @@ public void Frame_CheckClient(int userid) {
int client = GetClientOfUserId(userid); int client = GetClientOfUserId(userid);
if(client > 0 && GetClientTeam(client) == 2 && !IsFakeClient(client)) { if(client > 0 && GetClientTeam(client) == 2 && !IsFakeClient(client)) {
int survivorThreshold = hCookiesEnabled.IntValue == 1 ? 4 : 0; int survivorThreshold = hCookiesEnabled.IntValue == 1 ? 4 : 0;
if(++survivors > survivorThreshold && g_iPendingCookieModel[client] > 0) { if(++survivors > survivorThreshold) {
//A model is set: Fetched from cookie //A model is set: Fetched from cookie
if(g_iPendingCookieModel[client]) {
CreateTimer(0.2, Timer_SetClientModel, client); CreateTimer(0.2, Timer_SetClientModel, client);
if(cookieModelTimer != null && !cookieModelsSet) { } else {
delete cookieModelTimer; CreateTimer(0.2, Timer_SetAllCookieModels);
}else{
cookieModelTimer = CreateTimer(20.0, Timer_SetAllCookieModels);
} }
}else{ }else{
//Model was not set: Use least-used survivor. //Model was not set: Use least-used survivor.
@ -329,9 +328,9 @@ public Action Timer_SetClientModel(Handle timer, int client) {
g_iPendingCookieModel[client] = 0; g_iPendingCookieModel[client] = 0;
} }
public Action Timer_SetAllCookieModels(Handle h) { public Action Timer_SetAllCookieModels(Handle h) {
cookieModelsSet = true;
for(int i = 1; i <= MaxClients; i++) { for(int i = 1; i <= MaxClients; i++) {
if(IsClientConnected(i) && IsClientInGame(i) && g_iPendingCookieModel[i] && GetClientTeam(i) == 2) { if(IsClientConnected(i) && IsClientInGame(i) && g_iPendingCookieModel[i] && GetClientTeam(i) == 2) {
// TODO: Proper implement
SetEntityModel(i, survivor_models[g_iPendingCookieModel[i] - 1]); SetEntityModel(i, survivor_models[g_iPendingCookieModel[i] - 1]);
SetEntProp(i, Prop_Send, "m_survivorCharacter", g_iPendingCookieModel[i] - 1); SetEntProp(i, Prop_Send, "m_survivorCharacter", g_iPendingCookieModel[i] - 1);
} }
@ -425,10 +424,10 @@ public Action Cmd_SetSurvivor(int client, int args) {
ReplyToCommand(client, "Your survivor preference set to %s", survivor_names[number]); ReplyToCommand(client, "Your survivor preference set to %s", survivor_names[number]);
return Plugin_Handled; return Plugin_Handled;
}else{ }else{
int type = GetSurvivorId(arg1, false); int type = GetSurvivorId(arg1, false); // Use false to have every character have unique id
if(type > -1) { if(type > -1) {
strcopy(g_Models[client], 64, survivor_models[type]); strcopy(g_Models[client], 64, survivor_models[type]);
if(isL4D1Survivors) type = GetSurvivorId(arg1, true); if(isL4D1Survivors) type = GetSurvivorId(arg1, true); // Then fetch the correct ids for the survivorCharacter
SetEntProp(client, Prop_Send, "m_survivorCharacter", type); SetEntProp(client, Prop_Send, "m_survivorCharacter", type);
} }
} }
@ -445,7 +444,7 @@ int Menu_ChooseSurvivor(Menu menu, MenuAction action, int activator, int item) {
ReplyToCommand(activator, "Your survivor preference has been reset"); ReplyToCommand(activator, "Your survivor preference has been reset");
}else{ }else{
/*strcopy(g_Models[client], 64, survivor_models[type]); /*strcopy(g_Models[client], 64, survivor_models[type]);
if(isL4D1Survivors) type = GetSurvivorId(arg1, true); if(isL4D1Survivors) type = GetSurvivorId(str, true);
SetEntProp(client, Prop_Send, "m_survivorCharacter", type);*/ SetEntProp(client, Prop_Send, "m_survivorCharacter", type);*/
SetClientCookie(activator, hModelPrefCookie, info); SetClientCookie(activator, hModelPrefCookie, info);
ReplyToCommand(activator, "Your survivor preference set to %s", survivor_names[StringToInt(info) - 1]); ReplyToCommand(activator, "Your survivor preference set to %s", survivor_names[StringToInt(info) - 1]);
@ -499,33 +498,22 @@ public int Native_SetPlayerModel(Handle plugin, int numParams) {
} }
stock int GetSurvivorId(const char str[16], bool isL4D1 = false) { stock int GetSurvivorId(const char str[16], bool isL4D1 = false) {
int possibleNumber = StringToInt(str, 10); if(str[0] == 'b') {
if(strlen(str) == 1) { return isL4D1 ? 0 : 4;
if(possibleNumber <= 7 && possibleNumber >= 0) { } else if(str[0] == 'z') {
return possibleNumber; return isL4D1 ? 1 : 5;
} } else if(str[0] == 'l') {
}else if(possibleNumber == 0) { return isL4D1 ? 2 : 7;
/* } else if(str[0] == 'f') {
L4D2: return isL4D1 ? 3 : 6;
0 - Nick, 4 - Bill, 5 - Zoey, 6 - Francis, 7 - Louis } else if(str[0] == 'n') {
L4D1: return 0;
0 - Bill, 1 - Zoey, 2 - Louis, 3 - Francis } else if(str[0] == 'r') {
*/ return 1;
if(StrEqual(str, "nick", false)) return 0; } else if(str[0] == 'e') {
else if(StrEqual(str, "rochelle", false)) return 1; return 3;
else if(StrEqual(str, "coach", false)) return 2; } else if(str[0] == 'c') {
else if(StrEqual(str, "ellis", false)) return 3; return 2;
if(isL4D1) {
if(StrEqual(str, "bill", false)) return 0;
else if(StrEqual(str, "zoey", false)) return 1;
else if(StrEqual(str, "francis", false)) return 3;
else if(StrEqual(str, "louis", false)) return 2;
}else{
if(StrEqual(str, "bill", false)) return 4;
else if(StrEqual(str, "zoey", false)) return 5;
else if(StrEqual(str, "francis", false)) return 6;
else if(StrEqual(str, "louis", false)) return 7;
}
} }
return -1; return -1;
} }