Hello!
I am hosting a confogl server which have a scavenge config. To solve the problem there are no gascans in the first round in the previous time, the method we used is trying to restart first round twice. the plugin detail can be found here:
https://github.com/lechuga16/scavogl...eadyup_scav.sp
After then I noticed this post and the function Scavenge_FixNoGascanSpawnBug(), so I tried to use your method to solve this.
The plugin works great, gascan spawned properly in the first round, but only under the condition when you not
using sm_forcematch in server.cfg to load a scavenge config when the server starts, otherwise you will meet some extremly wired bugs like:
① gascans spawned overflownly in the first round, but you can solve this by using sm_map to change map or just simply to end the first round.
② the match will never have an end with all the previous score being set to 0, you can keep playing round 6,7,8.. although a team has already win the match.
I know these problems may not see to be so serious to be mentioned since the plugin itself runs well under the normal condition like a vanilla scavenge server or lunching the confogl config by using sm_match, I still want to report this issue.
Here is the plugin detail I edited and extracted:
PHP Code:
#pragma newdecls required
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#include <left4dhooks>
#include <scavenge_func>
float g_fMapStartTime;
ConVar
g_hGamemode,
l4d2_scavenge_rounds;
public Plugin myinfo =
{
name = "[L4D2] Fix Scavenge Issues",
author = "Eyal282",
description = "Fix bug when first round start there are no gascans and set the round number",
version = "1.0",
url = ""
}
public void OnPluginStart()
{
// ConVars
g_hGamemode = FindConVar("mp_gamemode");
l4d2_scavenge_rounds = CreateConVar("l4d2_scavenge_rounds", "5", "Set the number of rounds", FCVAR_NOTIFY, true, 1.0, true, 5.0);
// Hook
HookEvent("scavenge_round_start", Event_ScavRoundStart, EventHookMode_PostNoCopy);
//HookEvent("scavenge_round_finished", Event_ScavRoundFinished, EventHookMode_PostNoCopy);
}
public void OnMapStart()
{
g_fMapStartTime = GetGameTime();
CreateTimer(1.0, Timer_Fix, _, TIMER_FLAG_NO_MAPCHANGE|TIMER_REPEAT);
}
public void Event_ScavRoundStart(Event event, const char[] name, bool dontBroadcast)
{
// when round starts and the round number is the first round (round 1), sets the round limit.
int round = GetScavengeRoundNumber();
if(round == 1)
{
SetScavengeRoundLimit(l4d2_scavenge_rounds.IntValue);
}
}
public Action Timer_Fix(Handle hTimer)
{
char sValue[32];
g_hGamemode.GetString(sValue, sizeof(sValue));
if(StrEqual(sValue, "scavenge") && GetGameTime() - g_fMapStartTime > 5.0 && GetScavengeItemsRemaining() == 0 && GetScavengeItemsGoal() == 0 && GetGasCanCount() == 0)
{
Scavenge_FixNoGascanSpawnBug();
}
return Plugin_Handled;
}
stock void Scavenge_FixNoGascanSpawnBug()
{
char sSignature[128];
sSignature = "@_ZN9CDirector21SpawnAllScavengeItemsEv";
Handle Call = INVALID_HANDLE;
if (Call == INVALID_HANDLE)
{
StartPrepSDKCall(SDKCall_Raw);
if (!PrepSDKCall_SetSignature(SDKLibrary_Server, sSignature, strlen(sSignature)-1))
{
return;
}
Call = EndPrepSDKCall();
if (Call == INVALID_HANDLE)
{
return;
}
}
SDKCall(Call, L4D_GetPointer(POINTER_DIRECTOR));
}
stock int GetGasCanCount()
{
int count;
int entCount = GetEntityCount();
for(int ent = MaxClients + 1; ent < entCount; ent++)
{
if(!IsValidEdict(ent))
continue;
char sClassname[64];
GetEdictClassname(ent, sClassname, sizeof(sClassname));
if(StrEqual(sClassname, "weapon_gascan") || StrEqual(sClassname, "weapon_gascan_spawn"))
count++;
}
return count;
}
Some functions used from my include scavenge_func.inc:
PHP Code:
/*
* Returns the current round number of current scavenge match.
*
* @return Round numbers
*/
stock int GetScavengeRoundNumber()
{
return GameRules_GetProp("m_nRoundNumber");
}
/*
* Sets the round limit.
*
* @param round round limit to set. valid round number is 1, 3, 5.
* @noreturn
*/
stock void SetScavengeRoundLimit(int round)
{
GameRules_SetProp("m_nRoundLimit", round);
}
/*
* Returns the amount of current remaining gascans.
*
* @return amount of current remaining gascans
*/
stock int GetScavengeItemsRemaining()
{
return GameRules_GetProp("m_nScavengeItemsRemaining");
}
/*
* Returns the goal amount of this match.
*
* @return goal amount of this match
*/
stock int GetScavengeItemsGoal()
{
return GameRules_GetProp("m_nScavengeItemsGoal");
}
Bug ① appears like this:
Bug ② appears like this:
(PS: the match score should be 3:0 since the round 3 had ended, but the game continued to begin round 4, and the previous round scores and match scores were all cleared to be 0)