fixed round termination when one zombie and fixed reserve ammo

This commit is contained in:
jenz 2024-01-30 15:06:52 +01:00
parent 552a81ac14
commit c907d9e99f

View File

@ -171,7 +171,7 @@ public Action Timer_CheckIfRestartNeeded(Handle timer, any userid)
if (activePlayers == 1)
{
PrintToChatAll("First Player joining. Restarting the round...");
CS_TerminateRound(4.0, CSRoundEnd_Draw, false);
CS_TerminateRound(4.0, CSRoundEnd_Draw, true);
}
return Plugin_Handled;
}
@ -268,7 +268,7 @@ public Action Cmd_ChangeWave(int client, int args)
{
g_iWave = l_iWave;
PrintToChatAll("Admin %N Changing to Day %i: %s", client, g_iWave, g_cDaysTitles[g_iWave - 1]);
CS_TerminateRound(4.0, CSRoundEnd_Draw, false);
CS_TerminateRound(4.0, CSRoundEnd_Draw, true);
}
else
{
@ -457,43 +457,44 @@ public int Zclass_Menu(Menu menu, MenuAction action, int client, int selection)
//----------------------------------------------------------------------------------------------------
public void ZmarketGetWeapon(int client, int index)
{
if (GetClientTeam(client) != CS_TEAM_CT || !IsPlayerAlive(client))
{
PrintToChat(client, "You have to be Human for obtaining weapons");
return;
}
int l_iClientCash = GetEntProp(client, Prop_Send, "m_iAccount");
int l_iEntity;
int l_iWeapon;
float l_fClientPos[3];
if (g_iWeaponPrice[index] <= l_iClientCash)
{
l_iEntity = CreateEntityByName(g_cWeaponEntity[index][g_iLength]);
if (l_iEntity == -1)
{
ReplyToCommand(client, "Error occured");
return;
}
GetClientAbsOrigin(client, l_fClientPos);
l_iWeapon = GetPlayerWeaponSlot(client, g_iWeaponSlot[index]);
if (IsValidEntity(l_iWeapon))
{
if (GetEntPropEnt(l_iWeapon, Prop_Send, "m_hOwnerEntity") != client)
{
SetEntPropEnt(l_iWeapon, Prop_Send, "m_hOwnerEntity", client);
}
CS_DropWeapon(client, l_iWeapon, false, true);
AcceptEntityInput(l_iWeapon, "Kill");
}
TeleportEntity(l_iEntity, l_fClientPos, NULL_VECTOR, NULL_VECTOR);
DispatchSpawn(l_iEntity);
SetEntProp(client, Prop_Send, "m_iAccount", l_iClientCash - g_iWeaponPrice[index]);
PrintToChat(client, "you purchased: %s", g_cWeaponNames[index][g_iLength]);
}
else
{
PrintToChat(client, "Not enough money, requires: %i", g_iWeaponPrice[index]);
}
if (GetClientTeam(client) != CS_TEAM_CT || !IsPlayerAlive(client))
{
PrintToChat(client, "You have to be Human for obtaining weapons");
return;
}
int l_iClientCash = GetEntProp(client, Prop_Send, "m_iAccount");
int l_iEntity;
int l_iWeapon;
float l_fClientPos[3];
if (g_iWeaponPrice[index] <= l_iClientCash)
{
l_iEntity = CreateEntityByName(g_cWeaponEntity[index][g_iLength]);
if (l_iEntity == -1)
{
ReplyToCommand(client, "Error occured. cry to jenz");
return;
}
GetClientAbsOrigin(client, l_fClientPos);
l_iWeapon = GetPlayerWeaponSlot(client, g_iWeaponSlot[index]);
if (IsValidEntity(l_iWeapon))
{
if (GetEntPropEnt(l_iWeapon, Prop_Send, "m_hOwnerEntity") != client)
{
SetEntPropEnt(l_iWeapon, Prop_Send, "m_hOwnerEntity", client);
}
CS_DropWeapon(client, l_iWeapon, false, true);
AcceptEntityInput(l_iWeapon, "Kill");
}
DispatchKeyValueInt(l_iEntity, "ammo", 4500);
TeleportEntity(l_iEntity, l_fClientPos, NULL_VECTOR, NULL_VECTOR);
DispatchSpawn(l_iEntity);
SetEntProp(client, Prop_Send, "m_iAccount", l_iClientCash - g_iWeaponPrice[index]);
PrintToChat(client, "you purchased: %s", g_cWeaponNames[index][g_iLength]);
}
else
{
PrintToChat(client, "Not enough money, requires: %i", g_iWeaponPrice[index]);
}
}
//----------------------------------------------------------------------------------------------------
// Purpose:
@ -1152,7 +1153,7 @@ public void LoadWave(int wave)
{
g_iWave = 1;
PrintToChatAll("Finished last Day! Restarting...");
CS_TerminateRound(5.0, CSRoundEnd_Draw, false);
CS_TerminateRound(5.0, CSRoundEnd_Draw, true);
}
delete kv;
delete l_hFile;
@ -1778,7 +1779,7 @@ public Action UpdateWaveCount(int client)
}
}
PrintToChatAll("All Humans died!");
CS_TerminateRound(4.0, CSRoundEnd_TerroristWin, false);
CS_TerminateRound(4.0, CSRoundEnd_TerroristWin, true);
return Plugin_Handled;
}
else if (GetClientTeam(client) == CS_TEAM_T)
@ -1789,12 +1790,30 @@ public Action UpdateWaveCount(int client)
if (g_iZMCount == 0 && g_bRoundInProgress)
{
PrintToChatAll("Won Round!");
CS_TerminateRound(4.0, CSRoundEnd_CTWin, false);
CS_TerminateRound(4.0, CSRoundEnd_CTWin, true);
g_iWave++;
g_bRoundInProgress = false;
}
return Plugin_Continue;
}
public Action CS_OnTerminateRound(float& delay, CSRoundEndReason& reason)
{
//generally we only want to block round termination when all (or the only) zombies are dead but the count requires that there
//are more left to kill. we wait for the zombie to respawn so we can kill him again until g_iZMCount reaches 0.
if (g_iZMCount > 0)
{
for (int i = 1; i <= MaxClients; i++)
{
if (IsValidClient(i) && IsPlayerAlive(i) && GetClientTeam(i) == CS_TEAM_CT)
{
return Plugin_Handled;
}
}
}
return Plugin_Changed;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------