Seems like you found the way to do it, however, here is the same part of code, but written a bit better, according to me
Code:
ConVar sFunRoundsEnabled;
ConVar sRoundInterval;
int g_round_interval = -1;
public void OnPluginStart()
{
sFunRoundsEnabled = CreateConVar("funrounds_enabled", "1", "Enable/disable plugin", FCVAR_NOTIFY|FCVAR_REPLICATED);
sRoundInterval = CreateConVar("funrounds_interval", "2", "Set number of rounds between a Fun/Special round (0=Everyround will be funround)", FCVAR_NOTIFY);
HookEvent("round_end", Event_OnRoundEnd, EventHookMode_PostNoCopy);
}
public void Event_OnRoundEnd(Handle event, const char[] name, bool dontBroadcast)
{
g_round_interval++;
if (!sFunRoundsEnabled.BoolValue || sRoundInterval.IntValue <= -1 || g_round_interval != sRoundInterval.IntValue)
return;
g_round_interval = -1;
int random = GetRandomInt(1, 11);
switch(random)
{
case 1:
{
if (!sEnabledBhop.BoolValue)
return;
BhopRound = true;
}
case 2:
{
if (!sEnabledAWP.BoolValue)
return;
AWP_Round = true;
}
case 3:
{
if (!sEnabledKnife.BoolValue)
return;
KnifeRound = true;
}
case 4:
{
if(g_Game != Engine_CSGO || !sEnabledZeus.BoolValue)
return;
ZeusRound = true;
}
case 5:
{
if (!sEnabledDeagle.BoolValue)
return;
DeagleRound = true;
ServerCommand("sm_cvar sm_restrict_deagle_ct -1");
ServerCommand("sm_cvar sm_restrict_deagle_t -1");
}
case 6:
{
if (!sEnabledScout.BoolValue)
return;
ScoutRound = true;
}
case 7:
{
if (!sEnabledNegav.BoolValue)
return;
NegavRound = true;
}
case 8:
{
if (!sEnabledAK.BoolValue)
return;
AkRound = true;
}
case 9:
{
if (!sEnabledShotgun.BoolValue)
return;
ShotgunRound = true;
}
case 10:
{
if (!sEnabledGaygun.BoolValue)
return;
GaygunRound = true;
}
case 11:
{
if (!sEnabledNade.BoolValue)
return;
NadeRound = true;
}
}
SpecialRound = true;
}
new random = old syntax, use int random instead
same for new String: , use char sExampleString[16];
don't draw a montain with your code, avoid making 1 IF per indentation, use them on the same line, ex:
Code:
if (test > 5)
{
if (test2 > 3)
{
// do things..
}
}
can be changed to
Code:
if (test > 5 && test2 > 3)
avoid doing any indentation if possible. For example, instead of doing
Code:
if (sFunRoundsEnabled.BoolValue)
{
// do things...
}
// if you don't enter this IF, well.. nothing happens
do
Code:
if (!sFunRoundsEnabled.BoolValue)
return;
// do things...
Sorry for (bumping) a resolved thread
Good luck with your plugins! If you need any help, you can create a new thread and message me
(or even add me on discord)
__________________